Gamestudio Links
Zorro Links
Newest Posts
FXCM demo test failed
by qin. 01/13/26 13:53
Camera always moves upwards?
by NeoDumont. 01/12/26 09:39
Alpaca Plugin v1.5.2 Release
by kzhao. 01/11/26 13:42
Alpaca Plugin v1.4.0
by kzhao. 01/11/26 13:38
separating groups of 3 digits by a comma
by joe_kane. 01/11/26 00:01
MRC.c and WFO
by joe_kane. 01/10/26 23:58
BarOffset (default = 940 for daily bars?
by joe_kane. 01/10/26 23:46
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 5,207 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
promfast, joe_kane, Namitha_NN, Syndrela, agasior
19190 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
limit order filled at the next day's opening price is 0.01 less #489071
01/06/26 09:24
01/06/26 09:24
Joined: Jan 2023
Posts: 33
Q
qin Offline OP
Newbie
qin  Offline OP
Newbie
Q

Joined: Jan 2023
Posts: 33
I tested limit orders using the following code. I set Fill=3, meaning the order is filled at the opening price of the next day. I used historical AAPL EOD data. I placed the order on 2025-1-16 with a limit price of Entry = -232.00. I expected the order to be filled at the opening price of 231.86 the next day (17th, as shown in the attached image), but it was actually filled at 231.85 on the 17th, which is 0.01 less than expected. I'm not sure why this is happening. I tested several other dates, and the result was consistently 0.01 less. Any idea?
Code
function run() 
{
	set(LOGFILE);
	StartDate = 20250101;
	EndDate = 20250212;
	LookBack = 5;
	Slippage=0;
	Fill = 3;
	Spread = 0;
	BarPeriod = 1440;
	assetList("AssetsSP30");
	asset("AAPL");
	vars Prices = series(priceC());
	Entry = - 232.00 ;	

	if(year()==2025 && month()==1 && day()==16){
		watch("date",year(), month(),day());
		enterLong();
	}		
}

Attached Files aapl.png
Re: limit order filled at the next day's opening price is 0.01 less [Re: qin] #489072
01/06/26 10:31
01/06/26 10:31
Joined: Jul 2000
Posts: 28,051
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,051
Frankfurt
Good question. The reason of the difference is simulating the most likely price move between triggering the trade and and filling the order. Since you have an entry limit, the price is supposed to move against the trade direction. This difference is rounded to the next point, which is 0.01 in case of stocks.

It is arguable whether this makes much sense, since the Slippage simulation should anyway cover it. It has historical reasons, we wanted to replicate the backtests of TradeStation. They are in this way adding or subtracting one point from the fill price. We will probably in a future version add a flag to enable or disable that effect.

Re: limit order filled at the next day's opening price is 0.01 less [Re: qin] #489073
01/06/26 14:35
01/06/26 14:35
Joined: Jan 2023
Posts: 33
Q
qin Offline OP
Newbie
qin  Offline OP
Newbie
Q

Joined: Jan 2023
Posts: 33
This revision is highly necessary, as otherwise the outcome would be too optimistic.

Re: limit order filled at the next day's opening price is 0.01 less [Re: qin] #489074
01/06/26 16:43
01/06/26 16:43
Joined: Jul 2000
Posts: 28,051
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,051
Frankfurt
In this case yes, in other cases it's pessimistic. But we'll add a flag for that.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1