Ребята, подскажите пожалуйста, где ошибка на форме создаю проект, хочу получить свечи с финама взял проект из семплов в тестинге, делал все как по инструкции, но в тестинге свечи получаю, а в этом коде нет Привел полный код.
string SecId; int TimeFrame; string folder; DateTime start; DateTime stop; public Form1() { InitializeComponent(); folder = @".\HistoryData"; SecId = "RIZ2@FORTS";
start = new DateTime(2015, 10, 1); stop = new DateTime(2015, 10, 15); var startTime = ((DateTime)start).ChangeKind(DateTimeKind.Utc); var stopTime = ((DateTime)stop).ChangeKind(DateTimeKind.Utc); TimeFrame = 1; var timeFrame = TimeSpan.FromMinutes(1); var secGen = new SecurityIdGenerator(); var id = secGen.Split(SecId); var secCode = id.SecurityCode; var board = ExchangeBoard.GetOrCreateBoard(id.BoardCode); var security = new Security { Id = SecId, // sec id has the same name as folder with historical data Code = secCode, Board = board, }; // create backtesting connector // test portfolio var portfolio = new Portfolio { Name = "test account", BeginValue = 1000000, }; var secId = security.ToSecurityId(); _finamHistorySource.Refresh(new FinamSecurityStorage(security), security, s => { }, () => false); // storage to historical data var storageRegistry = new StorageRegistry { // set historical path DefaultDrive = new LocalMarketDataDrive(folder) }; var emulationInfo = new EmulationInfo { UseCandleTimeFrame = timeFrame, HistorySource = d => _finamHistorySource.GetCandles(security, timeFrame, d.Date, d.Date) }; // create backtesting connector var connector = new HistoryEmulationConnector( new[] { security }, new[] { portfolio }) { EmulationAdapter = { Emulator = { Settings = { // match order if historical price touched our limit order price. // It is terned off, and price should go through limit order price level // (more "severe" test mode) MatchOnTouch = false, } } }, UseExternalCandleSource = true, CreateDepthFromOrdersLog = emulationInfo.UseOrderLog, CreateTradesFromOrdersLog = emulationInfo.UseOrderLog, HistoryMessageAdapter = { StorageRegistry = storageRegistry, // set history range StartDate = startTime, StopDate = stopTime, OrderLogMarketDepthBuilders = { { secId, (IOrderLogMarketDepthBuilder)new PlazaOrderLogMarketDepthBuilder(secId) } } }, // set market time freq as time frame MarketTimeChangedInterval = timeFrame, }; var candleManager = new CandleManager(connector); candleManager.Processing += (_s, _c) => { }; var series = new CandleSeries(typeof(TimeFrameCandle), security, timeFrame); connector.NewSecurities += securities => { if (securities.All(s => s != security)) return; // start strategy before emulation started candleManager.Start(series); // start historical data loading when connection established successfully and all data subscribed connector.Start(); }; // start emulation // raise NewSecurities and NewPortfolio for full fill strategy properties connector.Connect(); }
Comments (0)
Login or Create account, Log in or register to leave a comment
No comments yet. Be the first!