Les ressources ont été chargées... Je charge...

OKEX V5 interfaces pour arrêter les dommages

Auteur:L'été ne vous frappe pas., Date: le 14 janvier 2022 22:04:26
Les étiquettes:




// 挂多单止损
function longStopLossInOkex(num, symbol, price, size) {
    let real_symbol = symbol.replace("_USDT", "") + "-USDT-SWAP";
    var param = "instId=" + real_symbol + "&tdMode=cross" + "&side=sell" + "&posSide=long" + "&ordType=conditional" + "&sz=" + size.toString() + "&slTriggerPx=" + price.toString() + "&slOrdPx=-1";
    var ret = exchanges[num].IO("api", "POST", "/api/v5/trade/order-algo", param);
    Log(exchanges[num].GetLabel(), ": 挂多单止损:", ret);
    return true;
}

// 挂多单止盈
function longTakeProfitInOkex(num, symbol, price, size) {
    let real_symbol = symbol.replace("_USDT", "") + "-USDT-SWAP";
    var param = "instId=" + real_symbol + "&tdMode=cross" + "&side=sell" + "&posSide=long" + "&ordType=conditional" + "&sz=" + size.toString() + "&tpTriggerPx=" + price.toString() + "&tpOrdPx=-1";
    var ret = exchanges[num].IO("api", "POST", "/api/v5/trade/order-algo", param);
    Log(exchanges[num].GetLabel(), ": 挂多单止盈:", ret);
    return true;
}

// 挂空单止损
function shortStopLossInOkex(num, symbol, price, size) {
    let real_symbol = symbol.replace("_USDT", "") + "-USDT-SWAP";
    var param = "instId=" + real_symbol + "&tdMode=cross" + "&side=buy" + "&posSide=short" + "&ordType=conditional" + "&sz=" + size.toString() + "&slTriggerPx=" + price.toString() + "&slOrdPx=-1";
    var ret = exchanges[num].IO("api", "POST", "/api/v5/trade/order-algo", param);
    Log(exchanges[num].GetLabel(), ": 挂空单止损:", ret);
    return true;
}

// 挂空单止盈
function shortTakeProfitInOkex(num, symbol, price, size) {
    let real_symbol = symbol.replace("_USDT", "") + "-USDT-SWAP";
    var param = "instId=" + real_symbol + "&tdMode=cross" + "&side=buy" + "&posSide=short" + "&ordType=conditional" + "&sz=" + size.toString() + "&tpTriggerPx=" + price.toString() + "&tpOrdPx=-1";
    var ret = exchanges[num].IO("api", "POST", "/api/v5/trade/order-algo", param);
    Log(exchanges[num].GetLabel(), ": 挂空单止盈:", ret);
    return true;
}

// 挂多单止盈止损
function longTpAndSlInOkex(num, symbol, tp_price, sl_price, size) {
    let real_symbol = symbol.replace("_USDT", "") + "-USDT-SWAP";
    var param = "instId=" + real_symbol + "&tdMode=cross" + "&side=sell" + "&posSide=long" + "&ordType=oco" + "&sz=" + size.toString() + "&tpTriggerPx=" + tp_price.toString() + "&tpOrdPx=-1"
                    + "&slTriggerPx=" + sl_price.toString() + "&slOrdPx=-1";
    var ret = exchanges[num].IO("api", "POST", "/api/v5/trade/order-algo", param);
    Log(exchanges[num].GetLabel(), ": 挂多单止盈止损:", ret);
    return true;
}

// 挂空单止盈止损
function shortTpAndSlInOkex(num, symbol, tp_price, sl_price, size) {
    let real_symbol = symbol.replace("_USDT", "") + "-USDT-SWAP";
    var param = "instId=" + real_symbol + "&tdMode=cross" + "&side=buy" + "&posSide=short" + "&ordType=oco" + "&sz=" + size.toString() + "&tpTriggerPx=" + tp_price.toString() + "&tpOrdPx=-1"
                    + "&slTriggerPx=" + sl_price.toString() + "&slOrdPx=-1";
    var ret = exchanges[num].IO("api", "POST", "/api/v5/trade/order-algo", param);
    Log(exchanges[num].GetLabel(), ": 挂空单止盈止损:", ret);
    return true;
}

function main() {
    shortTakeProfitInOkex(0, "ETH_USDT", 2800, 1);
    shortTpAndSlInOkex(0, "ETH_USDT", 2800, 3000, 1);
}

Plus de