Sumber dimuat naik... memuat...

Jadi, saya akan merayu kepada anda untuk merubah kod ini menjadi kod Python untuk gambar dua hala koordinat.

Penulis:a410999923, Dicipta: 2019-12-24 16:03:12, Dikemas kini:

var preTime = 0; var ChartObj = null; fungsi utama LogReset ((1); ChartObj = Chart(null); ChartObj.reset(); rekod var = sifar; var MACD = sifar; pertukaran.SetContractType ((quarter); // Log ((exchange.GetUSDCNY()); // exchange.SetRate ((exchange.GetUSDCNY()); pertukaran.SetRate(1); ChartObj = $.GetCfg();

///*
// 处理 指标轴------------------------
ChartObj.yAxis = [{
        title: {text: 'K线'},//标题
        style: {color: '#4572A7'},//样式 
        opposite: false  //生成右边Y轴
    },
    {
        title:{text: "指标轴"},
        opposite: true,  //生成右边Y轴  ceshi
    }
];
// 初始化指标线
while(!records || records.length < 30){
    records = _C(exchange.GetRecords);
    LogStatus("records.length:", records.length);
    Sleep(1000);
}

$.PlotRecords(records, 'OK期货');
$.PlotLine('dif', 0, records[records.length - 1].Time);
$.PlotLine('dea', 0, records[records.length - 1].Time);
var chart = $.PlotLine('macd', 0, records[records.length - 1].Time);
// 修改指标线 坐标轴Y轴
for(var key in ChartObj.series){
    if(ChartObj.series[key].name == 'dif' || ChartObj.series[key].name == 'dea' || ChartObj.series[key].name == 'macd'){
        ChartObj.series[key].yAxis = 1;
    }
}
chart.update(ChartObj);
chart.reset();
//*/

while(true){
    records = _C(exchange.GetRecords);
    if(records.length > 50){
        $.PlotRecords(records, 'OK期货');
        MACD = TA.MACD(records);
        var dif = MACD[0];
        var dea = MACD[1];
        var macd = MACD[2];
        if(preTime !== records[records.length - 1].Time){
            $.PlotLine('dif', dif[dif.length - 2], records[records.length - 2].Time);
            $.PlotLine('dea', dea[dea.length - 2], records[records.length - 2].Time);
            $.PlotLine('macd', macd[macd.length - 2], records[records.length - 2].Time);
            
            $.PlotLine('dif', dif[dif.length - 1], records[records.length - 1].Time);
            $.PlotLine('dea', dea[dea.length - 1], records[records.length - 1].Time);
            $.PlotLine('macd', macd[macd.length - 1], records[records.length - 1].Time);
            
            preTime = records[records.length - 1].Time;
        }else{
            $.PlotLine('dif', dif[dif.length - 1], records[records.length - 1].Time);
            $.PlotLine('dea', dea[dea.length - 1], records[records.length - 1].Time);
            $.PlotLine('macd', macd[macd.length - 1], records[records.length - 1].Time);
        }
    }
    LogStatus("records.length:", records.length, records[records.length - 1]);
    // Log(records[records.length - 1]);
    Sleep(1000);
}

}


Lebih lanjut

a410999923Tetapi tidak ada dua hala koordinat. Bolehkah anda bantu saya menulis satu?

RumputPada masa yang sama, Python juga mempunyai perpustakaan baris gambar.