选择合约
This scenario shows how to filter and add the most liquid stocks into strategy project
此场景展示如何过滤并添加流动性大的股票到策略工程
- public class MyScenario : Scenario
- {
- public override void Run()
- {
- // get reference to strategy project
- Project project = Solution.Projects[0];
- // clear project instrument list
- project.ClearInstruments();
- // add most liquid stocks to instrument list
- foreach (Instrument instrument in InstrumentManager.Instruments)
- if (instrument.Type == InstrumentType.Stock)
- {
- BarSeries series = DataManager.GetHistoricalBars(instrument, BarType.Time, 86400);
- if (series.Count != 0 && series.Last.Volume > 50000000)
- {
- Console.WriteLine("Adding " + instrument);
- project.AddInstrument(instrument);
- }
- }
- // start backtest
- Start();
- }
- }