Closed WudsyWudsyWudsy closed 5 years ago
Hi @WudsyWudsyWudsy
Thanks for taking time and making proposal for improving the WebSocket feed.
The requirement you mentioned about broadcasting trade data makes a lot of sense and was part of our team's original plan for next iterations.
From a solution perspective, we have tried to stick to principale of separating market data (trade
, trade
, orderbook
) from individual account order and trade data so adding account trade information (price, volume, fee, liquidity type, fee, etc) inside the orderChange
event seems to be consistent with our model as per below:
{
"orderId": 312899,
"marketId": "XLM-AUD",
"type": "Limit",
"side": "Bid",
"openVolume": "0",
"status": "Fully Matched",
"triggerStatus": "",
"timestamp": "2019-04-11T20:08:41.393Z",
"trades": {
"tradeId": 310827,
"price": "0.1634",
"volume": "10",
"liquidityType": "Taker",
"fee": "0.001"
},
"messageType": "orderChange"
}
Our team is now making the trade information available as part of the current solution and I will update this ticket (and also the documentation) shortly.
For clarity we will also update the documentation for fundChange
event type as it was only meant to cover fund transfers (e.g. deposit and withdraw) and not individual balance changes.
Thanks again for your great feedbacks.
Hi @martin-nginio
Thanks for the time to review and respond to my feature request, as well as getting it implemented so quickly. Very impressed and grateful!
Your implementation is great and fulfills all my needs.
One comment on an inconsistency I have noticed though. When trades
is empty it returns an empty array however when an order is matched it returns a single object (examples found end of post).
I am yet to be able to try the case where one single order instantly takes multiple trades. This case was the reason I suggested using an array of objects structure. For coding purposes it is much easier if the structure is consistent, always returning an array of object, even if empty or a single trade, allowing a for forEach
loop etc.
Current no trades - empty array
{ orderId: 3174292371,
marketId: 'BTC-AUD',
type: 'Limit',
side: 'Ask',
openVolume: '0.00178155',
status: 'Placed',
triggerStatus: '',
timestamp: '2019-04-13T00:56:52.960Z',
trades: [],
messageType: 'orderChange' }
Current single trade - object
{ orderId: 3174265243,
marketId: 'BTC-AUD',
type: 'Limit',
side: 'Bid',
openVolume: '0',
status: 'Fully Matched',
triggerStatus: '',
timestamp: '2019-04-13T00:51:46.230Z',
trades:
{ tradeId: 3174277067,
price: '7095',
volume: '0.00178155',
fee: '0.1074407',
liquidityType: 'Marker' },
messageType: 'orderChange' }
Suggested single trade - array of a single object
{ orderId: 3174265243,
marketId: 'BTC-AUD',
type: 'Limit',
side: 'Bid',
openVolume: '0',
status: 'Fully Matched',
triggerStatus: '',
timestamp: '2019-04-13T00:51:46.230Z',
trades:
[{ tradeId: 3174277067,
price: '7095',
volume: '0.00178155',
fee: '0.1074407',
liquidityType: 'Marker' }],
messageType: 'orderChange' }
Suggested multiple trade - array of a multiple objects
{ orderId: 3174265243,
marketId: 'BTC-AUD',
type: 'Limit',
side: 'Bid',
openVolume: '0',
status: 'Fully Matched',
triggerStatus: '',
timestamp: '2019-04-13T00:51:46.230Z',
trades:
[{ tradeId: 3174277067,
price: '7095',
volume: '0.00178155',
fee: '0.1074407',
liquidityType: 'Marker' },
{ tradeId: 3174277067,
price: '7095',
volume: '0.00178155',
fee: '0.1074407',
liquidityType: 'Marker' }]
messageType: 'orderChange' }
thanks for the note. Sorry, passing a single object was a bug and using array indeed was the intention (as per documentation/wiki updated earlier today). The issue will be resolved shortly.
Thanks.
Thanks! Final tiny note, the wiki documentation is currently still missing marketID
and side
in the examples. Otherwise this is resolved!
Thank you again. I seriously cant praise your speed and responses enough.
documentation was updated. thanks.
Feedback regarding the new WebSocket v2 Beta.
The problem
As a trader, when one of my orders is matched the most important information I need to get is my change in balances. This is currently very hard (actually impossible) to get via the WebSocket.
To get my change in balances I need the following information about each trade:
It is also very handy to have
Using trade Currently
trade
will give memarketID
,price
,volume
and atradeID
. However there is nothing to tell me if that that trade ismine
, whatside
I was on, thefee
involved, the correspondingorderID
or theopenVolume
.Using orderChange Currently
orderChange
will give memine
via only getting messages regarding my orders,openVolume
andorderID
.Assuming I held an array of orders as I placed them, using
orderID
, I could find themarketID
, reference theside
and compute thevolume
via comparing the initialvolume
andopenVolume
However as it gives me no link to to the
tradeID
, onlyorderID
, I can not find out theprice
it was executed at in the case that I moved the market. For example:I sell 5 BTC for $7 each (or market)
In this case I would get $44 (1 x 10 + 2 x 9 + 2 x 8) for my 5 BTC, however if I looked up my orderID, it would be priced at $7, and that I should have got $35 (5 x 7). So the actual
trade
s need to be linked under theorderChange
I could then look up my
fees
and calculate them myself, however this all could be much easier.Possible Solution 1: Authenticated Trades
When an authenticated user subscribes to
trade
, the following additional information should be added to the message:trade
mine: (bool) true if the user was one of the two parties involved in the trade, false otherwise
orderInformation: (object) only valid if mine was true
orderID: (number) the order ID
side: (string) what side the authenticated users order was of the trade
openVolume: (number) the remaining open volume
funds: (number) only valid if mine was true - the increase / decrease in funds **after fees** that the authenticate user received. Using side they could determine which balance was altered by the funds, and the calculate the other balance change by looking at price and volume
Possible Solution 2: My Trades (my preference)
A further step to this would be a separate authenticated subscription called
myTrades
, this has the advantages of reducing waste bandwidth as I actually only care about my trades, removes themine
part, and keeps everytrade
message the same.myTrade
Possible Solution 3: Add trade information to orderChange
The most simple method if this would simply be adding an array of
tradeID
's to theorderChange
message.The issue however with this is you have to keep an array of the
trade
messages to compare thetradeId
to and you are reliant on ordering of the messages or implementing wait loops.It is much cleaner if you include all the trade information in an array under the message. (Array should only include
trade
s since lastorderChange
message, but allows you to combined messages if the market is moved such as the example given above)orderChange
Everything here is same as above.
Possible Solution 4: Add trade event to fundChange
Finally you could notify the change of balance of each asset via
fundChange
. The trader could then use a combination oforderChange
andfundChange
to manage their balance changes andorderId
s.This could be the most simple solution, and makes dealing with fees very clear, however its the least nice to have as you still have no link between
orderId
s and the actual price it was executed at and for analysis purposes his is not ideal.