Replies: 1 comment 1 reply
-
|
I want to backtest last 500 timeframes entries but on a whole df |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
Please help me with this problem.
I want to backtest whole dataframe but with entries per 500 timeframes
e.g. len(df)=1500
entry1=df[-500:]
entry2=df[500:1000]
``
coin = 'BNB'
symbol = coin + 'USDT'
cols = ['Open', 'High', 'Low', 'Close', 'Volume']
interval = '1h'
df = vbt.BinanceData.download(symbol, start='30 days ago UTC', interval=interval).get(cols)
df.index = df.index.tz_localize(None)
df.index = pd.to_datetime(df.index, unit='ms')
y = df['Close'].tolist()
y = y[-500:] # last 500 values from a list
x = range(len(y))
best_fit_line2 = np.poly1d(np.polyfit(x, y + np.std(y), 1))(x)
best_fit_line3 = np.poly1d(np.polyfit(x, y - np.std(y), 1))(x)
entries = y < best_fit_line3
exits = y > best_fit_line2
portfolio = vbt.Portfolio.from_signals(df.Close[-500:], entries,exits, init_cash=1000)
Beta Was this translation helpful? Give feedback.
All reactions