资源加载中... 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
}

More

topiori $.Cross can not rewrite ! 咋办

小草 可以,把return改为$.PlotLine(dff),勾选画图类库就行,加个循环,你是不是引用了交易类库?

topiori 没改过, 不知道能不能变成独立运行的

小草 是不是重新定义了Cross函数,不能