Versi yang disederhanakan dari Multi-platform Hedging Stabilization Arbitrage strategy (Hanya untuk tujuan studi)

Penulis:Kebaikan, Dibuat: 2018-08-30 10:28:43, Diperbarui: 2023-11-14 21:08:18

Simplified version of Multi-platform Hedging Stabilization Arbitrage strategy  (Study purpose only)

Versi Sederhana dari Multi-Platform Hedging Stabilization Arbitrage www.fmz.com versi asli dari strategi ini, Anda dapat menemukannya di:https://www.fmz.com/bbs-topic/2279berisi komentar yang sangat spesifik tentang kode.

Versi yang lebih pendek ini hanya untuk tujuan belajar, karena peningkatan teknologi situs web kami, sebagian besar strategi rumit Anda dapat sangat menghemat waktu pada bagian pengkodean. Kami saat ini membangun kembali fungsi API kami, kami akan membuatnya lebih mudah dibaca dan lebih efektif untuk dieksekusi, selain fungsi dasar, kami akan mengumpulkan lebih banyak metode dalam beberapa fungsi tertentu daripada sekali Anda memanggil fungsi, itu akan melakukan tindakan yang serius.

Berikut ini versi yang disederhanakan:

var preSumBalance = 0
var initSumBalance = 0
function UpdateAccount(isFirst){
    var msg = ""
    var sumStocks = 0
    var sumBalance = 0
    for(var i = 0; i < exchanges.length; i++){
        if(exchanges[i].needUpdate == true || isFirst == true){
            exchanges[i].account = _C(exchanges[i].GetAccount)
            exchanges[i].needUpdate = false
            if(isFirst == true){
                initSumBalance += (exchanges[i].account.Balance + exchanges[i].account.FrozenBalance)
                exchanges[i].SetPrecision(_CurrencyPrecision, _BaseCurrencyPrecision)
            }
        }
        sumStocks += (exchanges[i].account.Stocks + exchanges[i].account.FrozenStocks)
        sumBalance += (exchanges[i].account.Balance + exchanges[i].account.FrozenBalance)
        msg += exchanges[i].GetName() + "coin:" + exchanges[i].account.Stocks + "Frozen coin:" + exchanges[i].account.FrozenStocks + "money:" + exchanges[i].account.Balance + "Frozen money:" + exchanges[i].account.FrozenBalance + "\n"
    }
    LogStatus(_D(), "Total Coins:" + sumStocks, "Total Money:" + sumBalance, "\n", msg)
    if(preSumBalance != sumBalance){
        LogProfit(sumBalance - initSumBalance, preSumBalance = sumBalance)
    }
}
function main(){
    UpdateAccount(true)
    while(1){
        for(var i = 0; i < exchanges.length; i++){
            for(var j = 0; j < exchanges.length; j++){
                if(i == 0 && j == 0){
                    for(var m = 0; m < exchanges.length; m++){
                        exchanges[m].thread = exchanges[m].Go("GetTicker")
                    }
                    for(var n = 0; n < exchanges.length; n++){
                        exchanges[n].ticker = exchanges[n].thread.wait()
                    }
                }
                if(exchanges[i].GetName() != exchanges[j].GetName() && exchanges[i].ticker && exchanges[j].ticker && exchanges[i].ticker.Buy - exchanges[j].ticker.Sell > _HedgePrice){
                    if(exchanges[i].account.Stocks > _HedgeAmount && exchanges[j].account.Balance / ((exchanges[i].ticker.Buy + exchanges[j].ticker.Sell) / 2) > _HedgeAmount){
                        var sellId_I = exchanges[i].Sell((exchanges[i].ticker.Buy + exchanges[j].ticker.Sell) / 2, _HedgeAmount, exchanges[i].GetName())
                        var buyId_J = exchanges[j].Buy((exchanges[i].ticker.Buy + exchanges[j].ticker.Sell) / 2, _HedgeAmount, exchanges[i].GetName())
                        exchanges[i].needUpdate = exchanges[j].needUpdate = true
                    }
                }
            }
        }
        UpdateAccount(false)
        Sleep(300)      // test
    }
}

Artikel terkait

Informasi lebih lanjut

QQ4830163zan

Penemu Kuantitas - Mimpi KecilBagus sekali!