You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have this problem when I try to run the below code, I am using the Apple M1 and a python version 3.9.13, because compatiblity whith pandas and numpy. Anybody now how to solve this problem?
from backtesting import Backtest, Strategy
from backtesting.lib import crossover
from backtesting.test import SMA, GOOG
import datetime
import yfinance as yf
ticker = "GOOG"
start = datetime.datetime(2021,1,1)
end = datetime.datetime(2023,12,31)
Hi @lfferraz, I was having the same issue. Downgrading yfinance to v0.2.44 worked for me. Maybe this isn't the best solution, but it's a quick one. Hope it helps
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
I have this problem when I try to run the below code, I am using the Apple M1 and a python version 3.9.13, because compatiblity whith pandas and numpy. Anybody now how to solve this problem?
from backtesting import Backtest, Strategy
from backtesting.lib import crossover
from backtesting.test import SMA, GOOG
import datetime
import yfinance as yf
ticker = "GOOG"
start = datetime.datetime(2021,1,1)
end = datetime.datetime(2023,12,31)
ticker_ohlc = yf.download(ticker,start,end)
class SmaCross(Strategy):
n1=10
n2=70
bt = Backtest(ticker_ohlc, SmaCross, cash=10000, commission=.002, exclusive_orders=True)
stats = bt.run()
print(stats)
print(stats['_trades'].tail(20))
print(stats['_equity_curve'].tail(20))
#bt.plot()
result_optimize, heatmap = bt.optimize(n1=range(5, 70, 5),
n2=range(10, 100, 5),
maximize='Equity Final [$]',
constraint=lambda param: param.n1 < param.n2,
return_heatmap=True)
#print(result_optimize)
#print(result_optimize['_strategy'])
print(heatmap)
hm = heatmap.groupby(['n1', 'n2']).mean().unstack()
print(hm)
All reactions