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

当周季度差价画图插件

Author: 小草, Date: 2020-02-29 21:42:15
Tags:

可画出季度-当周的差价图,用于对冲分析

插件可以在交易终端一键启动,不收取费用,方便手动交易。详细介绍:https://www.fmz.com/digest-topic/5051



var chart = { 
    __isStock: true,    
    title : { text : '差价分析图'},                     
    xAxis: { type: 'datetime'},                 
    yAxis : {                                        
        title: {text: '差价'},                   
        opposite: false,                             
    },
    series : [                    
        {name : "diff", data : []}, 

    ]
}
function main() {
    exchange.SetContractType('quarter')
    var recordsA = exchange.GetRecords(PERIOD_M5)
    exchange.SetContractType('this_week')
    var recordsB = exchange.GetRecords(PERIOD_M5)
    
    for(var i=0;i<Math.min(recordsA.length,recordsB.length);i++){
        var diff = recordsA[recordsA.length-Math.min(recordsA.length,recordsB.length)+i].Close - recordsB[recordsB.length-Math.min(recordsA.length,recordsB.length)+i].Close
        chart.series[0].data.push([recordsA[recordsA.length-Math.min(recordsA.length,recordsB.length)+i].Time, diff])
    }
    return chart
}
template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6