发明者量化商品期货合约代码明细

Posted K线骑士

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了发明者量化商品期货合约代码明细相关的知识,希望对你有一定的参考价值。


温馨提示:鉴于内容太多, 可使用 Ctrl + F 进行搜索

由于商品期货合约存续的特殊性,为满足用户的使用需求,针对每一个品种提供主力连续合约和指数合约,其主要是根据当前时间段内有效的商品期货合约数据人工合成,具体调用方法可以参考本页示例代码。其中:

  • 主力连续合约:由该期货品种不同时期的主力合约(价格和成交量)直接拼接而成,代码以888结尾,例如rb888。合约首次上市时, 以当日收盘同品种持仓量最大者作为从第二个交易日开始的主力合约。如果同品种其他合约持仓量在收盘后超过当前主力合约1.1倍时, 则在第二个交易日进行主力合约切换。

  • 指数合约:由该期货品种所有正在交易的合约,以持仓量加权平均计算。

1. 期货合约

1.1 期货合约代码规则

交易所具体合约规则主力连续合约指数合约具体合约
中国金融期货交易所品种代码(大写) + 交割年份(2位) + 交割月份(2位)IF888IF000IF2201
上海期货交易所品种代码(小写) + 交割年份(2位) + 交割月份(2位)ag888ag000ag2201
上海国际能源交易中心品种代码(小写) + 交割年份(2位) + 交割月份(2位)bc888bc000bc2201
郑州商品交易所品种代码(大写) + 交割年份(1位) + 交割月份(2位)AP888AP000AP201
大连商品交易所品种代码(小写) + 交割年份(2位) + 交割月份(2位)a888a000a2201

1.2 期货合约代码明细

中国金融期货交易所

名称主力合约代码指数合约代码具体合约代码
沪深300指数IF888IF000IF2201
中证500指数IC888IC000IC2201
上证50指数IH888IH000IH2201
2年期国债期货TS888TS000TS2201
5年期国债期货TF888TF000TF2201
10年期国债期货T888T000T2201

示例代码

function main() 
    // 判断商品期货行情和交易连接是否正常
    while(!exchange.IO("status")) 
        Sleep(1000);
    
    // 设置合约代码
    Log(exchange.SetContractType("IF888"));

返回值


    "InstrumentName": "沪深连续",
    "ExchangeInstID": "IF2112",
    "MaxLimitOrderVolume": 20,
    "PriceTick": 0.2,
    "MaxMarginSideAlgorithm": 49,
    "ProductID": "IF",
    "DeliveryMonth": 12,
    "MaxMarketOrderVolume": 10,
    "EndDelivDate": "20211217",
    "InstLifePhase": 49,
    "PositionType": 50,
    "UnderlyingMultiple": 1,
    "CombinationType": 48,
    "IsTrading": 1,
    "StrikePrice": 1.7976931348623157e+308,
    "ExchangeID": "CFFEX",
    "VolumeMultiple": 300,
    "DeliveryYear": 2021,
    "MinMarketOrderVolume": 1,
    "MinLimitOrderVolume": 1,
    "ExpireDate": "20211217",
    "OptionsType": 0,
    "InstrumentID": "IF2112",
    "CreateDate": "20210416",
    "PositionDateType": 50,
    "LongMarginRatio": 0.12,
    "UnderlyingInstrID": "IF",
    "ProductClass": 49,
    "OpenDate": "20210419",
    "StartDelivDate": "20211217",
    "ShortMarginRatio": 0.12

上海期货交易所

名称主力合约代码指数合约代码具体合约代码
白银ag888ag000ag2201
al888al000al2201
黄金au888au000au2201
石油沥青bu888bu000bu2201
cu888cu000cu2201
燃料油fu888fu000fu2201
热轧卷板hc888hc000hc2201
ni888ni000ni2201
pb888pb000pb2201
螺纹钢rb888rb000rb2201
天然橡胶ru888ru000ru2201
sn888sn000sn2201
纸浆sp888sp000sp2201
不锈钢ss888ss000ss2201
线材wr888wr000wr2201
zn888zn000zn2201

