资源加载中... loading...

数据格式

返回的格式必须为以下两种格式其中之一(系统自动识别):

  • 模拟级 Tick,以下是JSON数据范例: 普通的Bar级别回测,以下是数据范例:

    {
        "detail": {
            "alias": "MA501",
            "baseCurrency": "FUTURES",
            "basePrecision": 1,
            "contractType": "MA501",
            "eid": "Futures_CTP",
            "info": {
                "CombinationType": 48,
                "CreateDate": 20240116,
                "DeliveryMonth": 1,
                "DeliveryYear": 1501,
                "EndDelivDate": 20250114,
                "ExchangeID": "CZCE",
                "ExchangeInstID": "MA501",
                "ExpireDate": 20250114,
                "InstLifePhase": 49,
                "InstrumentID": "MA501",
                "InstrumentName": "甲醇1月",
                "IsTrading": 1,
                "LongMarginRatio": 0.08,
                "MaxLimitOrderVolume": 1000,
                "MaxMarginSideAlgorithm": 48,
                "MaxMarketOrderVolume": 200,
                "MinLimitOrderVolume": 1,
                "MinMarketOrderVolume": 1,
                "OpenDate": 20240116,
                "OptionsType": 0,
                "PositionDateType": 50,
                "PositionType": 50,
                "PriceTick": 1,
                "ProductClass": 49,
                "ProductID": "MA",
                "ShortMarginRatio": 0.08,
                "StartDelivDate": 0,
                "StrikePrice": 0,
                "UnderlyingInstrID": "",
                "UnderlyingMultiple": 1,
                "VolumeMultiple": 10
            },
            "marginCurrency": "CNY",
            "marginLevel": 12,
            "maxNotional": 10000000,
            "maxQty": 1000,
            "minNotional": 1,
            "minQty": 1,
            "priceTick": 1,
            "quoteCurrency": "CNY",
            "quotePrecision": 0,
            "symbol": "MA501",
            "volumeTick": 1
        },
        "schema": ["time", "open", "high", "low", "close", "vol", "position"],
        "data": [
            [1719795600000, 2632, 2633, 2621, 2625, 13070, 1720510],   // 2024-07-01 09:00:00
            [1719795660000, 2625, 2625, 2621, 2623, 4280, 1720940],    // 2024-07-01 09:01:00
            [1719795720000, 2623, 2626, 2622, 2622, 5320, 1722310],    // 2024-07-01 09:02:00
            [1719795780000, 2622, 2625, 2620, 2625, 3480, 1722160],
            [1719795840000, 2624, 2624, 2622, 2623, 2220, 1723150],
            [1719795900000, 2623, 2624, 2620, 2620, 3080, 1722840],
            [1719795960000, 2621, 2622, 2620, 2620, 3090, 1723850]
        ]
    }
    
  • 实盘级 Tick,以下是JSON数据范例: Tick级回测的数据(包含盘口深度信息,深度格式为[价格, 量]的数组。可有多级深度,asks为价格升序,bids为价格倒序)。

    // 不含分笔数据
    {
        "detail": {
            "alias": "MA501",
            "baseCurrency": "FUTURES",
            "basePrecision": 1,
            "contractType": "MA501",
            "eid": "Futures_CTP",
            "info": {
                "CombinationType": 48,
                "CreateDate": 20240116,
                "DeliveryMonth": 1,
                "DeliveryYear": 1501,
                "EndDelivDate": 20250114,
                "ExchangeID": "CZCE",
                "ExchangeInstID": "MA501",
                "ExpireDate": 20250114,
                "InstLifePhase": 49,
                "InstrumentID": "MA501",
                "InstrumentName": "甲醇1月",
                "IsTrading": 1,
                "LongMarginRatio": 0.08,
                "MaxLimitOrderVolume": 1000,
                "MaxMarginSideAlgorithm": 48,
                "MaxMarketOrderVolume": 200,
                "MinLimitOrderVolume": 1,
                "MinMarketOrderVolume": 1,
                "OpenDate": 20240116,
                "OptionsType": 0,
                "PositionDateType": 50,
                "PositionType": 50,
                "PriceTick": 1,
                "ProductClass": 49,
                "ProductID": "MA",
                "ShortMarginRatio": 0.08,
                "StartDelivDate": 0,
                "StrikePrice": 0,
                "UnderlyingInstrID": "",
                "UnderlyingMultiple": 1,
                "VolumeMultiple": 10
            },
            "marginCurrency": "CNY",
            "marginLevel": 12,
            "maxNotional": 10000000,
            "maxQty": 1000,
            "minNotional": 1,
            "minQty": 1,
            "priceTick": 1,
            "quoteCurrency": "CNY",
            "quotePrecision": 0,
            "symbol": "MA501",
            "volumeTick": 1
        },
        "schema": ["time", "asks", "bids", "close", "vol", "position"],
        "data": [
            [1719795601778, [[2633, 50]],  [[2631, 50]],  2632, 110410, 1718490],
            [1719795602192, [[2632, 120]], [[2631, 50]],  2632, 110410, 1718490],
            [1719795603873, [[2631, 20]],  [[2630, 600]], 2631, 110780, 1718790],
            [1719795604769, [[2633, 120]], [[2630, 490]], 2631, 111300, 1718860],
            [1719795605661, [[2632, 200]], [[2631, 30]],  2632, 111750, 1718880]
        ]
    }
    
字段 说明
schema 指定data数组里列的属性,区分大小写, 仅限于 time, open, high, low, close, vol, asks, bids, trades
data 一个按schema指一列保存数据的数组
detail 商品期货的品种需要提供的属性

detail字段

字段 说明 例子
alias 合约代码 rb2501
baseCurrency 交易品种 FUTURES
basePrecision 交易品种精度 1
contractType 合约代码 rb2501
eid 交易所对象Id Futures_CTP
info 合约详细信息 其中记录了合约的上市日期、交割日期、合约乘数、价格一跳等信息。
marginCurrency 保证金币种 CNY
marginLevel 杠杆倍数 该数据和合约具体的保证金率有关,一般不可修改
maxNotional 单笔最大下单金额 10000000
maxQty 单笔最大下单数量 1000
minNotional 单笔最小下单金额 1
minQty 单笔最小下单数量 1
priceTick 价格一跳
quoteCurrency 计价货币 CNY
quotePrecision 计价货币精度 0
symbol 合约代码 rb2501
volumeTick 下单量最小变动幅度 1

特殊的列属性asksbidstrades

字段 说明 备注
asks / bids [[价格, 数量], …] 例如实盘级 Tick数据范例中的数据:[[9531300, 10]]
trades [[时间, 方向(0:买,1:卖), 价格, 数量], …] 例如实盘级 Tick数据范例中的数据:[[1564315200000, 0, 9531300, 10]]

detail字段中info字段值内容与exchange.SetContractType()函数返回的数据Info字段一致。

detail字段中timeLine字段说明: 当策略代码中设置的合约代码为主力连续合约(例如:MA888)、指数合约(例如:MA000)时,自定义数据源应答的数据的detail中还需要增加一个timeLine字段。

// timeLine字段值
[
    {
        "begin": 1451836800000,
        "end": 1460013300000,
        "symbol": "MA605"
    }, {
        "begin": 1460034000000,
        "end": 1470640500000,
        "symbol": "MA609"
    }
    // ...
]
保存回测设置 自定义数据源范例