Monitoring the spot price of digital currency futures

Author: The Little Dream, Date: 2019-09-02 14:31:14
Tags: ToolStudy

Monitoring the spot price of digital currency futures

This strategy is a strategy for monitoring the spread between a futures exchange and a spot exchange. Draw a graph with a statistical deviation of 10 seconds, drawn on a graph. The first exchange to be added is the futures exchange. The second exchange added is the spot exchange.

Testing can be done using the BTC_USDT transaction pair. Default futures exchanges use tokens for DM contracts quarterly contracts, codenamed:quarterI'm not sure. The spot test exchange uses BIT-Z, trading pairs set to BTC_USDT.

Testing demonstrations, teaching use.


function main () {
    LogReset(1)
    
    exchanges[0].SetContractType(ContractType)
    
    var lastPlotTime = 0
    while(true) {
        var ticker_futures = exchanges[0].GetTicker()
        var ticker_spot = exchanges[1].GetTicker()
        var diff = ticker_futures.Last - ticker_spot.Last
        
        LogStatus(_D(), "期货-现货,差价:", diff)
        var cmd = GetCommand()
        if (cmd) {
            Log("接收到命令:", cmd, "可以对该命令内容解析,触发自定义的函数执行!#FF0000")
        }
        
        var ts = new Date().getTime()
        if (ts - lastPlotTime > 1000 * 10) {
            $.PlotLine("差价(期货-现货)", diff)
            lastPlotTime = ts
        }
        
        Sleep(500)
    }
}

Related

More

bwxiaokIt's simple and easy to understand.