BitMEX / api-connectors

Libraries for connecting to the BitMEX API.

Home Page:https://www.bitmex.com/app/restAPI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to have "PositionId" or "createdAtTimestamp" on the Position details?

hems opened this issue · comments

Currently, when fetching Orders we have a unique identifier for an Order ( orderID ) but we don't have the counter-party for Positions.

The documentation states "The fields account, symbol, currency is unique to each position and form its key." but in reality, if Positions are stored in a database that key won't be unique.

For instance, by opening and closing multiple positions on the same market a user will end up with several positions opened and closed and all of them will have the same "unique id".

Is it possible to somehow ensemble a unique id per position currently?

I was expecting to use symbol + openingTimestamp but just recently discovered through Bitmex support ( and @bendelo 's comment on this issue ) that this is not possible.

On my specific application, it would be very useful to have createdAtTimestamp as a way to facilitate and simplify tracking open and closed positions and also as a way of uniquely identified multiple positions.

It would also make easy to "Fetch all Trades for this position" by knowing the timestamp the position was opened.

Your concept of historical positions, which is trades being grouped into batches that occur between currentQty==0 and currentQty==0 i.e. the opening and closing of a net-long or net-short position, does not exist inside the trading engine. However you may find that GET /execution/tradeHistory gives you the historical average entry and realisedPNL of each 'position'.

https://www.bitmex.com/api/explorer/#!/Execution/Execution_getTradeHistory

Your concept of historical positions, which is trades being grouped into batches that occur between currentQty==0 and currentQty==0 i.e. the opening and closing of a net-long or net-short position, does not exist inside the trading engine. However you may find that GET /execution/tradeHistory gives you the historical average entry and realisedPNL of each 'position'.

https://www.bitmex.com/api/explorer/#!/Execution/Execution_getTradeHistory

Are there any plans of adding documentation for that endpoint?

There are several fields with `Qty" suffix, it would be great to know the difference between them

    "displayQty": 0,
    "lastQty": 0,
    "simpleOrderQty": 0,
    "orderQty": 0,
    "simpleLeavesQty": 0,
    "leavesQty": 0,
    "simpleCumQty": 0,
    "cumQty": 0,

Your concept of historical positions, which is trades being grouped into batches that occur between currentQty==0 and currentQty==0 i.e. the opening and closing of a net-long or net-short position, does not exist inside the trading engine.

What about "Open Positions", once a trade is executed and currentQty goes from 0 to negative or 0 to position?

Don't you create an "Open Position" ( which has a liquidation price, and is rollover every hour ) or every time an "get open positions" request is made to the API requesting you have to check the Trade History for each market and reconstruct the Open Positions?

I'm interested in the timestamp an open position was initiated ( first trade that happens after currentQty = 0 ), I don't particularly care for "Historical Positions".

Hence why I'm wondering what all those "Qty" properties mean on TradeHistory so i can find that information in an efficient way.

Ooops, I meant to link to this endpoint, it has currentQty on it:
https://www.bitmex.com/api/explorer/#!/User/User_getExecutionHistory

Thanks, I'll do some tests on my side and try it out.

BTW, Currently, the documentation for that endpoint on the REST EXPLORER is empty, is it available anywhere else? it would be great to have it updated on the REST EXPLORER.

Not sure how feasible it is, but might make sense to move the documentation to an open-source GitHub repository so more people could contribute?

image

image

We're looking into just that, as we want to document the columns in a way that is not possible within swagger-ui. We will likely introduce a new folder into this repository and link to it prominently from within the API documentation in the site, the Swagger Explorer, and the README here.

We're looking into just that, as we want to document the columns in a way that is not possible within swagger-ui. We will likely introduce a new folder into this repository and link to it prominently from within the API documentation in the site, the Swagger Explorer, and the README here.

Thanks for the update, i created an issue here so hopefully i'll be notified as soon as the documentation is updated.

Thank You

Also i found this issue ( #280 ) from 2018 regarding User_getExecutionHistory which is probably solved but not yet closed on this repository?

Thanks for highlighting that @hems, I've closed that ticket out.

I'm receiving always an empty array when using User_getExecutionHistory, what could be causing that? (other endpoints are working fine, I can get my trades etc, and I'm not receiving an error, just an empty array as result)

The API Explorer is also returning always an empty array (and again, my trades are returning fine from there too, just User_getExecutionHistory has that problem)

So timestamp is the exact timestamp for a realized PNL? we cannot get the full execution history?
Do we need to scan first all the trades and then for every (!) trade make a new request to get the execution history of that trade?

OK, so the timestamp is always 12:00 UTC and we need to make one request for every day?

that's a bit slow, I will probably need to make 365 requests just to get one year, but well, thanks for the clarification !