示例代码

function main() 
    // 判断商品期货行情和交易连接是否正常
    while(!exchange.IO("status")) 
        Sleep(1000);
    
    // 设置合约代码
    Log(exchange.SetContractType("ag888"));

返回值


    "InstrumentName": "ag连续",
    "DeliveryMonth": 6,
    "OpenDate": "20210616",
    "StartDelivDate": "20220616",
    "PositionDateType": 49,
    "UnderlyingInstrID": "ag",
    "ProductID": "ag",
    "ProductClass": 49,
    "DeliveryYear": 2022,
    "ExchangeInstID": "ag2206",
    "EndDelivDate": "20220620",
    "MinLimitOrderVolume": 1,
    "PositionType": 50,
    "LongMarginRatio": 0.12,
    "VolumeMultiple": 15,
    "CreateDate": "20210514",
    "UnderlyingMultiple": 1,
    "ExchangeID": "SHFE",
    "MaxMarketOrderVolume": 30,
    "MaxLimitOrderVolume": 500,
    "MinMarketOrderVolume": 1,
    "OptionsType": 48,
    "MaxMarginSideAlgorithm": 49,
    "CombinationType": 48,
    "InstLifePhase": 49,
    "IsTrading": 1,
    "ShortMarginRatio": 0.12,
    "StrikePrice": 0,
    "InstrumentID": "ag2206",
    "PriceTick": 1,
    "ExpireDate": "20220615"


上海国际能源交易中心

名称主力合约代码指数合约代码具体合约代码
阴极铜bc888bc000bc2201
低硫燃料油lu888lu000lu2201
20号胶nr888nr000nr2201
原油sc888sc000sc2201

示例代码

function main() 
    // 判断商品期货行情和交易连接是否正常
    while(!exchange.IO("status")) 
        Sleep(1000);
    
    // 设置合约代码
    Log(exchange.SetContractType("bc888"));

返回值


    "ExchangeID": "INE",
    "InstLifePhase": 49,
    "LongMarginRatio": 0.1,
    "ShortMarginRatio": 0.1,
    "OptionsType": 48,
    "ExchangeInstID": "bc2202",
    "MaxLimitOrderVolume": 500,
    "StartDelivDate": "20220216",
    "EndDelivDate": "20220222",
    "MaxMarginSideAlgorithm": 49,
    "StrikePrice": 0,
    "InstrumentName": "bc连续",
    "DeliveryYear": 2022,
    "PriceTick": 10,
    "UnderlyingInstrID": "bc",
    "MinLimitOrderVolume": 1,
    "ExpireDate": "20220215",
    "UnderlyingMultiple": 1,
    "PositionType": 50,
    "InstrumentID": "bc2202",
    "ProductClass": 49,
    "DeliveryMonth": 2,
    "VolumeMultiple": 5,
    "OpenDate": "20210208",
    "CombinationType": 48,
    "ProductID": "bc",
    "MaxMarketOrderVolume": 30,
    "MinMarketOrderVolume": 1,
    "CreateDate": "20210114",
    "IsTrading": 1,
    "PositionDateType": 49

郑州商品交易所

名称主力合约代码指数合约代码具体合约代码
苹果AP888AP000AP201
棉花CF888CF000CF201
红枣CJ888CJ000CJ201
棉纱CY888CY000CY201
早籼稻ER888ER000ER201
玻璃FG888FG000FG201
绿豆GN888GN000GN201
粳稻谷JR888JR000JR201
晚籼稻LR888LR000LR201
甲醇MA888MA000MA201
甲醇ME888ME000ME201
菜籽油OI888OI000OI201
短纤PF888PF000PF201
花生PK888PK000PK201
普麦PM888PM000PM201
早籼稻RI888RI000RI201
菜籽粕RM888RM000RM201
菜籽油RO888RO000RO201
油菜籽RS888RS000RS201
纯碱SA888SA000SA201
硅铁SF888SF000SF201
锰硅SM888SM000SM201
白糖SR888SR000SR201
PTATA888TA000TA201
动力煤TC888TC000TC201
尿素UR888UR000UR201
强麦WH888WH000WH201
强麦WS888WS000WS201
硬白小麦WT888WT000WT201
动力煤ZC888ZC000ZC201

