如何区分是否实盘

You can use Strategy.Mode property to understand if your strategy code is running in live, paper trading or simulation mode. This way you can turn off certain functionality (for example heavy debugging) if you are running in the simulation mode.

你能用Strategy.Mode属性去了解你的策略代码是在实盘,仿真,还是模拟下运行。这样,你能在你运行模拟模式时关闭某一特定功能(如大量调试)。

  1. public override void OnBar(Bar bar)
  2. {
  3. if (Mode != StrategyMode.Simulation)
  4. Console.WriteLine("Close = " + bar.Close);
  5. }