SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Mon Oct 07, 2024 5:45 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sun Mar 08, 2020 2:28 pm 
Offline

Joined: Mon Apr 02, 2018 1:39 pm
Posts: 22
Hi,

I've just downloaded data from IQFeed as bars.
This the output from data viewer :

Data Series , Object Count , First Date Time , Last Date Time
Bar Range 60 , 1,835,079 , 01/02/2012 00:00:00 , 03/06/2020 16:03:00

Now I've followed the code in post viewtopic.php?f=64&t=6227
(please see code below)

I get no results from the function DataManager.GetHistoricalBars(Instrument , datetime1, datetime2, BarType.Time, 60)
However, it does print the bars in "OnBar"

Does the DB treat these downloaded bars differently to Saved Bars? If so, is there a way of accessing downloaded bars in this manner?


Thanks

-------------------------------------------------------------------------------------------------------------------
My Strategy :

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

DateTime datetime1;
DateTime datetime2;

protected override void OnStrategyStart()
{
datetime2 = new DateTime(2013, 12, 18); ;
datetime1 = datetime2.AddDays(-2);

Console.WriteLine(datetime1.ToString());
Console.WriteLine(datetime2.ToString());


foreach (Bar bar in DataManager.GetHistoricalBars(Instrument , datetime1, datetime2, BarType.Time, 60))
{
Console.WriteLine(bar);
Bars.Add(bar);
}
Console.WriteLine("cnt = " + Bars.Count.ToString());
}
protected override void OnBid(Instrument instrument, Bid bid) { Console.WriteLine(bid); }
protected override void OnAsk(Instrument instrument, Ask ask) { Console.WriteLine(ask); }
//protected override void OnTrade(Instrument instrument, Trade trade) { Console.WriteLine(trade); }
protected override void OnBar(Instrument instrument, Bar bar)
{
Console.WriteLine(bar);
//DataManager.Save(bar);
}
}

----------------------------------------------------------------------------------------------------------------------------
My Scenario :

public partial class MyScenario : Scenario
{
public MyScenario(Framework framework)
: base(framework)
{
}

public override void Run()
{
string instName = "XG#";
strategy = new MyStrategy(framework, "Backtest");
Initialize();
//strategy.AddInstrument("MSFT");

Instrument instrument = InstrumentManager.Instruments[instName];
strategy.AddInstrument(instName);
DataSimulator.DateTime1 = new DateTime(2013, 12, 15);
DataSimulator.DateTime2 = new DateTime(2013, 12, 20);
DataSimulator.SubscribeBid = false;
DataSimulator.SubscribeAsk = false;
DataSimulator.SubscribeTrade = true;
DataSimulator.SubscribeBar = true;

BarFactory.Add(instName, BarType.Time, 60);

StartStrategy();
}
}


Top
 Profile  
 
PostPosted: Sun Mar 08, 2020 11:51 pm 
Offline

Joined: Mon Apr 02, 2018 1:39 pm
Posts: 22
Forgot to mention downloaded bars from IQ Feed are 1m bars ("Bar Range 60") ..


Top
 Profile  
 
PostPosted: Tue Mar 10, 2020 10:11 am 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 583
Hello,
1)the simplest way to understand what is happening is to request historical market data via menu Data/Import/Historical.
You will get data or a message corresponding to the problem.
2)GetHistoricalBars (or other historical data) do not correlate with OnBar (or other live data).
The bars retrieved using GetHistoricalBars are not saving in DB without you.

Additionally, I recommend to try common instruments such as AAPL, MSFT.


Top
 Profile  
 
PostPosted: Tue Mar 10, 2020 1:29 pm 
Offline

Joined: Mon Apr 02, 2018 1:39 pm
Posts: 22
I think I understand .. what you're saying is that data I download that's being used for backtesting (historic ticks) is not considered to be part of the "database" .. I should physically store this data using "Save" to be able to load it using the API GetHistoricalData. Would that be correct?


Top
 Profile  
 
PostPosted: Wed Mar 18, 2020 11:02 am 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 583
zbxxxx wrote:
I think I understand .. what you're saying is that data I download that's being used for backtesting (historic ticks) is not considered to be part of the "database" .. I should physically store this data using "Save" to be able to load it using the API GetHistoricalData. Would that be correct?

Yes, after downloading the data remains in memory, then you can save it in the database (using DataManager.Save()) or use somehow.


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

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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