catalyst
catalyst copied to clipboard
catalyst.api.record fails randomly in live mode (Bitfinex)
The code:
record(
price=data.current(symbol('btc_usd'), 'price'),
volume=data.current(symbol('btc_usd'), 'volume'),
cash=context.portfolio.cash,
leverage=context.account.leverage,
)
The exception:
Traceback (most recent call last):
File "main.py", line 338, in <module>
main()
File "main.py", line 300, in main
quote_currency='usd'
File " /catalyst/utils/run_algo.py", line 596, in run_algorithm
stats_output=stats_output
File " /catalyst/utils/run_algo.py", line 358, in _run
overwrite_sim_params=False,
File " /catalyst/exchange/exchange_algorithm.py", line 1075, in run
data, overwrite_sim_params
File " /catalyst/exchange/exchange_algorithm.py", line 362, in run
data, overwrite_sim_params
File " /catalyst/algorithm.py", line 725, in run
for perf in self.get_generator():
File " /catalyst/gens/tradesimulation.py", line 222, in transform
for dt, action in self.clock:
File " /catalyst/exchange/live_graph_clock.py", line 74, in __iter__
self.context.frame_stats, recorded_cols=recorded_cols
File " /catalyst/exchange/utils/stats_utils.py", line 198, in prepare_stats
value = row_data[column]
KeyError: 'price'
I have discovered this error also for others keys like 'cash' etc.
The same code is working in backtest without problems.
Use Catalyst version 0.5.18
Thanks @avolution , we will investigate this.
Hi @avolution, I have tried to reproduce it, because it happens randomly, it is very difficult to reproduce. Is there more information that you can provide? Thanks
I have same problems in backtest mode. Sometimes ,it record. now it is not working