Questions tagged [back-testing]

( in Quantitative Finance, AI, ML, ... ) A systematic approach to put a System-under-Test [ SuT ] into a state, where historical data ( a known part of both the evolution of inputs and the eco-system responses ) are used & fed into a SuT so as to review it's behaviour in-vitro ( as opposed to a forward-testing )

( in Quantitative Finance, AI, ML, Technical Cybernetics, Modelling ... )

Back-testing

is a systematic approach to put a System-under-Test [ SuT ] into a state, where historical data ( as a known part of both the evolution of inputs and the eco-system responses ) are used & fed into a SuT so as to review it's behaviour in-vitro ( as opposed to a forward-testing ).


Strengths & Weaknesses

The concept of back-testing relies on an a-priori belief ( a proof of which is left on the reader ) that the SuT does not intervene with the environment's generalised dynamics.

In other words, back-testing assumes that the SuT does not influence the future evolution moves ( the very steps that were recorded in the Historical Data, that are being fed into the SuT during the flow of back-testing ) that the outer ecosystem, surrounding the SuT, actually undertook in the past.


Tools

Strategy Tester, Quantopian, Quant Modeller, Quant Strat, AmiBroker, TradingView, MultiCharts
and many more


Historical Data

Quandl, Olsen Data, Dukas Copy, Yahoo! Finance, Google
and many more

255 questions
0
votes
1 answer

Pyalgotrade's ninjatraderfeed fails after 7 onBars() calls

I'm trying to use the ninjaTrader feed via CSV files containing minute data. The program works as intended for seven onBars calls, then spits an error: self.info(str(instr) + " current Open price: %.2f" % (bars.getBar(instr).getOpen()))…
0
votes
1 answer

Backtest with rebalancing - automation

I'm currently trying to set up a PSQL database for a portfolio backtest and was wondering if anyone had a more automated solution for future changes. Say I have a portfolio with stocks A, B, and C. I change the weights on the portfolio each month.…
user3628240
  • 877
  • 1
  • 23
  • 41
0
votes
1 answer

Backtesting with Data

In a hypothetical scenario where I have a large amount of data that is received, and is generally in chronological order upon receipt, is there any way to "play" the data forward or backward, thereby recreating the flow of new information on demand?…
KidMcC
  • 486
  • 2
  • 7
  • 17
-1
votes
1 answer

Open multiple positions in Backtrader

Does someone know if it's possible to open multiple positions with only a single data feed? I am trying to do a second buy whilst in a position, which doesn't seem to be possible. Nobody seems to adress this issue. Does anyone have any experience…
yebowo
  • 3
  • 1
-1
votes
1 answer

Fill order below/above the low/ high of the bar in pine script

Is it possible to fill an order below/above the low/high of the bar (not below/above the close)? With process_orders_on_close = true - the order is filled on close of the bar and with process_orders_on_close = false - on the next bar but I need an…
admiral
  • 1
  • 2
-1
votes
1 answer

How can I speed up this pandas dataframe for loop computation?

I have the following dataframe of BTC price for each minute from 2018-01-15 17:01:00 to 2020-10-31 09:59:00, as you can see this is 1,468,379 rows of data, so my code needs to be optimized otherwise computations can take a long time. dfcondensed =…
-1
votes
1 answer

I'm unable to plot a backtest of my algorithm

Thank you in advance for any help! I'm trying to backtest a very simple moving average cross over strategy in Python. I'm using the Jupyter notebook. I've installed and imported backtrader and matplotlib. However, I'm unable to plot anything and I…
TLS
  • 31
  • 4
-1
votes
1 answer

Create historical data from a dataframe in pyspark

I have a dataframe as follows: date some_quantity ... ... 2021-01-01 4 2021-01-02 1 2021-01-03 6 2021-01-04 2 2021-01-05 2 2021-01-06 8 2021-01-07 9 2021-01-08 1 ... ... I would like to create the historical data for…
-1
votes
1 answer

Calculating RSI in Python for BTC Trading Backtesting

I already calculated the RSI for BTC which worked fine. I want to add a new column [Position] to my dataframe, which indicates if my current position is long or short. Now I am trying to do a Loop, which should give me the output, if I am Longing or…
Matthias
  • 19
  • 5
-1
votes
1 answer

Python: How to count the number of moving average crossovers + highest point between each crossover?

I am backtesting a simple moving average strategy, using price (for example daily bars) and a simple moving average. I want to find out how often the price crossed over or below the moving average over my historical data for stock X. In other words…
-2
votes
0 answers

How do I take an element from the previous row in a datafrme in Python?

I have a dataframe with open, high, low, close, 8DayMovingAverge, 21DayMovingAverage, and when the 8dma turns higher (1 or 0). For 'entry' I want the trade entry level to be the closing price when the 8ma turns higher. All good. But, then I want to…
Bugsy
  • 49
  • 2
  • 8
-2
votes
1 answer

not able to resolve a python error while using backtesting library

The error is as follows: Traceback (most recent call last): File "/home/runner/stock/test.py", line 160, in strategy = MyStrategy(data=df_1h, params={}) File "/home/runner/stock/test.py", line 108, in __init__ …
-2
votes
1 answer

can you use pine-script to alert you that an indicator has passed a certain level for the first time in a few months?

so im trying to write a script which can alert me when the sma of the williams%r crosses above -20 or bellow -80, for the first time in 1 month for example. is this possible with pinescript?. thanks in advance.
-3
votes
2 answers

Comparing the High and Low from one day to the previous

I am trying to make and indicator to use in my quantstrat backtest but can't seem to figure out how to write it. Basically I want to compare the High and Low from 2 days ago to the H&L from 3 days ago. If day 2's H&L is lower than day 3 I'll make…
Cameron Giles
  • 72
  • 1
  • 8
-4
votes
1 answer

0.5% per hour profit Trading bot?

If I had CryptoCurrency trading bot that can give me 0.5% profit in hour, and the exchange fees is 0.075%, and my capital balance is $1000, how can I calculate the return profit of 365 hours using a cumulative trading strategy ? I came up with this…
1 2 3
16
17