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
TypeError: ufunc 'isnan' not supported for the input types #104
Comments
I believe this should be addressed in a recent update. Try running |
Google Colab Output
Windows Output
|
Looks like it worked great. I think the size might be casted to an |
I try rsi.py but it is not worked.
|
I believe the blankly code is working correctly, it is mainly due to issues with order sizing. Try out this version: import blankly
def price_event(price, symbol, state: blankly.StrategyState):
""" This function will give an updated price every 15 seconds from our definition below """
state.variables['history'].append(price)
rsi = blankly.indicators.rsi(state.variables['history'])
if rsi[-1] < 30 and not state.variables['owns_position']:
# Dollar cost average buy
buy = blankly.trunc(state.interface.cash/price, 2)
state.interface.market_order(symbol, side='buy', size=buy)
state.variables['owns_position'] = True
elif rsi[-1] > 70 and state.variables['owns_position']:
# Dollar cost average sell
curr_value = state.interface.account[state.base_asset].available
state.interface.market_order(symbol, side='sell', size=curr_value)
state.variables['owns_position'] = False
def init(symbol, state: blankly.StrategyState):
# Download price data to give context to the algo
state.variables['history'] = state.interface.history(symbol, to=150, return_as='deque',
resolution=state.resolution)['close']
state.variables['owns_position'] = False
if __name__ == "__main__":
# Authenticate coinbase pro strategy
exchange = blankly.CoinbasePro()
# Use our strategy helper on coinbase pro
strategy = blankly.Strategy(exchange)
# Run the price event function every time we check for a new price - by default that is 15 seconds
strategy.add_price_event(price_event, symbol='BTC-USDT', resolution='1h', init=init)
# Start the strategy. This will begin each of the price event ticks
# strategy.start()
# Or backtest using this
results = strategy.backtest(to='1y', initial_values={'USDT': 10000})
print(results) |
This is extremely interesting to me - I'm testing the code locally with the same 1h for 1 week resolution & I'm getting a result. I think that to make it work you
Thanks for sticking through this process. We're trying to identify and reduce the pains with onboarding new users and we are learning a ton from this and will give debugging prints when users hit this error in the future. |
I found the error. I hope you don't get mad at me.😟 error messages could be very instructive. The cash setting is BUSD in the setting file, but the result failed because I tried USDT in the code I tested. I noticed it in the VM where I installed Linux Mint. |
Awesome I'm glad you got it working. These symbol and quote errors can be extremely easy to miss and will require more work on our part to get everything working. Just let me know if you have any more issues and I'm glad to help out. We learn a lot every time we help someone get up and running. |
Description
When I try the RSI code on the Google Colab Jupyter, I get the following error.
Error on Colab
When I try the RSI code on the Windows desktop, I get the following error.
Error on Windows Desktop
The text was updated successfully, but these errors were encountered: