protected bool LoadDataForTickers(StrategyBase s)
        {
            StrategyInputInfo info = s.CreateInputInfo();

            for (int i = 0; i < info.Tickers.Count; i++)
            {
                TickerInputInfo ti = info.Tickers[i];
                Exchange        e  = ((IStrategyDataProvider)this).GetExchange(ti.Exchange);
                if (e == null)
                {
                    return(false);
                }
                ti.Ticker = e.GetTicker(ti.TickerName);
                if (ti.Ticker == null)
                {
                    return(false);
                }
                StrategySimulationData data = null;
                SimulationData.TryGetValue(ti.Ticker, out data);
                if (data == null)
                {
                    data = new StrategySimulationData()
                    {
                        Ticker = ti.Ticker, Exchange = e, Strategy = s, TickerInfo = ti
                    }
                }
                ;
                if (!string.IsNullOrEmpty(ti.TickerSimulationDataFile))
                {
                    data.UseTickerSimulationDataFile = true;
                    if (!ti.Ticker.CaptureDataHistory.Load(ti.TickerSimulationDataFile))
                    {
                        return(false);
                    }
                    data.CaptureDataHistory = ti.Ticker.CaptureDataHistory;
                }
                else
                {
                    if (ti.UseTradeHistory)
                    {
                        if (data.Trades == null)
                        {
                            data.Trades = DownloadTrades(ti);
                        }
                    }
                    if (ti.UseKline)
                    {
                        if (data.CandleStickData == null)
                        {
                            data.CandleStickData = DownloadCandleStickData(ti);
                        }
                        data.CopyCandleSticksFromLoaded();
                        if (data.CandleStickData.Count == 0)
                        {
                            return(false);
                        }
                    }
                    data.OrderBook = DownloadOrderBook(ti);
                    if (data.OrderBook == null)
                    {
                        return(false);
                    }
                }
                if (!SimulationData.ContainsKey(ti.Ticker))
                {
                    SimulationData.Add(ti.Ticker, data);
                }
            }
            return(true);
        }
Exemplo n.º 2
0
 bool IStrategyDataProvider.InitializeDataFor(StrategyBase s)
 {
     return(true);
 }