Gamestudio Links
Zorro Links
Newest Posts
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 01/07/26 15:14
Zorro locks DLL
by jcl. 01/07/26 13:33
zorro with ccxt?
by qin. 01/07/26 07:50
The new evaluation system
by jcl. 01/05/26 08:50
bar time, right side open or close?
by Spirit. 01/03/26 08:10
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (Grant, AndrewAMD, 1 invisible), 3,762 guests, and 12 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Syndrela, HDRSEO, AOUNZA, digitalboy381, 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
Yesterday at 09:24
Yesterday at 09:24
Joined: Jan 2023
Posts: 29
Q
qin Offline OP
Newbie
qin  Offline OP
Newbie
Q

Joined: Jan 2023
Posts: 29
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
Yesterday at 10:31
Yesterday at 10:31
Joined: Jul 2000
Posts: 28,050
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,050
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
Yesterday at 14:35
Yesterday at 14:35
Joined: Jan 2023
Posts: 29
Q
qin Offline OP
Newbie
qin  Offline OP
Newbie
Q

Joined: Jan 2023
Posts: 29
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
Yesterday at 16:43
Yesterday at 16:43
Joined: Jul 2000
Posts: 28,050
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,050
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