अर्ध-स्वचालित मात्रात्मक व्यापार उपकरण को शीघ्र लागू करें

लेखक:अच्छाई, बनाया गयाः 2020-08-30 10:11:02, अद्यतन किया गयाः 2023-10-08 19:54:06

img

अर्ध-स्वचालित मात्रात्मक व्यापार उपकरण को शीघ्र लागू करें

कमोडिटी फ्यूचर्स ट्रेडिंग में, अंतरिम मध्यस्थता एक आम ट्रेडिंग विधि है। इस प्रकार का मध्यस्थता जोखिम मुक्त नहीं है। जब स्प्रेड की एकतरफा दिशा का विस्तार जारी रहता है, तो मध्यस्थता स्थिति एक फ्लोटिंग लॉस राज्य में होगी। हालांकि, जब तक मध्यस्थता स्थिति को ठीक से नियंत्रित किया जाता है, तब तक यह अभी भी बहुत परिचालन और व्यवहार्य है।

इस लेख में, हम एक और ट्रेडिंग रणनीति पर स्विच करने की कोशिश करते हैं, एक पूरी तरह से स्वचालित ट्रेडिंग रणनीति के निर्माण के बजाय, हमने एक इंटरैक्टिव अर्ध-स्वचालित मात्रात्मक ट्रेडिंग टूल का एहसास किया ताकि कमोडिटी वायदा व्यापार में अंतरिम मध्यस्थता को आसान बनाया जा सके।

विकास मंच हम एफएमजेड क्वांट प्लेटफॉर्म का उपयोग करेंगे। इस लेख का फोकस इंटरैक्टिव कार्यों के साथ अर्ध-स्वचालित रणनीतियों के निर्माण पर है।

अंतराल मध्यस्थता एक बहुत ही सरल अवधारणा है।

अंतरिम मध्यस्थता की अवधारणा

  • विकिपीडिया से उद्धरण

In economics and finance, arbitrage is the practice of taking advantage of a price difference between two or more markets: striking a combination of matching deals that capitalize upon the imbalance, the profit being the difference between the market prices at which the unit is traded. When used by academics, an arbitrage is a transaction that involves no negative cash flow at any probabilistic or temporal state and a positive cash flow in at least one state; in simple terms, it is the possibility of a risk-free profit after transaction costs. For example, an arbitrage opportunity is present when there is the opportunity to instantaneously buy something for a low price and sell it for a higher price.

रणनीति डिजाइन

रणनीतिक ढांचा इस प्रकार है:

Function main(){
     While(true){
         If(exchange.IO("status")){ // Determine the connection status of the CTP protocol.
             LogStatus(_D(), "Already connected to CTP !") // Market Opening time, login connection is normal.
         } else {
             LogStatus(_D(), "CTP not connected!") // Not logged in to the trading front end.
         }
     }
}

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

Function main(){
     While(true){
         If(exchange.IO("status")){ // Determine the connection status of the CTP protocol.
             exchange.SetContractType("rb2001") // Set the far month contract
             Var tickerA = exchange.GetTicker() // far-month contract quote data
            
             exchange.SetContractType("rb1910") // Set the near month contract
             Var tickerB = exchange.GetTicker() // near-month contract quote data
            
             Var diff = tickerA.Last - tickerB.Last
             $.PlotLine("diff", diff)

             LogStatus(_D(), "Already connected to CTP !") // Market Opening time, login connection is normal.
         } else {
             LogStatus(_D(), "CTP not connected!") // Not logged in to the trading front end.
         }
     }
}

बाजार के आंकड़ों को प्राप्त करें, अंतर की गणना करें, और रिकॉर्ड करने के लिए ग्राफ खींचें। इसे बस मूल्य अंतर में हालिया उतार-चढ़ाव को प्रतिबिंबित करने दें। लाइन ड्राइंग लाइब्रेरी के फ़ंक्शन का प्रयोग करें$.PlotLine

img

अन्तरक्रियात्मक भाग

रणनीति संपादन पृष्ठ पर, आप सीधे रणनीति के लिए इंटरैक्टिव नियंत्रण जोड़ सकते हैंः

img

फ़ंक्शन का प्रयोग करेंGetCommandरणनीति कोड में उस कमांड को कैप्चर करने के लिए जो उपरोक्त रणनीति नियंत्रण को ट्रिगर करने के बाद रोबोट को भेजी गई थी।

आदेश कैप्चर होने के बाद, विभिन्न आदेशों को अलग-अलग तरीके से संसाधित किया जा सकता है।

कोड का व्यापारिक भाग Commodity Futures Trading Class Library फ़ंक्शन का उपयोग करके पैक किया जा सकता है।var q = $.NewTaskQueue()लेन-देन नियंत्रण वस्तु उत्पन्न करने के लिएq(एक वैश्विक चर के रूप में घोषित) ।

var cmd = GetCommand()
if (cmd) {
    if (cmd == "plusHedge") {
        q.pushTask(exchange, "rb2001", "sell", 1, function(task, ret) {
            Log(task.desc, ret)
            if (ret) {
                q.pushTask(exchange, "rb1910", "buy", 1, 123, function(task, ret) {
                    Log("q", task.desc, ret, task.arg)
                })
            }
        })
    } else if (cmd == "minusHedge") {
        q.pushTask(exchange, "rb2001", "buy", 1, function(task, ret) {
            Log(task.desc, ret)
            if (ret) {
                q.pushTask(exchange, "rb1910", "sell", 1, 123, function(task, ret) {
                    Log("q", task.desc, ret, task.arg)
                })
            }
        })
    } else if (cmd == "coverPlus") {
        q.pushTask(exchange, "rb2001", "closesell", 1, function(task, ret) {
            Log(task.desc, ret)
            if (ret) {
                q.pushTask(exchange, "rb1910", "closebuy", 1, 123, function(task, ret) {
                    Log("q", task.desc, ret, task.arg)
                })
            }
        })
    } else if (cmd == "coverMinus") {
        q.pushTask(exchange, "rb2001", "closebuy", 1, function(task, ret) {
            Log(task.desc, ret)
            if (ret) {
                q.pushTask(exchange, "rb1910", "closesell", 1, 123, function(task, ret) {
                    Log("q", task.desc, ret, task.arg)
                })
            }
        })
    }
}
q.poll()

संबंधित

अधिक