Error live testing the example mean reversion algorithm


#1

Hi,
I have set up catalyst on my windows 10 machine and been doing well back testing.
I am fairly new to python and have been getting an error when I run in live and paper trading.
I get the error when I run the example script, mean reversion simple.
Any assistance will be appreciated!

To run it I have changed the currency to eth_btc

context.market = symbol(‘eth_btc’)
context.base_price = None
context.current_day = None

context.RSI_OVERSOLD = 60
context.RSI_OVERBOUGHT = 70
context.CANDLE_SIZE = '15T'

context.start_time = time.time()

context.set_commission(maker=0.001, taker=0.002)
context.set_slippage(spread=0.001)

I have the following edits in the ‘if live’ section
if live:
run_algorithm(
capital_base=0.0001,
initialize=initialize,
handle_data=handle_data,
analyze=analyze,
exchange_name=‘bitfinex’,
live=True,
algo_namespace=NAMESPACE,
quote_currency=‘btc’,
live_graph=False,
simulate_orders=False,
stats_output=None,
# auth_aliases=dict(poloniex=‘auth2’)
)

I am running this in spyder with the following error trace.

runfile(‘C:/Users/IanHP/AnacondaProjects/IanDevTest/mean_reversion_simpleih.py’, wdir=‘C:/Users/IanHP/AnacondaProjects/IanDevTest’)
[2018-05-28 14:38:10.412587] WARNING: run_algo: Catalyst is currently in ALPHA. It is going through rapid development and it is subject to errors. Please use carefully. We encourage you to report any issue on GitHub: https://github.com/enigmampc/catalyst/issues
[2018-05-28 14:38:10.413603] INFO: run_algo: Catalyst version 0.5.12
[2018-05-28 14:38:13.414858] INFO: run_algo: running algo in live-trading mode
Traceback (most recent call last):

File “”, line 1, in
runfile(‘C:/Users/IanHP/AnacondaProjects/IanDevTest/mean_reversion_simpleih.py’, wdir=‘C:/Users/IanHP/AnacondaProjects/IanDevTest’)

File “C:\Users\IanHP\Anaconda3\envs\catalyst\Lib\site-packages\spyder\utils\site\sitecustomize.py”, line 705, in runfile
execfile(filename, namespace)

File “C:\Users\IanHP\Anaconda3\envs\catalyst\Lib\site-packages\spyder\utils\site\sitecustomize.py”, line 102, in execfile
exec(compile(f.read(), filename, ‘exec’), namespace)

File “C:/Users/IanHP/AnacondaProjects/IanDevTest/mean_reversion_simpleih.py”, line 261, in
stats_output=None,

File “C:\Users\IanHP\Anaconda3\envs\catalyst\Lib\site-packages\catalyst\utils\run_algo.py”, line 601, in run_algorithm
stats_output=stats_output

File “C:\Users\IanHP\Anaconda3\envs\catalyst\Lib\site-packages\catalyst\utils\run_algo.py”, line 258, in _run
data_frequency=‘minute’

File “C:\Users\IanHP\Anaconda3\envs\catalyst\Lib\site-packages\catalyst\utils\factory.py”, line 70, in create_simulation_parameters
trading_calendar=trading_calendar,

File “C:\Users\IanHP\Anaconda3\envs\catalyst\Lib\site-packages\catalyst\finance\trading.py”, line 191, in init
self._end_session, direction=“previous”

File “C:\Users\IanHP\Anaconda3\envs\catalyst\Lib\site-packages\catalyst\utils\calendars\trading_calendar.py”, line 742, in minute_to_session_label
Given a minute, get the label of its containing session.

File “C:\Users\IanHP\Anaconda3\envs\catalyst\Lib\site-packages\catalyst\utils\calendars\trading_calendar.py”, line 771, in minute_to_session_label
current_or_next_session = self.schedule.index[idx]

File “C:\Users\IanHP\Anaconda3\envs\catalyst\Lib\site-packages\pandas\tseries\base.py”, line 251, in getitem
val = getitem(key)

IndexError: index 1549 is out of bounds for axis 0 with size 1549


#2

I’m not sure if this is the cause of your problem, but you have simulate orders set to false (which would mean live trading instead of paper trading), but have no API key set. If you removed the # from auth_aliases, it would also fail live trading because you would be trying to use a Poloniex API key to trade on Bitfinex.


#3

Hi SOG35,
Thanks for the suggestion. I restarted the kernel in spyder and tried again and it worked! I think there must have been some weird issue going on in spyder.
Appreciate the support - happy trading!


#4

On further investigation I think the problem was with the live and paper trading datasets stored in the hidden folder .catalyst. I had been changing the recorded data without deleting the trading data or changing the namespace. I think the code was looking to log data which wasn’t there or conflicted. New namespace or deleting the data fixed the issue.
Hi dev team,
Suggest some more info on how data is collected and reported during live and paper trading would be appreciated.
Thanks for a fun project!