如何有计划地添加合约

The code below demonstrates how to write a simple script that adds new instruments to the instrument data base and application instrument list.

以下代码演示了如何通过编译一个简单脚本来把合约添加到合约数据库和应用合约列表。

This example can be found in the Script Explorer among other script samples.

这个例子能在脚本管理器的其他脚本示例中找到。

  1. using System;
  2.  
  3. using OpenQuant.API;
  4. using OpenQuant.API.Indicators;
  5.  
  6. public class MyScript : Script
  7. {
  8. public override void Run()
  9. {
  10. string[] symbols = new string[] {"Stock1", "Stock2", "Stock3"};
  11.  
  12. foreach (string symbol in symbols)
  13. new Instrument(InstrumentType.Stock, symbol);
  14. }
  15. }