资源加载中... loading...

割庄神器

Author: kongbai979, Date: 2020-03-19 21:49:56
Tags:


function xiadan() { //下单函数

    exchange.SetPrecision(2, 3)  
    Sleep(51)
    exchange.SetContractType("swap")  
    Sleep(51)
    exchange.SetMarginLevel(g2)  
    Sleep(51)
    var fff000 = exchange.GetPosition()  
    if (fff000.length == 0) {
        var records = exchange.GetRecords(PERIOD_D1)
        var records1 = records[records.length - 1].High - records[records.length - 1].Low
        var records2 = records[records.length - 2].High - records[records.length - 2].Low
        var records3 = records[records.length - 3].High - records[records.length - 3].Low
        var records4 = records[records.length - 4].High - records[records.length - 4].Low
        var records5 = records[records.length - 5].High - records[records.length - 5].Low
        var recordsn = [records1, records2, records3, records4, records5]
        yh = 0
        for (var i = 0; i < recordsn.length; i++) {
            if (recordsn[i] > 5) {
                yh = yh + 1  
            }
        }
        if (records1 > 20) {
            Sleep(51)
            exchange.SetDirection("buy")        
            Sleep(60)
            var id = exchange.Buy(-1, a)    
            Sleep(500)
            Log("开仓,方向为做多,智能识别,我的选择不会错的!加油!")
        } else {
            exchange.SetDirection("sell")      
            Sleep(51)
            var id = exchange.Sell(-1, a)   
            Sleep(500)
            Log("开仓,方向为做空,智能识别,我的选择不会错的!加油!")
        }


        var oder = exchange.GetOrder(id)  
        var j = oder.AvgPrice  
        var ying = j + k
        var sun = j - k



    } else {
        var jjjj = fff000[0].Price  
        var ying = jjjj + k
        var sun = jjjj - k
    }
    var t = 0
    Sleep(60)



    Sleep(100)
    /*↓ 二级循环 ↓*/
    while (true) {


        Sleep(60)
        zhanghu2 = _C(exchange.GetAccount) 

        Sleep(80)
        m100 = exchange.GetAccount()
        v1 = m100.Info
        v2 = v1.assets
        v3 = v2[1].walletBalance         

        LogProfit(_N(v3 - (_G("v4")), 2), 'USDT')

        var yu2 = zhanghu2.Balance  
        Sleep(70)
        /*↓ 以下判断是否有持仓,没有就循环跳出 ↓*/
        var fff = exchange.GetPosition()    
        var eee = 66
        if (fff.length != 0) {                        
            var cc = fff[0].Amount  
            var pp = fff[0].Price  
            var ww = fff[0].Type    
            t = t + 1  
            if (t > 2) {
                var tx = ((t * 0.0008 * a) / cc) * pp
                var td = (t * k * a) / cc
            } else {
                var tx = 0
                var td = 0
            }
            var lirun = (parseInt(cc / a)) * k / 2
            if (yu2 > (cc / g2)) {
                /*↓ 多头情况下上下挂单 ↓*/
                if (ww == 0) { //如果持仓是多头



                    while (true) {
                        var recordss = exchange.GetRecords(60)
                        var records11 = recordss[recordss.length - 1].High - recordss[recordss.length - 1].Low
                        Sleep(60)

                        if (records11 < 0) {
                            Sleep(3000)
                        } else {


                            if (cc > pc * a) {
                                Sleep(100)
                                exchange.SetDirection("closebuy")    
                                var sellid = exchange.Sell(-1, cc)   
                                Log("海燕呐,你可长点心吧,触发风控,重新开仓")
                                Sleep(10000)
                                break
                            } else if (cc > a) {

                                Sleep(100)
                                exchange.SetDirection("closebuy")  
                                Sleep(100)
                                var sellid = exchange.Sell(pp + k + tx + lirun, cc - a)  
                                Sleep(100)
                                exchange.SetDirection("buy")  
                                Sleep(100)
                                var buyid = exchange.Buy(sun, a)    
                                Sleep(100)
                                if (cc > 2 * a) {
                                    exchange.SetDirection("closebuy")  
                                    Sleep(100)
                                    var abc = exchange.Sell(ying, a)    
                                    var eee = 88
                                    Sleep(100)
                                }
                                /*else if ((pp + k + tx + lirun) > ying + k) {
                                    exchange.SetDirection("closebuy")  
                                    Sleep(100)
                                    var abc = exchange.Sell(ying, a)     
                                    var eee = 88
                                    Sleep(100)
                                }*/
                                xx = (xx + 1)
                                var zye = _N(v3 - 0, 2)
                                Log("这是第", xx, "次下单", "账户总余额:", zye, "USDT", "加险系数为", _N(tx, 2), "降险系数为", _N(td, 2), "本次建仓交易次数", t, "时间:", _D())

                            } else {
                                Sleep(100)
                                exchange.SetDirection("closebuy")  
                                Sleep(100)
                                var sellid = exchange.Sell(pp + k, cc) 
                                Sleep(100)
                                exchange.SetDirection("buy")  
                                Sleep(100)
                                var buyid = exchange.Buy(sun, a)    
                                Sleep(100)
                                xx = (xx + 1)
                                var zye = _N(v3 - 0, 2)
                                Log("这是第", xx, "次下单", "账户总余额:", zye, "USDT", "加险系数为", _N(tx, 2), "降险系数为", _N(td, 2), "本次建仓交易次数", t, "时间:", _D())
                            }


                            break
                        }
                        Sleep(2000)
                    }






                    /*↓ 空头情况下上下挂单 ↓*/
                } else if (ww == 1) {  






                    while (true) {
                        var recordsss = exchange.GetRecords(60)
                        var records111 = recordsss[recordsss.length - 1].High - recordsss[recordsss.length - 1].Low
                        Sleep(60)
                        if (records111 > 0) {
                            Sleep(3000)
                        } else {


                            if (cc > pc * a) {
                                Sleep(100)
                                exchange.SetDirection("closesell")  
                                Sleep(100)
                                var buyid = exchange.Buy(-1, cc)  
                                Log("海燕呐,你可长点心吧,触发风控,重新开仓")
                                Sleep(10000)
                                break

                            } else if (cc > a) {

                                Sleep(100)
                                exchange.SetDirection("closesell")  
                                Sleep(100)
                                var buyid = exchange.Buy(pp - k - tx - lirun, cc) 
                                Sleep(100)
                                exchange.SetDirection("sell")
                                Sleep(100)
                                var sellid = exchange.Sell(ying, a)   
                                Sleep(100)

                                if (cc > 2 * a) {
                                    exchange.SetDirection("closesell")  
                                    Sleep(100)
                                    var abc = exchange.Buy(sun, a)    
                                    Sleep(100)
                                    var eee = 88
                                }
                                /*else if ((pp - k - tx - lirun) < sun - k) {
                                    exchange.SetDirection("closesell") 
                                    Sleep(100)
                                    var abc = exchange.Buy(sun, a)    
                                    Sleep(100)
                                    var eee = 88
                                }*/
                                xx = (xx + 1)
                                var zye = _N(v3 - 0, 2)
                                Log("这是第", xx, "次下单", "账户总余额:", zye, "USDT", "加险系数为", _N(tx, 2), "降险系数为", _N(td, 2), "本次建仓交易次数", t, "时间:", _D())
                            } else {
                                Sleep(100)
                                exchange.SetDirection("closesell")  
                                Sleep(100)
                                var buyid = exchange.Buy(pp - k, cc)  
                                Sleep(100)
                                exchange.SetDirection("sell")
                                Sleep(100)
                                var sellid = exchange.Sell(ying, a)   
                                Sleep(100)
                                xx = (xx + 1)
                                var zye = _N(v3 - 0, 2)
                                Log("这是第", xx, "次下单", "账户总余额:", zye, "USDT", "加险系数为", _N(tx, 2), "降险系数为", _N(td, 2), "本次建仓交易次数", t, "时间:", _D())
                            }

                            break
                        }
                        Sleep(2000)
                    }


                }
            } else {
                Log("余额不足,剩余为", yu2, "USDT", "@")
                Sleep(1000000)
                break
            }
            /*↓ 三级循环 ↓*/
            while (true) {

         
                Sleep(1500)
                var m1 = exchange.GetOrder(sellid) 
                var m2 = m1.Status 
                var jg1 = m1.AvgPrice  
                Sleep(1500)
                var m3 = exchange.GetOrder(buyid)  
                var m4 = m3.Status 
                var jg2 = m3.AvgPrice
                Sleep(1500)

                if (eee == 88) {
                    Sleep(100)
                    var m5 = exchange.GetOrder(abc) 
                    var m6 = m5.Status  
                    var jg3 = m5.AvgPrice
                    Sleep(60)
                }
                if (m2 == 1) {  
                    if (m4 == 0) {
                        exchange.CancelOrder(buyid)
                    }  
                    if (m6 == 0) {
                        exchange.CancelOrder(abc)
                    }
                    ying = jg1 + k
                    sun = jg1 - k
                    m2 = 8
                    m4 = 8


                                       
                    break




                } else if (m4 == 1) { 
                    exchange.CancelOrder(sellid)   
                    if (m6 == 0) {
                        exchange.CancelOrder(abc)
                    }
                    sun = jg2 - k
                    ying = jg2 + k
                    m2 = 8
                    m4 = 8


                  
                    break
                } else if (m6 == 1 && eee == 88) { //如果新加的这单成交完成
                    if (m2 == 0) {
                        exchange.CancelOrder(sellid)
                       


                    }

                    if (m4 == 0) {
                        exchange.CancelOrder(buyid)
                
                    }  
                    sun = jg3 - k
                    ying = jg3 + k
                    m2 = 8
                    m4 = 8
                    break
                }



            }
        } else {
            break
        }
    }
}

function main() {
    LogReset()
    LogProfitReset()
    var m100 = exchange.GetAccount()
    var v1 = m100.Info
    var v2 = v1.assets
    var v3 = v2[1].walletBalance  
    //var v4 =v3
    _G("v4", v3)



    while (true) {
        var zhanghu = _C(exchange.GetAccount)  
        var yu = zhanghu.Balance // USDT可用余额
        var yu1 = zhanghu.Stocks //BTC持有余额
        Sleep(1000)
        var hang = exchange.GetTicker()
        var zui = hang.Last //获取当前最新价格  
        Sleep(500)
        if (yu > (zui * a) / g2) { //判断条件
            xiadan()         
        } else {
            Log("余额不足,余额为", yu, "需要余额为", zui * a, "@")
        }
    }
}
template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6