掘金社区

获取主力连续合约对应的交易合约Pinned highlighted

zhuyeaini 发表在策略研究 2020-08-24 16:18:53

策略研究
83
0
0

namespace MultiCodeDataEventDriven
{
public class MyStrategy : Strategy
{
string mSymbol = "";
public MyStrategy(string token, string strategyId, StrategyMode mode) : base(token, strategyId, mode)

        {
            mSymbol = "DCE.JD";
        }

        public override void OnInit()
        {
            Console.WriteLine("OnInit");

            Subscribe(mSymbol, "1d");

        }

        //重写OnBar事件
        public override void OnBar(Bar bar)
        {

            Console.WriteLine("onBar");



            GMData<DataTable> ds = GMApi.GetContinuousContracts(mSymbol, Now(), Now());

            if(ds.status == 0)

            {

                foreach(DataRow v in ds.data.Rows)

                {

                    Console.WriteLine(v["symbol"]);

                }

            }

        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            MyStrategy s = new MyStrategy("f764da39efa877d8f9b3a0e7e33ab039c04cc926","e4267faa-e054-11ea-91d5-3c2c30d506fb", StrategyMode.MODE_BACKTEST);
            s.SetBacktestConfig("2020-05-20 8:20:00", "2020-07-20 17:30:00");
            s.Run();
            System.Console.WriteLine("回测完成!");
        }
    }
}

如上的代码,很简单的获取主力连续合约对应的交易合约,
返回都是DCE.jd2009
但实际上:
0_1598256890126_73c2e2c4-6e13-4366-921a-b874eced6fe6-image.png
应该要有鸡蛋2006,2007

请问是代码上有上面不对的地方吗?

暂无评论
相关阅读
  • 策略研究主力合约策略优化
  • 问题反馈主力合约换月
  • Looks like your connection to 掘金量化社区 - 量化交易者的策略交流学习社区 was lost, please wait while we try to reconnect.