示例代码

function main() 
    // 判断商品期货行情和交易连接是否正常
    while(!exchange.IO("status")) 
        Sleep(1000);
    
    // 设置合约代码
    Log(exchange.SetContractType("AP888"));

返回值


    "InstrumentName": "苹果连续",
    "ExchangeInstID": "AP201",
    "DeliveryYear": 2022,
    "CreateDate": "20210118",
    "PositionDateType": 50,
    "InstrumentID": "AP201",
    "ExchangeID": "CZCE",
    "MaxLimitOrderVolume": 1000,
    "CombinationType": 48,
    "DeliveryMonth": 1,
    "MinMarketOrderVolume": 1,
    "EndDelivDate": "20220114",
    "PositionType": 50,
    "VolumeMultiple": 10,
    "ExpireDate": "20220114",
    "InstLifePhase": 49,
    "UnderlyingInstrID": "",
    "MaxMarketOrderVolume": 1000,
    "ShortMarginRatio": 0.1,
    "StrikePrice": 0,
    "ProductID": "AP",
    "MinLimitOrderVolume": 1,
    "StartDelivDate": "20220114",
    "IsTrading": 1,
    "LongMarginRatio": 0.1,
    "ProductClass": 49,
    "PriceTick": 1,
    "OpenDate": "20210118",
    "MaxMarginSideAlgorithm": 48,
    "OptionsType": 0,
    "UnderlyingMultiple": 1

大连商品交易所

名称主力合约代码指数合约代码具体合约代码
豆一a888a000a2201
豆二b888b000b2201
胶合板bb888bb000bb2201
玉米c888c000c2201
玉米淀粉cs888cs000cs2201
苯乙烯eb888eb000eb2201
乙二醇eg888eg000eg2201
纤维板fb888fb000fb2201
铁矿石i888i000i2201
焦炭j888j000j2201
鸡蛋jd888jd000jd2201
焦煤jm888jm000jm2201
聚乙烯l888l000l2201
生猪lh888lh000lh2201
豆粕m888m000m2201
棕榈油p888p000p2201
液化石油气pg888pg000pg2201
聚丙烯pp888pp000pp2201
粳米rr888rr000rr2201
聚氯乙烯v888v000v2201
豆油y888y000y2201

示例代码

function main() 
    // 判断商品期货行情和交易连接是否正常
    while(!exchange.IO("status")) 
        Sleep(1000);
    
    // 设置合约代码
    Log(exchange.SetContractType("a888"));

返回值


    "MaxMarginSideAlgorithm": 48,
    "InstrumentName": "豆一连续",
    "ExchangeInstID": "a2203",
    "MinMarketOrderVolume": 1,
    "UnderlyingMultiple": 0,
    "InstrumentID": "a2203",
    "ExchangeID": "DCE",
    "DeliveryYear": 2022,
    "PriceTick": 1,
    "PositionType": 50,
    "StrikePrice": 0,
    "ProductID": "a",
    "ProductClass": 49,
    "CreateDate": "20210315",
    "StartDelivDate": "",
    "IsTrading": 1,
    "LongMarginRatio": 0.12,
    "OptionsType": 0,
    "CombinationType": 48,
    "MinLimitOrderVolume": 1,
    "OpenDate": "20210315",
    "DeliveryMonth": 3,
    "MaxLimitOrderVolume": 1000,
    "VolumeMultiple": 10,
    "ExpireDate": "20220314",
    "EndDelivDate": "20220317",
    "InstLifePhase": 49,
    "ShortMarginRatio": 0.12,
    "UnderlyingInstrID": "",
    "MaxMarketOrderVolume": 1000,
    "PositionDateType": 50

