For example: A exchange: ETH_BTC Exchange B: ETH_USDT Exchange C (actually exchange B) is another trading pair, which is logically assumed to be C。): BTC_USDT
B, C exchange trades for a combination of ETH_BTC and A exchange hedge; so BC is actually an exchange account.
// 交易对以 ETH_BTC , ETH_USDT , BTC_USDT 为例 // 教学策略,还有很大优化空间,例如:币平衡模块,根据手续费率控制对冲差价,硬搬砖等等。 function main () { if (exchanges[0].GetQuoteCurrency() != exchanges[2].GetCurrency().split("_")[0] || exchanges[0].GetCurrency().split("_")[0] != exchanges[1].GetCurrency().split("_")[0]) { throw "交易所 交易对 配置错误。" } var marketSlideRate = 1 // 1.02 var hedgeDiff = 0.0007 var hedgeAmount = 0.1 var isFirst = true var concurrenter = function (funcName, isWait, tasks, amounts) { for (var i = 0 ; i < exchanges.length; i++) { if (isFirst) { exchanges[i].acc = _C(exchanges[i].GetAccount) exchanges[i].initAcc = exchanges[i].acc } if (isWait) { var a = funcName == "GetTicker" ? exchanges[i].ticker = exchanges[i].tiR.wait() : exchanges[i].id = exchanges[i].trR.wait() if (funcName == "trade") { exchanges[i].acc = _C(exchanges[i].GetAccount) } } else { var b = funcName == "GetTicker" ? exchanges[i].tiR = exchanges[i].Go(funcName) : exchanges[i].trR = exchanges[i].Go(tasks[i], -1, amounts[i], exchanges[i].GetCurrency()) } } if (funcName == "trade" && isWait) { Log("BTC:", exchange.BTC = exchanges[0].acc.Balance + exchanges[2].acc.Stocks, "ETH:", exchange.ETH = exchanges[0].acc.Stocks + exchanges[1].acc.Stocks, "USDT:", exchange.USDT = exchanges[1].acc.Balance + exchanges[2].acc.Balance, "#FF0000") LogProfit(exchange.USDT - (exchanges[1].initAcc.Balance + exchanges[2].initAcc.Balance) - (exchanges[0].initAcc.Balance + exchanges[2].initAcc.Stocks - exchange.BTC) * exchanges[2].ticker.Last - (exchanges[0].initAcc.Stocks + exchanges[1].initAcc.Stocks - exchange.ETH) * exchanges[1].ticker.Last) } isFirst = false } while (1) { concurrenter("GetTicker", false) concurrenter("GetTicker", true) var tickerA = exchanges[0].ticker var tickerB = exchanges[1].ticker var tickerC = exchanges[2].ticker var tickerBC = { Buy : tickerB.Buy / tickerC.Sell, Sell : tickerB.Sell / tickerC.Buy, } if (tickerA.Buy - tickerBC.Sell > hedgeDiff && exchanges[0].acc.Stocks > 0.2 && exchanges[1].acc.Balance > 500 && exchanges[2].acc.Stocks > 0.03) { // Sell A , Buy BC (Buy B Sell C) concurrenter("trade", false, ["Sell", "Buy", "Sell"], [hedgeAmount, marketSlideRate * tickerB.Sell * hedgeAmount, tickerB.Sell * hedgeAmount / tickerC.Buy]) concurrenter("trade", true) } if (tickerBC.Buy - tickerA.Sell > hedgeDiff && exchanges[0].acc.Balance > 0.03 && exchanges[1].acc.Stocks > 0.2 && exchanges[2].acc.Balance > 500) { // Buy A , Sell BC (...) concurrenter("trade", false, ["Buy", "Sell", "Buy"], [marketSlideRate * hedgeAmount * tickerA.Sell, hedgeAmount, marketSlideRate * hedgeAmount * tickerA.Sell * tickerC.Sell]) concurrenter("trade", true) } Sleep(500) } }
BNMBNM pro: TypeError: cannot read property 'Sell' of null at main (__FILE__:45) pro: GetTicker: 429: {"msg":"Requests too frequent.","code":"50011"}
BNMBNMHey, this is going to run with three coins, or it will run with USDT.
BNMBNMHow can you not run?
fmzeroWhere's the teaching video?
Inventors quantify - small dreamsThree coins are needed.
Inventors quantify - small dreams Requests too frequent!
BNMBNMHey, this is going to run with three coins, or it will run with USDT.
BNMBNMCan you set the transaction volume to 0.03? What does that 0.00007 and 1/1.02 represent?
BNMBNMOkay, I'm going to run again.
Inventors quantify - small dreamsIf you have any questions about the error message, please send it here, or to the official FMZ group @dreamback.
BNMBNMCan you add your WeChat?
Inventors quantify - small dreamsSend us a specific question, or add an FMZ official WeChat group @dreamback
BNMBNMCan you add your WeChat?
Inventors quantify - small dreamsThis is a real-time strategy, and if there is a problem, you need to send a specific question.