SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Tue Sep 29, 2020 12:29 am

All times are UTC + 3 hours

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Apr 12, 2019 5:52 am 

Joined: Thu Dec 06, 2018 1:57 am
Posts: 28
I'm making an implementation of CurrencyConverter which uses the latest saved historical bid/ask. I'm getting the latest historical bid/ask like so:

using System;
using SmartQuant;
using System.Diagnostics;
namespace OpenQuant
class Program
static void Main(string[] args)
Framework framework = Framework.Current;
Stopwatch stopwatch = new Stopwatch();

Instrument instrument = framework.InstrumentManager.Get("EURUSD");
TickSeries bidSeries = framework.DataManager.GetHistoricalBids(instrument);
Bid bid = (Bid)bidSeries[bidSeries.Count-1];
Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed);
Bid 04/03/2019 15:37:00.000 4 193 1.12342 0
Time elapsed: 00:00:01.8565314

The problem I have is that the whole TickSeries is being collected and this takes ~ 2 seconds, but I'm only using the last tick in this series. Is there a way to access the last tick without getting the full TickSeries so that this operation is faster?

I know of DataManager.GetBid/Ask but these seem to only work if the instrument has been subscribed, but I don't want to subscribe due to realtime streaming limitations, I'm just after historical which I will periodically update.


PostPosted: Fri Apr 12, 2019 10:32 am 

Joined: Wed May 05, 2010 9:49 pm
Posts: 578
DataSeries series = framework.DataManager.GetDataSeries(instrument, DataObjectType.Trade);
if (series != null && series.Count > 0)
    Trade trade = (Trade)series[series.Count - 1];

will be much faster in your case

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: No registered users and 3 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:  
Powered by phpBB® Forum Software © phpBB Group