Gamestudio Links
Zorro Links
Newest Posts
Black Book, 4th edition
by jcl. 03/17/26 09:28
Trying to get started...
by Lukudo. 03/16/26 09:08
ZorroGPT
by TipmyPip. 03/08/26 18:50
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (1 invisible), 5,814 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
mredit, vestriaa, Lukudo, mldenoiser, the1
19204 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to control option fill price in backtest (mid-price vs bid/a #489321
Yesterday at 11:52
Yesterday at 11:52
Joined: Jul 2022
Posts: 5
Velika Gorica
M
MislavSag Online OP
Newbie
MislavSag  Online OP
Newbie
M

Joined: Jul 2022
Posts: 5
Velika Gorica
Hi,

I'm backtesting an options strategy that trades straddles on ~300 stocks with weekly rebalancing. I'm using .t8 files with historical bid/ask data from ORATS.
I understand that for options, Zorro fills long entries at fAsk and short entries at fBid from the contract chain, and that Spread and Slippage are ignored
for options.

My question: how can I control the fill price for options in a backtest?

Specifically, I want to simulate fills at the mid-price (average of bid and ask), or at a configurable percentage between mid and the natural side (e.g., 5%
from mid toward ask for a buy). This is important because in practice, limit orders on liquid options regularly fill at or near the mid.

I've tried:
- Setting Spread = 0 ? ignored for options
- Setting Slippage = 0 ? ignored for options
- Modifying c->fAsk and c->fBid on the CONTRACT before enterLong()/enterShort() ? works for entry, but I cannot control the exit fill when using exitTrade()
or LifeTime, because Zorro reads fresh prices from the .t8 chain at exit time

The only approach that fully works is writing mid-prices into the .t8 files (fAsk = fBid = mid), but then I lose the real bid/ask data and have to regenerate
all .t8 files to test a different fill assumption.

Is there a way to intercept or override the fill price for options on both entry and exit? For example:
- A fill mode that applies to options?
- A way to hook into the exit pricing?
- A broker plugin trick for backtesting?

Any help appreciated. Thanks!

Re: How to control option fill price in backtest (mid-price vs bid/a [Re: MislavSag] #489322
2 hours ago
2 hours ago
Joined: Jul 2000
Posts: 28,088
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,088
Frankfurt
The fill price is taken from the bid or ask price of the current contract. For replacing it with your own fill price, simply set ThisContract->fAsk or ThisContract->fBid to their mid price before opening the position. However be aware that this will likely produce a too optimistic backtest.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1