ভারসাম্য বজায় রাখার কৌশল (শিক্ষা কৌশল)

লেখক:ছোট্ট স্বপ্ন, তৈরিঃ 2020-09-02 17:05:25, আপডেটঃ 2023-09-27 19:40:10

img

ভারসাম্য বজায় রাখার কৌশল (শিক্ষা কৌশল)

এই নিবন্ধে বর্ণিত কৌশলটি মূলত একটি গতিশীল ভারসাম্য কৌশল, যা সর্বদা মুদ্রার মূল্যকে মুদ্রার মূল্যের সাথে সমান করে তোলে। যদিও এটি পূর্ব তালিকাভুক্ত করার জন্য ডিজাইন করা হয়েছে, কৌশলটির যুক্তিটি খুব সহজ। এই কৌশলটি লেখার মূল উদ্দেশ্যটি কৌশলটির নকশার বিভিন্ন দিক প্রদর্শন করা।

  • কৌশলগত লজিক্যাল প্যাকেজিং কৌশলগত যুক্তি এবং কিছু ডেটা, চিহ্নিতকরণ ভেরিয়েবলগুলিকে একসাথে আবৃত করা (অবজেক্ট হিসাবে আবৃত করা) ।

  • কৌশলগতভাবে ইনস্টল করার জন্য কোড প্রাথমিক চালানের সময় প্রাথমিক অ্যাকাউন্টের তথ্য রেকর্ড করা হয়, যা উপার্জন গণনা করার জন্য ব্যবহৃত হয়, প্রাথমিকভাবে প্যারামিটারগুলির উপর ভিত্তি করে ডেটা পুনরুদ্ধার করা হয় কিনা তা।

  • কৌশলগত ইন্টারঅ্যাকশন হ্যান্ডলিং কোড একটি সহজ বিরতি, চলমান ইন্টারঅ্যাকশন প্রক্রিয়া ডিজাইন করা হয়েছে।

  • কৌশলগত উপার্জন গণনার জন্য কোড মুদ্রার মূলধন গণনা পদ্ধতি ব্যবহার করে আয় গণনা করা হয়।

  • কৌশলগতভাবে গুরুত্বপূর্ণ তথ্য স্থায়িত্বের প্রক্রিয়া ডেটা পুনরুদ্ধারের জন্য ডিজাইন প্রক্রিয়া

  • কৌশলগত তথ্য প্রক্রিয়াকরণের জন্য প্রদর্শিত কোড স্ট্যাটাস বার ডেটা প্রদর্শিত হচ্ছে।

কৌশলগত কোড

