test: add error path test for live trading get_data
- Add check for `mt5.copy_rates_from_pos` returning `None` in `live_trading/multi_bar.py:82` - Add test in `tests/test_multi_bar.py` verifying that when `mt5.copy_rates_from_pos` returns `None`, the function returns `None` and an error is logged. Co-authored-by: maghdam <63883156+maghdam@users.noreply.github.com>
This commit is contained in:
co-authored by
maghdam
parent
29fcbf0f9d
commit
5c24d2d72d
@@ -82,6 +82,9 @@ class TradingApp:
|
||||
Fetch 'n' bars of historical data for the given symbol and timeframe.
|
||||
"""
|
||||
rates = mt5.copy_rates_from_pos(symbol, timeframe, 0, n)
|
||||
if rates is None:
|
||||
log_and_print(f"Could not retrieve data for {symbol}", is_error=True)
|
||||
return None
|
||||
rates_frame = pd.DataFrame(rates)
|
||||
rates_frame['time'] = pd.to_datetime(rates_frame['time'], unit='s')
|
||||
rates_frame.set_index('time', inplace=True)
|
||||
|
||||
Reference in New Issue
Block a user