274 questions
0
votes
0
answers
54
views
Latest trade and last date in backtesting period in backtesting.py
In backtesting.py, when looking at the trade statistics, the latest of field Last exit date is always filled with a date which is more recent than the latest date in field Last entry date. This means ...
1
vote
0
answers
54
views
Installation of backtesting package through Conda failed
I'm using backtesting.py package https://kernc.github.io/backtesting.py/ in the latest Anaconda distribution. The computation is finished successfully with right result. But it's not possible to show ...
0
votes
0
answers
79
views
Vectorbt Setting exit trade with max duration
I am a vectorbt newbie. so far I have been successfully setup many parameters, but what I cannot find is a way of exiting the trade if the max number of bars is reached
This is my current function:
...
0
votes
1
answer
261
views
Try to code risk-reward ratio of 1:3 with PineScript
unable to get the reward part working
Hi, I'm trying to calculate the profit price target based on the distance between entry price and recentlow, then times 3 to get 1 to 3 risk-reward setup working ...
1
vote
0
answers
79
views
Sellstop order not executing if a buy trade is already open
I have run two tests which clearly explain the scenario. Please see code block below of notify_order and notify_trade.
**Test 1 (execute only 1 sellstop order):
**
When I solely execute a sellstop ...
0
votes
0
answers
37
views
Trouble when compiling rolling_sharpe_ratio in VectorBT
Im just trying to run vectorbt to test out some of it's functions, in this case the rolling_sharpe, but I keep getting this error, does anyone know to solve this problem?
File "/Users/datwiththed/...
0
votes
1
answer
210
views
Use Google finance to check when a stock hits a target price in a given period
I am trying to do stock backtesting in Google sheets.
I have entered scrip symbol in A3, entry date in B3, the last date to exit the stock in C3 and the target price in D3. Now I want to find on which ...
0
votes
1
answer
62
views
Python Backtest Dataframe Shape Error Issue
I'm running the following code and getting this error - ChatGPT cannot solve this one. Please help.
Here is the code:
import pandas as pd
import numpy as np
import yfinance as yf
import matplotlib....
0
votes
0
answers
71
views
Removing Weekends from Historical Stock Data from Oanda API
I'm pretty new to programming and I am learning to code a backtest with data from Oanda API. When I plot the chart below, I get these gaps on weekends. I check the data and index(time) does not show ...
-1
votes
1
answer
302
views
how to implement ask and bid price in entry price in backtesting.py
I want to implement spread so I calculate the ask and bid price already
class TestStrategy(Strategy):
def next(self):
current_price = self.data.Close[-1]
current_spread = self....
0
votes
1
answer
151
views
How can I calculate my spread data upon entry and exit I only have spread in for per row in my csv
I'm trying to make a back trading class. but I don't really get how spread works for example if you buy in 1.06649 how will spread works here? and in the same trade if I exit in my intended take ...
0
votes
1
answer
113
views
How To Add Custom Data While cerebo.add(data) Adding Data Toward Ttrategy?
I'm facing some of the problem about adding custom data for strategy.
Most of the case which I can search on Internet is the data contain OHLCV (which is the default by backtrader)
But now my custom ...
2
votes
0
answers
239
views
limited trade execution using using backtesting.py library
My goal is to backtest data where you provide buy/sell dates and closing prices to backtest module in order to backtest data from one source csv (instead of having 3 separate files such as price data, ...
1
vote
1
answer
80
views
MQL4 - Expert Advisor EMA issues at closing order
I'm trying to build my own EA using EMA. When the program starts it will buy/sell according to the relative position of slow and fast EMA. Then the program should close the trade at the next EMA ...
-1
votes
1
answer
62
views
Merge Pandas sub dataframes in one sorted by date and add column symbol
I have a number of csv files with stock data and i create a Pandas data frame with a for symbol in symbol list loop by providing the path and reading these files..
The data frame has each stock sub ...
1
vote
1
answer
475
views
Backtrader - IndexError: list index out of range
I'm trying to load a custom data feed from a csv file that I've generated called "impact.csv" through the script below "backtrader_impact.py".
However, at "cerebro.adddata(...
0
votes
1
answer
1k
views
MACD Strategy in Backtesting.py
Good afternoon, can anyone tell my why the following strategy is not generating signals? The RSI part works fine but I have problems with the MACD. I tried the logic on a normal data frame, it worked ...
0
votes
1
answer
99
views
how to find df cells that are above/below pivot points, but only once
I've got pandas dataframe with candle highs and lows. I've made new column, which shows pivot points (if the value in cell is lowest\highest between two above it an two below it, it has value 1 for ...
0
votes
1
answer
368
views
Anyone facing ValueError for RSIIndicator for ta backtesting?
Trying to get some idea on how to debug this. Just started to use backtesting.py + TA to conduct some backtesting. Seems to work for EMA indicator. RSI indicator did not work: Tried with self.rsi ...
0
votes
1
answer
643
views
Unable to run backtesting.py on Jupyter Notebook
Backtest.run()
Output:
<bound method Backtest.run of <backtesting.backtesting.Backtest object at 0x0000022BAA3F79A0>>
Backtest.plot()
Output:
<bound method Backtest.plot of <...
-1
votes
1
answer
288
views
Truth Ambiguity Error in Backtesting.py Backtest
I am trying to backtest a momentum strategy using Backtesting.py. I've gathered the data and computed indicator values using pandas_ta. I've defined short and long trading conditions. Now I just ...
3
votes
1
answer
770
views
Trading fractional shares with Backtesting.py
'UserWarning: 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-...
0
votes
0
answers
195
views
Stop loss mechanics while backstesting on time series
I'm presented with the following problem. I have time series data of prices and through the use of the "loc" method I was able to create a new column "trade" that stores the close ...
0
votes
1
answer
291
views
Backtesting.py function resample_apply not defined
To learn how to use the Backtesting.py library I followed this YouTube video:
https://youtu.be/9m987swadQU?si=6UN7ARnrYrN6u7nf
But when I wrote my Strategy class:
class MomentumStrategy(Strategy):
...
0
votes
1
answer
735
views
I am getting a Value Error when running backtest for a simple trading strategy using backtesting module, Can anyone solve this issue?
I am trying to backtest a simple trading strategy using python3 using the backtesting module. Here is a sample of the data I am using through an external CSV:
Date,Open,High,Low,Close,Volume
2023-08-...