var Shannon = {
    // member
    e : exchanges[0],
    arrPlanOrders : [],
    distance : BalanceDistance,
    account : null,
    ticker : null, 
    initAccount : null,
    isAskPending : false,
    isBidPending : false,

    // function 
    CancelAllOrders : function (e) {
        while(true) {
            var orders = _C(e.GetOrders)
            if(orders.length == 0) {
                return 
            }
            Sleep(500)
            for(var i = 0; i < orders.length; i++) {
                e.CancelOrder(orders[i].Id, orders[i])
                Sleep(500)
            }
        }
    },

    Balance : function () {
        if (this.arrPlanOrders.length == 0) {
            this.CancelAllOrders(this.e)
            var acc = _C(this.e.GetAccount)
            this.account = acc
            var askPendingPrice = (this.distance + acc.Balance) / acc.Stocks
            var bidPendingPrice = (acc.Balance - this.distance) / acc.Stocks
            var askPendingAmount = this.distance / 2 / askPendingPrice
            var bidPendingAmount = this.distance / 2 / bidPendingPrice

            this.arrPlanOrders.push({tradeType : "ask", price : askPendingPrice, amount : askPendingAmount}) 
            this.arrPlanOrders.push({tradeType : "bid", price : bidPendingPrice, amount : bidPendingAmount})
        } else if(this.isAskPending == false && this.isBidPending == false) {
            for(var i = 0; i < this.arrPlanOrders.length; i++) {
                var tradeFun = this.arrPlanOrders[i].tradeType == "ask" ? this.e.Sell : this.e.Buy
                var id = tradeFun(this.arrPlanOrders[i].price, this.arrPlanOrders[i].amount)
                if(id) {
                    this.isAskPending = this.arrPlanOrders[i].tradeType == "ask" ? true : this.isAskPending
                    this.isBidPending = this.arrPlanOrders[i].tradeType == "bid" ? true : this.isBidPending
                } else {
                    Log("挂单失败,清理!")
                    this.CancelAllOrders(this.e)
                    return 
                }
            }
        }

        if(this.isBidPending || this.isAskPending) {
            var orders = _C(this.e.GetOrders)
            Sleep(1000)
            var ticker = _C(this.e.GetTicker)
            this.ticker = ticker
            if(this.isAskPending) {
                var isFoundAsk = false 
                for (var i = 0; i < orders.length; i++) {
                    if(orders[i].Type == ORDER_TYPE_SELL) {
                        isFoundAsk = true
                    }
                }
                if(!isFoundAsk) {
                    Log("卖单成交,撤销订单,重置")
                    this.CancelAllOrders(this.e)
                    this.arrPlanOrders = []
                    this.isAskPending = false 
                    this.isBidPending = false 
                    LogProfit(this.CalcProfit(ticker))
                    return 
                }
            }
            if(this.isBidPending) {
                var isFoundBid = false 
                for(var i = 0; i < orders.length; i++) {
                    if(orders[i].Type == ORDER_TYPE_BUY) {
                        isFoundBid = true
                    }
                }
                if(!isFoundBid) {
                    Log("买单成交,撤销订单,重置")
                    this.CancelAllOrders(this.e)
                    this.arrPlanOrders = []
                    this.isAskPending = false 
                    this.isBidPending = false 
                    LogProfit(this.CalcProfit(ticker))
                    return 
                }
            }        
        }
    }, 
    ShowTab : function() {
        var tblPlanOrders = {
            type : "table", 
            title : "计划挂单", 
            cols : ["方向", "价格", "数量"], 
            rows : []
        }
        for(var i = 0; i < this.arrPlanOrders.length; i++) {
            tblPlanOrders.rows.push([this.arrPlanOrders[i].tradeType, this.arrPlanOrders[i].price, this.arrPlanOrders[i].amount])
        }

        var tblAcc = {
            type : "table", 
            title : "账户信息", 
            cols : ["type", "Stocks", "FrozenStocks", "Balance", "FrozenBalance"], 
            rows : []            
        }
        tblAcc.rows.push(["初始", this.initAccount.Stocks, this.initAccount.FrozenStocks, this.initAccount.Balance, this.initAccount.FrozenBalance])
        tblAcc.rows.push(["当前", this.account.Stocks, this.account.FrozenStocks, this.account.Balance, this.account.FrozenBalance])
        
        return "时间:" + _D() + "\n `" + JSON.stringify([tblPlanOrders, tblAcc]) + "`" + "\n" + "ticker:" + JSON.stringify(this.ticker)
    },
    CalcProfit : function(ticker) {
        var acc = _C(this.e.GetAccount)
        this.account = acc
        return (this.account.Balance - this.initAccount.Balance) + (this.account.Stocks - this.initAccount.Stocks) * ticker.Last
    },
    Init : function() {
        this.initAccount = _C(this.e.GetAccount)
        if(IsReset) {
            var acc = _G("account")
            if(acc) {
                this.initAccount = acc 
            } else {
                Log("恢复初始账户信息失败!以初始状态运行!")
                _G("account", this.initAccount)
            }
        } else {
            _G("account", this.initAccount)
            LogReset(1)
            LogProfitReset()
        }
    },
    Exit : function() {
        Log("停止前,取消所有挂单...")
        this.CancelAllOrders(this.e)
    }
}

function main() {
    // 初始化
    Shannon.Init()

    // 主循环
    while(true) {
        Shannon.Balance()        
        LogStatus(Shannon.ShowTab())
        // 交互
        var cmd = GetCommand()
        if(cmd) {
            if(cmd == "stop") {
                while(true) {
                    LogStatus("暂停", Shannon.ShowTab())
                    cmd = GetCommand()
                    if(cmd) {
                        if(cmd == "continue") {
                            break
                        }
                    }
                    Sleep(1000)
                }
            }
        }
        Sleep(5000)
    }
}

function onexit() {
    Shannon.Exit()
}

পুনরায় পরীক্ষা করা হচ্ছে

img

img

img

অপ্টিমাইজড এক্সটেনশন

  • ভার্চুয়াল লিঙ্কডইন মেকানিজম যোগ করা যেতে পারে, কিছু ট্রেড সমস্ত লিঙ্কডইন সীমা মূল্য, তাই অর্ডার প্রকৃতপক্ষে ঝুলতে পারে না, মূল্য বাস্তব লিঙ্কডইন কাছাকাছি আসা পর্যন্ত অপেক্ষা করতে হবে।
  • ফিউচার ট্রেডিং এ যোগদান
  • মাল্টি-বৈচিত্র্য, মাল্টি-এক্সচেঞ্জ সংস্করণে প্রসারিত

এই কৌশলটি শুধুমাত্র শিক্ষার জন্য এবং এটি ব্যবহার করার জন্য খুব সাবধান। এই পাতাটি আলাপঃপুনর্নির্দেশhttps://www.fmz.com/strategy/225746


সম্পর্কিত

আরো