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
3
votes
2 answers

Vectorising a for loop where logic spans rows

The table below shows an example of a strategy where a signal is generated in row 2 and then an opposite signal is generated in row 5. row open_signal close_signal live 1 0 0 0 2 …
Ian Ash
  • 1,087
  • 11
  • 23
3
votes
2 answers

Why does backtrader not display time when backtesting?

I am trying to backtest a strategy with Backtrader and have a problem while printing date & time for each iteration (time stay on 23:59:59). Here are the first lines of my dataset: What is printed on the console : And finally how I load my data…
AlexM
  • 231
  • 2
  • 13
3
votes
1 answer

F# data feed abstraction

I am trying to learn F# and would like to create a platform to test trading strategies. Usually brokers API broadcasts C# events every time a tick in the book is updated. What is the proper functional way to listen to C# events and react to those?…
3
votes
1 answer

Position sizing

I currently have my backtest set up so that it will invest 25% of my current equity. The problem this is causing is when my capital starts to grow the strategy starts taking on enormous trades. How do I specify for it do invest Equiuty*0.25 but only…
Cameron Giles
  • 72
  • 1
  • 8
3
votes
0 answers

Multi symbols in Quantstrat

First, I would like to thank the community for the fantastic support and reactivity. I encounter a problem applying a simple MA crossover strategy on multi instruments. Basically, I maintain a database of csv price files. I retrieve these files…
NicolasB
  • 83
  • 5
3
votes
1 answer

Event Driven Backtesting Engine Speed

I'm current developing an event-driven backtesting engine in Python. I would like to have an idea about how fast a high speed backtesting engine should be, especially in Python. Right now, I can replay one year of 1 min bar data about 10 hours.Is it…
SimonZ
  • 31
  • 1
2
votes
0 answers

How to tick-level backtest the spot grid trading strategy?

Is there a Python library with which I could tick-level backtest the famous Spot Grid Trading crypto strategy? I already did the tick data download part from data.binance.vision, although in my attempt I have used backtesting.py that seems to not be…
nop
  • 4,711
  • 6
  • 32
  • 93
2
votes
1 answer

Azure Data Explorer (Kusto/KQL) Financial Asset Backtesting Trail Stop

I have a data set of financial asset prices over time and I'd like to mimic a trail stop for back testing strategies against this data set. Trail stops are a type of trade order supported by some online brokers that are used as a stop loss or profit…
2
votes
1 answer

Calculation of floating weights based on weight and return DataFrame

I have two DataFrames; returns and weights and I try to combine them to a floating_weights DataFrame. The idea behind this is that I want to dynamically adjust the weights in period t with the return in period t-1. So the weights increase if there…
fjurt
  • 783
  • 3
  • 14
2
votes
0 answers

strategy with default_qty_type=strategy.percent_of_equity and default_qty_value=200 output same result as without leverage

While backtesting a pine strategy on tradingview I noticed that the docs allow to and use couple of options to set a leverage (just like you have on exchanges while trading futures/contracts). Hence, as per the docs recommendations, I added the…
gastngouron
  • 461
  • 1
  • 5
  • 15
2
votes
0 answers

Vectorized backtesting using a Pandas Dataframe with stop loss and take profit

I'm looking to do vectorized backtesting using a Pandas Dataframe and I'm having trouble setting a fixed stop loss and take profit. For example (see image): On 2021-11-26 at 17:44 there is a buy signal (setup == 1) . The purchase would be made if…
CeBoLaRk
  • 33
  • 1
  • 4
2
votes
2 answers

Why does pine script enter at the next candle open even when I am using a market order?

I am trying to implement a 2 period RSI based strategy backtest in Pine Script. The idea is simple Objective 2 Period RSI crosses under 10, when 200 EMA is below the recent close, I go long on the next candle with a market order set to limit 2%…
Abhishek
  • 1,101
  • 8
  • 8
2
votes
1 answer

How to create Multiple Seperate Long Entry and Long Exit Orders in one script

I am trying to figure out how to create multiple Long orders in one script. For example, I put together one script that has 3 buy / sell conditions, and I would like each to have it's own entry / exit parameters. Figuring out how to order multiple…
2
votes
1 answer

Enter the cost of the spread in the Pine Script strategies

Good morning, I am trying to find a possibility to insert the spread as a fixed cost for each trade in my Pine Script strategies on Tradingview. I give an example: I write a strategy on Pine script and execute it. Logically, the results will not be…
2
votes
0 answers

Why my calculation does not match metatrader 4 backtest loss?

I am writing and expert advisor and ran a test. And I cannot understand, and find info why loss amount is not matching my calculations. To do backtesting I should get correct results. So in the image we see there was 0.79 lot position opened at…
Dariux
  • 3,953
  • 9
  • 43
  • 69
1
2
3
16 17