Skip to content

Strategy wont execute if the 'cash' is below asset price (e.g. BTC is 60k and starting cash is 1k) #509

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

Closed
ch4meleon opened this issue Oct 21, 2021 · 1 comment
Labels
wontfix This will not be worked on

Comments

@ch4meleon
Copy link

ch4meleon commented Oct 21, 2021

Expected Behavior

Should allow to execute the strategy and allow the calculation in the final stats.

Steps to Reproduce

...
bt = Backtest(df, Test, cash=1000, commission=.002)
stats = bt.run()
print(stats)
...

@kernc
Copy link
Owner

kernc commented Oct 21, 2021

Backtesting doesn't support fractional units. When the price is higher than starting cash, a warning is issued:

if np.any(data['Close'] > cash):
warnings.warn('Some prices are larger than initial cash value. Note that fractional '
'trading is not supported. If you want to trade Bitcoin, '
'increase initial cash, or trade μBTC or satoshis instead (GH-134).',
stacklevel=2)

It seems sufficient.

See #134 for a workaround to trade BTC.

@kernc kernc closed this as completed Oct 21, 2021
@kernc kernc added the wontfix This will not be worked on label Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants