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();
}
}