-
Notifications
You must be signed in to change notification settings - Fork 678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IndexError in is_overbought_or_oversold() #14
Comments
@mbronckers I think this might be occurring because of the contract type. In your main.py, are you trading Forex contracts? Try using stock contracts instead: main.py
I can't be 100% certain, but I'm not getting your index error anymore. I still can't run the code because I removed all my market data subscriptions, but the error I have now is just:
This is to be expected. If I had a market data sub, this code should run correctly. |
ALTERNATIVE SOLUTION (if you're still receiving the out-of-bounds indexing error):The easiest way to fix the problem is to change the array. Your code is trying to get the last price (i.e. T-1) but the array position [-1] does not exist. I found a workaround in an earlier release, but it has been months since I've touched that code. Take a look at lines 276 - 358 of this file. The mathematics might seem a little complex, but you should be able to understand how the array of stock prices is indexed and referenced. Feel free to reach out if you need help! |
Same as #18 |
I get an index error while trying to run the main.py related to the last_prices_a & last_prices_b:
High-Frequency-Trading-Model-with-IB/test/models/hft_model_1.py", line 208, in is_overbought_or_oversold last_price_b = self.df_hist[symbol_b].dropna().values[-1] IndexError: index -1 is out of bounds for axis 0 with size 0
related to line 208:
Any thoughts or help would be appreciated. Thanks.
The text was updated successfully, but these errors were encountered: