Commit 2b4daf59 authored by hetao's avatar hetao

Update 设置回测过程中的BidAskTrade事件顺序.md

parent 29d9d2de
## 把行情和成交分开订阅,人为的设定行情订阅顺序
## 设定回撤行情触发顺序
```c#
internal static class DataSimulatorHelper
public class DataSimulator2 : DataSimulator
{
public DataSimulator2(Framework framework) : base(framework)
{
}
protected override void OnConnected()
{
if (framework.IsExternalDataQueue)
{
return;
}
base.OnConnected();
}
public void SubscribeTradeLast(Instrument instrument)
{
SubscribeAsk = false;
SubscribeBid = false;
SubscribeTrade = false;
var dataManager = framework.DataManager;
var bid = dataManager.GetDataSeries(instrument, DataObjectType.Bid);
Series.Add(bid);
var ask = dataManager.GetDataSeries(instrument, DataObjectType.Ask);
Series.Add(ask);
var trade = dataManager.GetDataSeries(instrument, DataObjectType.Trade);
Series.Add(trade);
}
}
public static class DataSimulatorHelper
{
public static void SubscribeTradeLast(this IDataSimulator simulator, Instrument instrument)
{
simulator.SubscribeAsk = true;
simulator.SubscribeBid = true;
simulator.SubscribeTrade = false;
simulator.Subscribe(instrument);
simulator.SubscribeAsk = false;
simulator.SubscribeBid = false;
simulator.SubscribeTrade = true;
simulator.Subscribe(instrument);
simulator.SubscribeAsk = false;
simulator.SubscribeBid = false;
simulator.SubscribeTrade = false;
var framework = ((DataSimulator)simulator).GetFramework();
if (!(framework.DataSimulator is DataSimulator2))
{
framework.DataSimulator = new DataSimulator2(framework)
{
DateTime1 = simulator.DateTime1,
DateTime2 = simulator.DateTime2
};
foreach (var item in simulator.BarFilter.Items)
{
framework.DataSimulator.BarFilter.Items.Add(item);
}
}
((DataSimulator2)framework.DataSimulator).SubscribeTradeLast(instrument);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment