सरल और समान खराब अनुबंध जाल

लेखक:नोबेल, दिनांकः 2021-11-18 17:28:35
टैगः

पैरामीटर बहुत सरल है, उदाहरण के लिए, बीटीसी के लिए, अधिक क्षेत्रों में सपाट, अधिक खुले क्षेत्रों में सपाट, और फिर से। जाहिर है, मुद्रा के दायरे में, लंबे समय में, कोई भी जटिल मॉडल मस्तिष्कहीन ग्रिड से अधिक नहीं चल सकता है। धन का पासवर्ड एक दिमाग रहित जाल + दिमाग रहित कुत्ता है। आशा, पहले मार्टिन की तरह, सबसे सरल, सबसे असभ्य, लेकिन सबसे अच्छा रणनीति है। img


'''backtest
start: 2021-01-01 00:00:00
end: 2021-11-17 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":2500}]
args: [["H",30],["n1",0.001],["grid",300],["xia",50000]]
'''

def CancelPendingOrders():
    orders = _C(exchanges[0].GetOrders)
    if len(orders)>0:
        for j in range(len(orders)):
            exchanges[0].CancelOrder(orders[j].Id, orders[j])
            j=j+1

def main():
    exchange.SetContractType('swap')
    exchange.SetMarginLevel(M)
    currency=exchange.GetCurrency()
    if _G('buyp') and _G('sellp'):
        buyp=_G('buyp')
        sellp=_G('sellp')
        Log('读取网格价格')
    else:
        ticker=exchange.GetTicker()
        buyp=ticker["Last"]-grid
        sellp=ticker["Last"]+grid
        _G('buyp',buyp)
        _G('sellp',sellp)
        Log('网格数据初始化')
    while True:
            account=exchange.GetAccount()
            ticker=exchange.GetTicker()
            position=exchange.GetPosition()
            orders=exchange.GetOrders()
            if len(position)==0:
                if ticker["Last"]>shang:
                    exchange.SetDirection('sell')
                    exchange.Sell(-1,n1*H)
                    Log(currency,'到达开空区域,买入空头底仓')
                    
                else:
                    exchange.SetDirection('buy')
                    exchange.Buy(-1,n1*H)
                    Log(currency,'到达开多区域,买入多头底仓')
            if len(position)==1:
                if position[0]["Type"]==1:
                    if ticker["Last"]<xia:
                        Log(currency,'空单全部止盈反手')
                        exchange.SetDirection('closesell')
                        exchange.Buy(-1,position[0].Amount)
                    else:
                        orders=exchange.GetOrders()
                        if len(orders)==0:
                            exchange.SetDirection('sell')
                            exchange.Sell(sellp,n1)
                            exchange.SetDirection('closesell')
                            exchange.Buy(buyp,n1)
                        if len(orders)==1:
                            if orders[0]["Type"]==1: #止盈成交
                                Log(currency,'网格减仓,当前份数:',position[0].Amount)
                                CancelPendingOrders()
                                buyp=buyp-grid
                                sellp=sellp-grid
                                LogProfit(account["Balance"])
                            if orders[0]["Type"]==0:
                                Log(currency,'网格加仓,当前份数:',position[0].Amount)
                                CancelPendingOrders()
                                buyp=buyp+grid
                                sellp=sellp+grid
                                LogProfit(account["Balance"])
            
                if position[0]["Type"]==0:
                    if ticker["Last"]>float(shang):
                        Log(currency,'多单全部止盈反手')
                        exchange.SetDirection('closebuy')
                        exchange.Sell(-1,position[0].Amount)
                    else:
                        orders=exchange.GetOrders()
                        if len(orders)==0:
                            exchange.SetDirection('buy')
                            exchange.Buy(buyp,n1)
                            exchange.SetDirection('closebuy')
                            exchange.Sell(sellp,n1)
                        if len(orders)==1:
                            if orders[0]["Type"]==0: #止盈成交
                                Log(currency,'网格减仓,当前份数:',position[0].Amount)
                                CancelPendingOrders()
                                buyp=buyp+grid
                                sellp=sellp+grid
                                LogProfit(account["Balance"])
                            if orders[0]["Type"]==1:
                                Log(currency,'网格加仓,当前份数:',position[0].Amount)
                                CancelPendingOrders()
                                buyp=buyp-grid
                                sellp=sellp-grid
                                LogProfit(account["Balance"])
                            
                    
                
                                     
            


अधिक

मेक्समिनfor के लिए एक समस्या है।

हल्के बादलकृपया बताएं, वास्तविक डिस्क में त्रुटि है Traceback (most recent call last): File "", line 36, in TypeError: object of type 'NoneType' has no len (() मुझे नहीं पता कि इसे कैसे ठीक किया जाए, धन्यवाद।

हल्के बादल

हल्के बादलअच्छा, धन्यवाद।

नोबेलस्थिति के लिए एक स्ट्रक्चरल सरणी को देखो, यह यहाँ एक समस्या होनी चाहिए।