Добрый день
Имею исторические данные (сделки - trades.bin). Для тестирования стратегии нужен стакан, поэтому для его генерации использую connector.RegisterMarketDepth(new TrendMarketDepthGenerator(connector.GetSecurityId(security)).
У HistoryEmulationConnector QuoteChangeMessage (так же правило this.Security.WhenMarketDepthChanged в стратегии) приходит раз минуту.
Пробовал менять:
1)
connector = new HistoryEmulationConnector(secProvider, new[] { portfolio })
{
...
HistoryMessageAdapter =
{
...
MarketTimeChangedInterval = TimeSpan.FromSeconds(1)
},
MarketTimeChangedInterval = TimeSpan.FromSeconds(1),
}
2)
connector.RegisterMarketDepth(new TrendMarketDepthGenerator(connector.GetSecurityId(security))
{
Interval = TimeSpan.FromSeconds(1),
GenerateDepthOnEachTrade = true
}
Изменение стакана всё равно происходит раз в минуту.
Как настроить HistoryEmulationConnector, чтобы изменить частоту появления QuoteChangeMessage сообщений (connector.NewMessage и this.Security.WhenMarketDepthChanged в стратегии) и изменять стакан с приходом сделки (GenerateDepthOnEachTrade = true)?
Код создан на основе проекта SampleHistoryTesting.
HistoryTest.zip static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Black;
var exchangeInfoProvider = new InMemoryExchangeInfoProvider();
var idStr = "SBER@TQBR";
var id = idStr.ToSecurityId();
var secCode = id.SecurityCode;
var board = exchangeInfoProvider.GetOrCreateBoard(id.BoardCode);
var security = new Security
{
Id = "SBER@TQBR",
Code = secCode,
Board = board,
};
var storageRegistry = new StorageRegistry
{
DefaultDrive = new LocalMarketDataDrive(@"H:\rep\History\MarketData")
};
var startTime = (new DateTime(2020, 2, 1)).UtcKind();
var stopTime = (new DateTime(2020, 2, 5)).UtcKind();
var portfolio = Portfolio.CreateSimulator();
var secProvider = (ISecurityProvider)new CollectionSecurityProvider(new[] { security });
var connector = new HistoryEmulationConnector(secProvider, new[] { portfolio })
{
EmulationAdapter =
{
Settings =
{
MatchOnTouch = false,
},
},
HistoryMessageAdapter =
{
StorageRegistry = storageRegistry,
MarketTimeChangedInterval = TimeSpan.FromSeconds(1)
},
MarketTimeChangedInterval = TimeSpan.FromSeconds(1),
};
var series = new CandleSeries(typeof(TimeFrameCandle), security, TimeSpan.FromHours(1))
{
BuildCandlesMode = MarketDataBuildModes.Build,
BuildCandlesFrom2 = null,
};
var strategy = new SmaStrategy(series)
{
Volume = 1,
Portfolio = portfolio,
Security = security,
Connector = connector,
LogLevel = LogLevels.Info,
};
connector.HistoryMessageAdapter.StartDate = startTime;
connector.HistoryMessageAdapter.StopDate = stopTime;
connector.SecurityReceived += (subscr, s) =>
{
connector.SubscribeMarketDepth(security);
connector.RegisterMarketDepth(new TrendMarketDepthGenerator(connector.GetSecurityId(security))
{
Interval = TimeSpan.FromSeconds(1),
MaxAsksDepth = 10,
MaxBidsDepth = 10,
UseTradeVolume = true,
MaxVolume = 1000,
MinSpreadStepCount = 2,
MaxSpreadStepCount = 5,
MaxPriceStepCount = 3,
GenerateDepthOnEachTrade = true
});
strategy.Start();
connector.Start();
};
connector.NewMessage += message =>
{
if (message is QuoteChangeMessage quoteMsg)
{
Console.BackgroundColor = ConsoleColor.Cyan;
Console.WriteLine(quoteMsg);
}
};
connector.Connect();
Console.ReadLine();
}