rest 버전 OKEX 연장 헤지킹 전략 (교육)

저자:작은 꿈, 2019-04-17 13:30:36
태그:연구

매우 간결한 버전의 OKEX 연장 헤지킹 전략 (교육)

img

  • 이 모든 것은 단지 정서일 뿐이고, 반서는 수정될 수 있고, 계약은 교체될 수 있다.

  • 두 개의 거래소 객체를 추가합니다. 첫 번째 분기, 두 번째 주간.

  • 모든 단순화 가능한 코드를 간소화하고, 최적화 할 수있는 공간이 많으며, 교육 전략은 신중하고, 시간이 넘어가면 위험이 있습니다.

  • 이 글은 이 부분의 다른 부분과 같습니다.

교육 전략, 실제 사용.

교육 전략, 실제 사용.

교육 전략, 실제 사용.


function Hedge (isOpen, priceA, priceB) {
    exchanges[0].SetDirection(isOpen ? "sell" : "closesell")
    exchanges[1].SetDirection(isOpen ? "buy" : "closebuy");
    (function (routineA, routineB) {
        Log(routineA.wait(), routineB.wait(), priceA, priceB)
    })(exchanges[0].Go(isOpen ? "Sell" : "Buy", priceA, _ContractNum), exchanges[1].Go(isOpen ? "Buy" : "Sell", priceB, _ContractNum));
}

var slidePrice = 5
function main () {
    var tickerA, tickerB 
    var arr = []
    for (var i = 0 ; i < _Count ; i++) {
        arr.push({open: _Begin + i * _Add, cover: _Begin + i * _Add - _Profit, isHold: false})
    }
    exchanges[0].SetContractType("quarter")
    exchanges[1].SetContractType("this_week")
    while (1) {
        var tab = {type: "table", title: "状态", cols: ["节点信息"], rows: []}
        tickerA = exchanges[0].GetTicker()
        tickerB = exchanges[1].GetTicker()

        if (tickerA && tickerB) {
            $.PlotLine("差价:A所-B所", tickerA.Last - tickerB.Last)
            for (var j = 0 ; j < arr.length; j++) {
                if (tickerA.Buy - tickerB.Sell > arr[j].open && !arr[j].isHold) {
                    Hedge(true, tickerA.Buy - slidePrice, tickerB.Sell + slidePrice)
                    arr[j].isHold = true
                }
                if (tickerA.Sell - tickerB.Buy < arr[j].cover && arr[j].isHold) {
                    Hedge(false, tickerA.Sell + slidePrice, tickerB.Buy - slidePrice)
                    arr[j].isHold = false 
                }
                tab.rows.push([JSON.stringify(arr[j])])
            }
        }
        LogStatus(_D(), "\n `" + JSON.stringify(tab) + "`")
        Sleep(500)
    }
}

관련

더 많은

제이미를 사랑해요exchanges[0].Go ((() 이 함수 문서에 설명이 없나요? 어디서 왔으며, 무슨 뜻입니까? 링크를 요청합니다.

1998년안녕하세요, 저자님, 이 전략이 여전히 유효한가요?

fmzero교육용 비디오는 어디 있어요?

제이미를 사랑해요오, 감사합니다, 봤어요, 배웠습니다.

작은 꿈이 API 문서는 http://www.fmz.com/api#exchange.go...

작은 꿈전략은 교육 전략이며, 실제 사용에 신중합니다.

작은 꿈이 코드는 매우 간단하고, 코드를 보면 알 수 있습니다.