catalyst icon indicating copy to clipboard operation
catalyst copied to clipboard

Exchange: support availabe spot values

Open brandsimon opened this issue 6 years ago • 5 comments

The documentation says, that open, high, low, close, volume, price and last_traded is supported, but only close/price and volume was supported. I changed it now, but the documentation is still incorrect, because dt and data_frequency is not used. I think, the documentation just got copied from DataPortal::get_spot_value. I changed it, so I can use data.current for backtesting and live-trading.

I have not found tests for this, if I should write some, please let me know, where the appropriate place is.

brandsimon avatar May 17 '18 13:05 brandsimon

Thanks @brandsimon for your contribution. You are correct regarding the documentation and the unsupported fields and your code is indeed addresses it. However, your PR has raised a bigger issue which we should address before fixing the code: what information should be available in the current (which in live mode calls the exchange get_spot_value function). As you know, in live the current information is retrieved from the ticker received from the exchange, which returns statistics for some period of time in recent past, usually last 24 hours. While in backtest, when requesting current, the statistics of the current date-time used by the simulation are returned (1 minute OHLCV in minute mode and 1 day OHLCV in daily mode). So both modes are not aligned, except in their price/close value. In addition to supporting spot price in live, the volume was added as well, although it might have caused more confusion (we were requested to align the backtest volume to 24H at #259). So I think we should decide on what is the best approach before updating the code:

  1. Support only the price/close field at the current in both modes.
  2. Support only the price/close field at the current in live and continue supporting all other fields at backtest.
  3. Align the backtest mode to 24H and support all fields in both modes.
  4. Align only the volume to 24H at backetest and continue supporting only price + volume at live.

lenak25 avatar May 21 '18 13:05 lenak25

@lenak25 Thank you for your response and explanation, I think I understand the underlying problem now (at least a bit better).

I dont think it is a good approach to support different fields in live and backtest mode, it is only confusing and I dont think, it is a good solution to have different code for backtest and live mode. So either solution 1 or 3 makes sense to me.

If I see it correctly, when I access the volume with current, in backtest mode I get the current volume (1T) and in live mode I get the 24hr volume. From the terminology "current", I would expect the current volume to be 1T (like I get the current price) and not the "history" volume.

Any thoughts on this? Would it raise other problems (for example poloniex only provides 5T values)?

brandsimon avatar May 22 '18 13:05 brandsimon

You are correct, not all exchanges support the 1 minute frequency - Poloniex for example. In any case, the information of the latest bar can be viewed using the data.history API as well (when supplying the required frequency - in case it supported, like discussed). Thanks for you feedback, we will consider it when addressing this. In any case, we will update the confusion documentation. We will keep this PR open until this issue is resolved. Thanks.

lenak25 avatar May 24 '18 08:05 lenak25

Please let me know, if I can help with something.

brandsimon avatar May 25 '18 13:05 brandsimon

Thanks @brandsimon !

lenak25 avatar May 27 '18 07:05 lenak25