2. 交易所套利合约

2.1 交易所套利代码规则

交易所类型具体合约规则具体合约
郑州商品交易所跨期SPD 代码年份月份&代码年份月份SPD OI201&OI205
郑州商品交易所跨品种IPS 代码年份月份&代码年份月份IPS FG205&SA205
大连商品交易所跨期SP 代码年份月份&代码年份月份SP v2201&v2205
大连商品交易所跨品种SPC 代码年份月份&代码年份月份SPC b2201&m2201

示例代码

function main() 
    // 判断商品期货行情和交易连接是否正常
    while(!exchange.IO("status")) 
        Sleep(1000);
    
    // 设置合约代码
    Log(exchange.SetContractType("SPC b2201&m2201"));

返回值


    "DeliveryMonth": 0,
    "MinMarketOrderVolume": 1,
    "PriceTick": 1,
    "StartDelivDate": "",
    "PositionDateType": 50,
    "CombinationType": 48,
    "ExchangeInstID": "SPC b2201&m2201",
    "CreateDate": "",
    "OpenDate": "",
    "UnderlyingMultiple": 1,
    "DeliveryYear": 0,
    "EndDelivDate": "",
    "PositionType": 50,
    "ShortMarginRatio": 0,
    "MaxMarketOrderVolume": 1000,
    "InstLifePhase": 49,
    "IsTrading": 1,
    "UnderlyingInstrID": "",
    "StrikePrice": 0,
    "InstrumentID": "SPC b2201&m2201",
    "ExchangeID": "DCE",
    "ProductID": "SPC b&m",
    "ProductClass": 51,
    "VolumeMultiple": 0,
    "LongMarginRatio": 0,
    "InstrumentName": "SPC b2201&m2201",
    "MinLimitOrderVolume": 1,
    "ExpireDate": "",
    "MaxLimitOrderVolume": 1000,
    "MaxMarginSideAlgorithm": 48,
    "OptionsType": 0

3. 商品期权

商品期权是一种很好的商品风险规避和管理的金融工具,大宗商品的风险无处不在,其中最重要的是价格风险,那么就可以利用商品期权的各种套期保值工具对冲交易,来规避这种风险。

3.1 商品期权代码规则

期权的合约代码由“期货合约代码+期权类型+行权价格”组成,例如M1705-C-2500、M1705-P-2500,里面C、P分别代表看涨期权和看跌期权。如下面的图表所示:

示例代码

function main() 
    // 判断商品期货行情和交易连接是否正常
    while(!exchange.IO("status")) 
        Sleep(1000);
    
    // 设置合约代码
    Log(exchange.SetContractType("i2211-C-740"));

返回值


    "ExpireDate": "20221014",
    "EndDelivDate": "20221014",
    "UnderlyingInstrID": "i2211",
    "InstrumentName": "i2211-C-740",
    "DeliveryYear": 2022,
    "InstLifePhase": 49,
    "UnderlyingMultiple": 1,
    "ProductClass": 50,
    "MaxLimitOrderVolume": 1000,
    "LongMarginRatio": 0,
    "ExchangeInstID": "i2211-C-740",
    "ProductID": "i_o",
    "VolumeMultiple": 100,
    "OpenDate": "20211209",
    "PositionType": 50,
    "InstrumentID": "i2211-C-740",
    "DeliveryMonth": 11,
    "MinMarketOrderVolume"

以上是关于发明者量化商品期货合约代码明细的主要内容,如果未能解决你的问题,请参考以下文章

商品期货等差网格策略

商品期货等差网格策略

CTA策略之商品期货网格策略

CTA策略之商品期货定时启停机器人

复盘一个商品期货的通用模型

股票型基金和期货有什么区别?