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

How to optimise parameters in a TradingView Pine script?

I want to optimise indicator parameters in a TradingView Pine backtest. This is possible with other tools, but when I search for this functionality in TradingView I don't find anything. Can anybody please help? If it isn't possible in TradingView,…
9
votes
2 answers

Trailing Stop Loss on Pandas dataframe

I am doing some backtesting for some trading strategies on the stock market on a pandas dataframe and I would like to set a trailing stop loss of 1% away from the entered price. If the stock price went up by let's say 5%, the trailing stop loss will…
atjw94
  • 529
  • 1
  • 6
  • 22
7
votes
3 answers

How do I feed in my own data into PyAlgoTrade?

I'm trying to use PyAlogoTrade's event profiler However I don't want to use data from yahoo!finance, I want to use my own but can't figure out how to parse in the CSV, it is in the format: Timestamp Low Open Close High BTC_vol …
5
votes
0 answers

How exactly does trail_price, trail_offset work in pinescript?

Thank you all for your help so far. I have been coding many different strategies in pinescript so far, and I have read through pinescript manual and many google articles, but I am still confused as to how trailing stop work in pinescript. For…
5
votes
2 answers

Progress bar (using tqdm) prints in a new line everytime the update is called on the tqdm object (VSCode terminal)

I am trying to print the status of the progress of an optimization algorithm using the tqdm module available in Python, however, every time I try to update it, it prints the progress in a new line, is there a way I could only update the original…
yash
  • 331
  • 1
  • 3
  • 12
5
votes
1 answer

How to get profit percentage of trade during backtest in Amibroker

I am using Amibroker v6.3 I would like to find out the profit percentage of a trade taken during backtest, then adjust the sell criteria accordingly. When profit is below 10%, I want to use this function sell_below10(). When profit is >10%, then use…
user3848207
  • 3,737
  • 17
  • 59
  • 104
4
votes
4 answers

backtesting.py ploting function not working

I'm trying to learn backtesting.py, when I run the following sample code, it pops up these errors, anyone could help? I tried to uninstall the Bokeh package and reinstall an older version, but it doen't work. BokehDeprecationWarning: Passing lists…
Ka Meng Ng
  • 41
  • 1
  • 2
4
votes
0 answers

VectorBT backtesting python intraday problem

I'm using VectorBT in python to backtest a strategy, however as soon as I get any intraday data with gaps, this is what happens: Obviously, the gaps are nights/holidays etc, and because of that the indicators are calculated incorrectly - this is…
Fatafim
  • 287
  • 2
  • 13
4
votes
0 answers

How to create an custom entry/exit signal in VectorBT?

thanks for reading! I'm trying to backtest a strategy that I wrote in Pinescrpt, and I struggle to create my entry conditions. So this is the code import numpy as np import pandas as pd import vectorbt as vbt from datetime import datetime from…
4
votes
1 answer

Vectorbt - Importing an indicator from Pandas_ta and setting entries and exits

I am trying to import the VWAP indicator from pandas_ta and test a simple strategy utilizing it with vectorbt. My code so far is: import vectorbt as vbt binance_data = vbt.BinanceData.load('ADABUSD_1m') high = binance_data.get('High') low =…
4
votes
1 answer

bt - Flexible Backtesting for Python - how to get total portfolio value/result for each given date?

I have recently started using bt for backtesting, and after looking into the documentation, https://pmorissette.github.io/bt/bt.html, there does not seem to be a way to get the total portfolio value at each date, even though it can be easily plotted…
OGARCH
  • 97
  • 1
  • 4
4
votes
1 answer

Scale in buying positions in Amibroker backtesting

I have a simple backtesting code in Amibroker. It looks something like this; Buy = BuySignal(); Sell = SellSignal(); My equity is $10000. This code works but the limitation is that when it buys, the entire equity $10000 is sunk into the buy. What…
user3848207
  • 3,737
  • 17
  • 59
  • 104
4
votes
2 answers

How to manually provide a benchmark in zipline

I want to create a reproducible example where the traded series and the benchmark are manually provided. This would make the life of people that are approaching to zipline incredibly easier. In fact, given the recent shut down of Yahoo!Finance API,…
MLguy
  • 1,776
  • 3
  • 15
  • 28
3
votes
0 answers

I have a issue at Backtrader Lib

I am interested in backtesting for my strategy by backtrader but I have a problem in the beginning. Here is my code: import backtrader as bt cerebro = bt.Cerebro() data = bt.feeds.GenericCSVData(dataname='BTCUSDT_15min.csv', dtformat =…
3
votes
2 answers

Calculate per trade Profit and Loss (PnL) using Pandas Dataframe

I have this pandas dataframe where 1 in long_entry or short_entry represents entering the trade at that time with a long/short position corresponding. While a 1 in long_exit or short_exit means exiting a trade. May I know how can I calculate the PnL…
atjw94
  • 529
  • 1
  • 6
  • 22
1
2 3
16 17