SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Thu Aug 22, 2019 5:02 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Mar 13, 2019 1:44 pm 
Offline

Joined: Thu Dec 06, 2018 1:57 am
Posts: 28
I have Quote data which is sampled each minute. When I make bars from these quotes I find that OnBarOpen always occurs before OnBid/OnAsk or Instrument.Bid/Instrument.Ask have been updated. See the strategy and it's outputs:

public class MyStrategy : InstrumentStrategy
{
public MyStrategy(Framework framework, string name)
: base(framework, name)
{
}

protected override void OnStrategyStart()
{
Console.WriteLine($"StartStrategy({Mode})");
}

protected override void OnBid(Instrument instrument, Bid bid)
{
Console.WriteLine();
Console.WriteLine($"OnBid: @ {Clock.DateTime}");
Console.WriteLine($"{bid}");
Console.WriteLine($"Instrument.Bid: {Instrument.Bid}");
}
protected override void OnAsk(Instrument instrument, Ask ask)
{
Console.WriteLine();
Console.WriteLine($"OnAsk: @ {Clock.DateTime}");
Console.WriteLine($"{ask}");
Console.WriteLine($"Instrument.Ask {Instrument.Ask}");
}

protected override void OnBarOpen(Instrument instrument, Bar bar)
{
Console.WriteLine();
Console.WriteLine("============================================");
Console.WriteLine($"OnBarOpen @ {Clock.DateTime}");
Console.WriteLine($"bar: {bar}");
Console.WriteLine($"Instrument.Bid: {Instrument.Bid}");
Console.WriteLine($"Instrument.Ask {Instrument.Ask}");

}
}

Output:
============================================
OnBarOpen @ 01/02/2018 00:16:00.000
bar: Bar [01/02/2018 00:16:00.000 - 01/02/2018 00:16:00.000] Instrument=10 Type=Time Size=1 Open=1.201375 High=1.201375 Low=1.201375 Close=1.201375 Volume=0
Instrument.Bid: Bid 01/02/2018 00:15:00.000 4 10 1.2013 0
Instrument.Ask Ask 01/02/2018 00:15:00.000 4 10 1.20135 0

OnBid: @ 01/02/2018 00:16:00.000
Bid 01/02/2018 00:16:00.000 4 10 1.2014 0
Instrument.Bid: Bid 01/02/2018 00:16:00.000 4 10 1.2014 0

OnAsk: @ 01/02/2018 00:16:00.000
Ask 01/02/2018 00:16:00.000 4 10 1.2015 0
Instrument.Ask Ask 01/02/2018 00:16:00.000 4 10 1.2015 0

============================================
OnBarOpen @ 01/02/2018 00:17:00.000
bar: Bar [01/02/2018 00:17:00.000 - 01/02/2018 00:17:00.000] Instrument=10 Type=Time Size=1 Open=1.201475 High=1.201475 Low=1.201475 Close=1.201475 Volume=0
Instrument.Bid: Bid 01/02/2018 00:16:00.000 4 10 1.2014 0
Instrument.Ask Ask 01/02/2018 00:16:00.000 4 10 1.2015 0

OnBid: @ 01/02/2018 00:17:00.000
Bid 01/02/2018 00:17:00.000 4 10 1.20145 0
Instrument.Bid: Bid 01/02/2018 00:17:00.000 4 10 1.20145 0

============================================
OnBarOpen @ 01/02/2018 00:18:00.000
bar: Bar [01/02/2018 00:18:00.000 - 01/02/2018 00:18:00.000] Instrument=10 Type=Time Size=1 Open=1.201575 High=1.201575 Low=1.201575 Close=1.201575 Volume=0
Instrument.Bid: Bid 01/02/2018 00:17:00.000 4 10 1.20145 0
Instrument.Ask Ask 01/02/2018 00:16:00.000 4 10 1.2015 0

OnBid: @ 01/02/2018 00:18:00.000
Bid 01/02/2018 00:18:00.000 4 10 1.20165 0
Instrument.Bid: Bid 01/02/2018 00:18:00.000 4 10 1.20165 0

