如何保存实时行情
The code below shows how to capture market (bar) data while running a strategy in live or paper trading mode.
下面的代码展示了当运行一个策略在实盘或者仿真模式下时,如何获取实时行情或Bar数据
- using OpenQuant.API;
- public class MyStrategy : Strategy
- {
- public override void OnBar(Bar bar)
- {
- DataManager.Add(Instrument, bar);
- }
- }
Note that you can capture quote and trade data as well by changing or adding corresponding methods
同样的,你也可以通过修改或者添加相应代码来获取合约的quote和trade数据
- using OpenQuant.API;
- public class MyStrategy : Strategy
- {
- public override void OnQuote(Quote quote)
- {
- DataManager.Add(Instrument, quote);
- }
- }