SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Mon Sep 23, 2019 2:08 pm

All times are UTC + 3 hours




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

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");
stopwatch.Start();
TickSeries bidSeries = framework.DataManager.GetHistoricalBids(instrument);
stopwatch.Stop();
Bid bid = (Bid)bidSeries[bidSeries.Count-1];
Console.WriteLine(bid);
Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed);
}
}
}
Output:
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.

thanks


Top
 Profile  
 
PostPosted: Fri Apr 12, 2019 10:32 am 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 497
Hello,
Code:
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


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: Bing [Bot] 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:  
cron
Powered by phpBB® Forum Software © phpBB Group