/*backtest start: 2017-06-26 00:00:00 end: 2022-02-16 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}] */ var MarginLevel=20 exchange.SetMarginLevel(MarginLevel) function cancelAll() { while (true) { var orders = _C(exchange.GetOrders) if (orders.length == 0) { break } for (var i = 0 ; i < orders.length ; i++) { exchange.CancelOrder(orders[i].Id, orders[i]) Sleep(interval) } } } function getLong(arr, kind) { var ret = null for (var i = 0 ; i < arr.length ; i++) { if (arr[i].Type == (kind == "pos" ? PD_LONG : ORDER_TYPE_BUY)) { ret = arr[i] } } return ret } function pendingBidOrders(firstPrice) { var index = 0 var bet=ratio var n = baseAmount while (true) { var pos = _C(exchange.GetPosition) var price = firstPrice - index * baseSpacing n=n*ratio index++ exchange.SetDirection("buy") exchange.Buy(price, amount=n) if (pos.length != 0) { var longPos = getLong(pos, "pos") if (longPos) { exchange.SetDirection("closebuy") exchange.Sell(longPos.Price + profitTarget, longPos.Amount) } } while (true) { Sleep(interval) if (!getLong(_C(exchange.GetOrders), "orders")) { cancelAll() break } if (!getLong(_C(exchange.GetPosition), "pos")) { cancelAll() return } } } } function main() { exchange.SetContractType(symbol) while (true) { pendingBidOrders(_C(exchange.GetTicker).Last) } }
ewbit12Jika Anda ingin mendapatkan informasi lebih lanjut, silakan hubungi kami di 13751002051 Weibo.
Hexie8Apakah ada multi-mata uang yang dapat menambahkan banyak pasangan transaksi?