andreskull / rFTX

R API for FTX
Other
5 stars 12 forks source link

ftx_orders_history() only returning results for current year #30

Open dnlbrkc opened 2 years ago

dnlbrkc commented 2 years ago

Thanks a lot for this package!

I am trying to retrieve my order history using:

ftx_orders_history("key", "secret", markets = c("BTC/USD"), tz = "GMT")

but the output only includes entries for the year 2022 but not from earlier (e.g. 2021, etc). When I try retrieving other markets where I only have history from 2021 then it returns 0 entries. So it seems like it cannot go back further than 2022 January.

Am I missing something?

andreskull commented 2 years ago

I'm not sure if I understood your issue correctly. markets parameter filters from all orders only specified orders. If you would like to get all orders regardless of market then just don't use markets parameter. The function itself is very simple and does not discriminate the orders by year. https://github.com/andreskull/rFTX/blob/main/R/ftx.R#L616-L636

dnlbrkc commented 2 years ago

sorry if I wasn't clear. my issue is that if I retrieve order history for a given market (e.g. BTC/USD) it only returns my order history for 2022, but not 2021 etc.

andreskull commented 2 years ago

Sorry, you were right. The function does not implement pagination, and by default, the FTX response includes 100 recent orders. With pagination, the max could be 5000. I will look at it next week.

dnlbrkc commented 2 years ago

Thanks! But I'm not sure that's the issue though because if I retrieve a market for which I only have order history from 2021 (e.g. SOL/USD) then the function returns 0 entries. it seems like it cannot access data from before 2022 for some reason?

andreskull commented 2 years ago

There is no way to ask for particular market orders from FTX. FTX API gives you all, and rFTX function filters out the ones you requested. To be honest, this is a silly feature and should be removed in future versions. Anyone can filter the markets from the data frame. This is the reason why tricking with markets parameter does not help you.

dnlbrkc commented 2 years ago

Oh so what you are saying is that ftx_orders_history() queries all entries and then filters on a specific market. So if all entries have more than 100 orders than the pagination issue will be a problem even if the specific market I am filtering on has less than 100 entries?

andreskull commented 2 years ago

exactly

dnlbrkc commented 2 years ago

ok got it :) it would be great if you could look into it as you said, or if you give me some pointers I can try to modify it for myself. thanks again!

andreskull commented 2 years ago

I very much appreciate it if you could help with it. My time is quite limited. I created v.0.1.3 branch where we can develop the fix. Pagination is implemented in FTX APi by start_time and end_time parameters. ftx_orders_history() should have two additional parameters - start_time and end_time. Look at the function ftx_order_fills() for hints on how the pagination is implemented. First, it would be good to test if the pagination in ftx_order_fills() works correctly.