PDF下载 下载

连续合约数据

阅读 1282

掘金量化支持获取期货主力连续合约及连续合约全部历史数据,以方便研究和回测策略。

主力合约的切换规则为:

  • 每个品种只选出唯一一个主力合约。
  • 日成交量和持仓量都为最大的合约,确定为新的主力合约,每日收盘结算后判断,于下一交易日进行指向切换,日内不会进行主力合约的切换。
  • 按照第二条规定产生新的主力合约之前,维持原来的主力合约不变。
  • 若出现当前主力合约的成交量和持仓量都不是最大的情况,当前指向合约在下一个交易日必须让出主力合约身份,金融期货新主力指向成交量最大的合约(中金所),商品期货新主力指向持仓量最大的合约(上期所、大商所、郑商所、上期能源)。

连续合约的规则为:

  • 该品种上市合约按交割月份排序,00对应最近月份合约,01对应其后一个合约,02对应再后一个合约,依次类推,合约最后交易日盘后切换。如SHFE.RB00,SHFE.RB01。

 

Python 数据接口

1.get_continuous_contracts - 获取主力合约,可获取主力合约和次主力合约

示例

获取2021-07-01 — 2021-07-15的主力合约:

  1. get_continuous_contracts(csymbol='SHFE.AG', start_date='2021-07-01', end_date='2021-07-15')

返回结果:

  1. [{'symbol': 'SHFE.ag2112', 'trade_date': datetime.datetime(2021, 7, 1, 0, 0, tzinfo=tzfile('PRC'))}, {'symbol': 'SHFE.ag2112', 'trade_date': datetime.datetime(2021, 7, 2, 0, 0, tzinfo=tzfile('PRC'))}, {'symbol': 'SHFE.ag2112', 'trade_date': datetime.datetime(2021, 7, 3, 0, 0, tzinfo=tzfile('PRC'))}, {'symbol': 'SHFE.ag2112', 'trade_date': datetime.datetime(2021, 7, 4, 0, 0, tzinfo=tzfile('PRC'))}, {'symbol': 'SHFE.ag2112', 'trade_date': datetime.datetime(2021, 7, 5, 0, 0, tzinfo=tzfile('PRC'))}, {'symbol': 'SHFE.ag2112', 'trade_date': datetime.datetime(2021, 7, 6, 0, 0, tzinfo=tzfile('PRC'))}, {'symbol': 'SHFE.ag2112', 'trade_date': datetime.datetime(2021, 7, 7, 0, 0, tzinfo=tzfile('PRC'))}, {'symbol': 'SHFE.ag2112', 'trade_date': datetime.datetime(2021, 7, 8, 0, 0, tzinfo=tzfile('PRC'))}, {'symbol': 'SHFE.ag2112', 'trade_date': datetime.datetime(2021, 7, 9, 0, 0, tzinfo=tzfile('PRC'))}, {'symbol': 'SHFE.ag2112', 'trade_date': datetime.datetime(2021, 7, 10, 0, 0, tzinfo=tzfile('PRC'))}, {'symbol': 'SHFE.ag2112', 'trade_date': datetime.datetime(2021, 7, 11, 0, 0, tzinfo=tzfile('PRC'))}, {'symbol': 'SHFE.ag2112', 'trade_date': datetime.datetime(2021, 7, 12, 0, 0, tzinfo=tzfile('PRC'))}, {'symbol': 'SHFE.ag2112', 'trade_date': datetime.datetime(2021, 7, 13, 0, 0, tzinfo=tzfile('PRC'))}, {'symbol': 'SHFE.ag2112', 'trade_date': datetime.datetime(2021, 7, 14, 0, 0, tzinfo=tzfile('PRC'))}, {'symbol': 'SHFE.ag2112', 'trade_date': datetime.datetime(2021, 7, 15, 0, 0, tzinfo=tzfile('PRC'))}]

主力连续合约完整的合约代码列表如下:

  1. CFFEX.IC 中证500期货主力连续合约
  2. CFFEX.IF 沪深300期货主力连续合约
  3. CFFEX.IH 上证50期货主力连续合约
  4. CFFEX.IM 中证1000期货主力连续合约
  5. CFFEX.T 10年期国债期货主力连续合约
  6. CFFEX.TF 5年期国债期货主力连续合约
  7. CFFEX.TS 2年期国债期货主力连续合约
  8. CZCE.AP 苹果主力连续合约
  9. CZCE.CF 棉花主力连续合约
  10. CZCE.CJ 红枣主力连续合约
  11. CZCE.CY 棉纱主力连续合约
  12. CZCE.FG 玻璃主力连续合约
  13. CZCE.JR 粳稻主力连续合约
  14. CZCE.LR 晚籼稻主力连续合约
  15. CZCE.MA 甲醇主力连续合约
  16. CZCE.OI 菜油主力连续合约
  17. CZCE.PF 短纤主力连续合约
  18. CZCE.PM 普麦主力连续合约
  19. CZCE.RI 早籼稻主力连续合约
  20. CZCE.RM 菜粕主力连续合约
  21. CZCE.RS 菜籽主力连续合约
  22. CZCE.SA 纯碱主力连续合约
  23. CZCE.SF 硅铁主力连续合约
  24. CZCE.SM 锰硅主力连续合约
  25. CZCE.SR 白糖主力连续合约
  26. CZCE.TA PTA主力连续合约
  27. CZCE.UR 尿素主力连续合约
  28. CZCE.WH 强麦主力连续合约
  29. CZCE.ZC 动力煤主力连续合约
  30. DCE.A 豆一主力连续合约
  31. DCE.B 豆二主力连续合约
  32. DCE.BB 胶合板主力连续合约
  33. DCE.C 玉米主力连续合约
  34. DCE.CS 玉米淀粉主力连续合约
  35. DCE.EB 苯乙烯主力连续合约
  36. DCE.EG 乙二醇主力连续合约
  37. DCE.FB 纤维板主力连续合约
  38. DCE.I 铁矿石主力连续合约
  39. DCE.J 焦炭主力连续合约
  40. DCE.JD 鸡蛋主力连续合约
  41. DCE.JM 焦煤主力连续合约
  42. DCE.L 塑料主力连续合约
  43. DCE.M 豆粕主力连续合约
  44. DCE.P 棕榈油主力连续合约
  45. DCE.PP 聚丙烯主力连续合约
  46. DCE.RR 粳米主力连续合约
  47. DCE.V PVC主力连续合约
  48. DCE.Y 豆油主力连续合约
  49. INE.LU 低硫燃料油连续合约
  50. INE.NR 20号胶主力连续合约
  51. INE.SC 原油主力连续合约
  52. SHFE.AG 白银主力连续合约
  53. SHFE.AL 铝主力连续合约
  54. SHFE.AU 黄金主力连续合约
  55. SHFE.BU 沥青主力连续合约
  56. SHFE.CU 铜主力连续合约
  57. SHFE.FU 燃油主力连续合约
  58. SHFE.HC 热轧卷板主力连续合约
  59. SHFE.NI 镍主力连续合约
  60. SHFE.PB 铅主力连续合约
  61. SHFE.RB 螺纹钢主力连续合约
  62. SHFE.RU 橡胶主力连续合约
  63. SHFE.SN 锡主力连续合约
  64. SHFE.SP 纸浆主力连续合约
  65. SHFE.SS 不锈钢主力连续合约
  66. SHFE.WR 线材主力连续合约
  67. SHFE.ZN 锌主力连续合约
其他语言数据接口

C#

C++

MATLAB

0 篇笔记