JKorf / FTX.Net

MIT License
31 stars 24 forks source link

GetOrdersAsync/GetOpenOrdersAsync with strange behavior #13

Closed CharlesNascimento closed 2 years ago

CharlesNascimento commented 2 years ago

Hi. I am integrating FTX.NET into my software and these methods are always returning the same content during the lifetime of the application, even when I create/cancel orders. It behaves as if it was using some kind of cache or something. Below is an example:

  1. I start the application
  2. GetOpenOrdersAsync returns the correct orders
  3. I cancel an order (CancelOrderAsync) and create another (PlaceOrderAsync)
  4. After 10 seconds, I call GetOpenOrdersAsync again and it returns the same orders from the step two
  5. I cancel all orders (CancelAllOrdersAsync)
  6. After 10 seconds, I call GetOpenOrdersAsync again and it returns the same orders from the step two
  7. I close the application and return to step 1

I don't know if this is a configuration problem on my program or if it is a problem on FTX.NET or the FTX API itself. I am using the latest version of FTX.NET. If anyone can help me, I will be very grateful.

JKorf commented 2 years ago

Hi, the library does not implement any caching, however the API might. If you request the status after 5 minutes, does it return the correct data? Generally it is good practice to subscribe to the websocket for trade/order updates to have it available to you quickly.

CharlesNascimento commented 2 years ago

Yes, during the same lifecycle if I call GetOrdersAsync / GetOpenOrdersAsync 5 minutes after changing the orders (by canceling / placing new), the same orders from the beginning of the lifecycle are returned. Now if I rerun the application immediately after changing the orders, the first call to GetOrdersAsync / GetOpenOrdersAsync returns the correct data. Really strange behavior.

I will try to workaround it by keeping a local list of orders synced by subscribing to the websocket.

JKorf commented 2 years ago

That's the way to go yes, but you're right, that's weird behavior