OnAsk: @ 01/02/2018 00:18:00.000
Ask 01/02/2018 00:18:00.000 4 10 1.2017 0
Instrument.Ask Ask 01/02/2018 00:18:00.000 4 10 1.2017 0

============================================
OnBarOpen @ 01/02/2018 00:19:00.000
bar: Bar [01/02/2018 00:19:00.000 - 01/02/2018 00:19:00.000] Instrument=10 Type=Time Size=1 Open=1.201575 High=1.201575 Low=1.201575 Close=1.201575 Volume=0
Instrument.Bid: Bid 01/02/2018 00:18:00.000 4 10 1.20165 0
Instrument.Ask Ask 01/02/2018 00:18:00.000 4 10 1.2017 0

OnBid: @ 01/02/2018 00:19:00.000
Bid 01/02/2018 00:19:00.000 4 10 1.20145 0
Instrument.Bid: Bid 01/02/2018 00:19:00.000 4 10 1.20145 0

OnAsk: @ 01/02/2018 00:19:00.000
Ask 01/02/2018 00:19:00.000 4 10 1.2015 0
Instrument.Ask Ask 01/02/2018 00:19:00.000 4 10 1.2015 0

============================================
OnBarOpen @ 01/02/2018 00:20:00.000
bar: Bar [01/02/2018 00:20:00.000 - 01/02/2018 00:20:00.000] Instrument=10 Type=Time Size=1 Open=1.201525 High=1.201525 Low=1.201525 Close=1.201525 Volume=0
Instrument.Bid: Bid 01/02/2018 00:19:00.000 4 10 1.20145 0
Instrument.Ask Ask 01/02/2018 00:19:00.000 4 10 1.2015 0

OnBid: @ 01/02/2018 00:20:00.000
Bid 01/02/2018 00:20:00.000 4 10 1.20155 0
Instrument.Bid: Bid 01/02/2018 00:20:00.000 4 10 1.20155 0

OnAsk: @ 01/02/2018 00:20:00.000
Ask 01/02/2018 00:20:00.000 4 10 1.2016 0
Instrument.Ask Ask 01/02/2018 00:20:00.000 4 10 1.2016 0

============================================
OnBarOpen @ 01/02/2018 00:21:00.000
bar: Bar [01/02/2018 00:21:00.000 - 01/02/2018 00:21:00.000] Instrument=10 Type=Time Size=1 Open=1.201625 High=1.201625 Low=1.201625 Close=1.201625 Volume=0
Instrument.Bid: Bid 01/02/2018 00:20:00.000 4 10 1.20155 0
Instrument.Ask Ask 01/02/2018 00:20:00.000 4 10 1.2016 0

OnBid: @ 01/02/2018 00:21:00.000
Bid 01/02/2018 00:21:00.000 4 10 1.20165 0
Instrument.Bid: Bid 01/02/2018 00:21:00.000 4 10 1.20165 0

OnAsk: @ 01/02/2018 00:21:00.000
Ask 01/02/2018 00:21:00.000 4 10 1.2017 0
Instrument.Ask Ask 01/02/2018 00:21:00.000 4 10 1.2017 0



From the output I can see that when a new quote arrives the order of events is:
OnBarOpen
Instrument.Bid, Instrument.Ask Updated
OnBid, OnAsk

Is this intentional behaviour? because it does not make sense to me.... the bar is made from quotes so the quotes should obviously be available in the strategy before the bar. This would make more sense.

Perhaps a setting similar to ReminderOrder.After would be useful?


Top
 Profile  
 
PostPosted: Thu Mar 14, 2019 10:05 am 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 497
abasqd wrote:
I have Quote data which is sampled each minute. When I make bars from these quotes I find that OnBarOpen always occurs before OnBid/OnAsk or Instrument.Bid/Instrument.Ask have been updated.

Hello,
yes, it normal behavior.

Quote:
Perhaps a setting similar to ReminderOrder.After would be useful?

In your case it can be helpful.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: Google [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group