mhallsmoore / qstrader

QuantStart.com - QSTrader backtesting simulation engine.
https://www.quantstart.com/qstrader/
MIT License
2.94k stars 855 forks source link

Handling bid/ask (and so spread) with BarEvent #113

Closed femtotrader closed 9 months ago

femtotrader commented 8 years ago

Hello,

When backtesting with only bar data, price handler put BarEvent into event queue.

Here are some properties of a BarEvent

- ticker
- time
- period
- open_price
- high_price
- low_price
- close_price
- volume
- adj_close_price

Backtesting using bar data can be useful with CFD (or any other derivatives) with bid/ask price (and so spread).

Metatrader 4, for example, display candle of bid price (but an optional ask line can be drawn). http://www.metatrader4.com/fr/trading-platform/help/setup/setup_charts Historical data only have bid price and backtest assume fixed spread ( http://www.forexfactory.com/showthread.php?p=5082986 )

I wonder how we can handle this nicely ?

Kind regards

ryankennedyio commented 8 years ago

Might depend a little bit on what the proposed "out-of-box" (presuming IB) historic data provider gives?

mhallsmoore commented 8 years ago

This is probably indicative of a wider conversation on transaction cost handling. I myself will be utilising specific models for transaction costs in order to test strategy sensitivity to various costs.

Once we have gitter/Slack we can have a good chat about it!

femtotrader commented 8 years ago

A strategy might be aware of spread (especially when it's not equal to 0). For example your strategy can enter only when spread is low (and never enter when spread is high)