如何保存实时行情

The code below shows how to capture market (bar) data while running a strategy in live or paper trading mode.

下面的代码展示了当运行一个策略在实盘或者仿真模式下时,如何获取实时行情或Bar数据

  1. using OpenQuant.API;
  2.  
  3. public class MyStrategy : Strategy
  4. {
  5. public override void OnBar(Bar bar)
  6. {
  7. DataManager.Add(Instrument, bar);
  8. }
  9. }

Note that you can capture quote and trade data as well by changing or adding corresponding methods

同样的,你也可以通过修改或者添加相应代码来获取合约的quote和trade数据

  1. using OpenQuant.API;
  2.  
  3. public class MyStrategy : Strategy
  4. {
  5. public override void OnQuote(Quote quote)
  6. {
  7. DataManager.Add(Instrument, quote);
  8. }
  9. }