एफएमजेड क्वांट ट्रेडिंग प्लेटफॉर्म कस्टम प्रोटोकॉल कस्टम एक्सचेंजों तक पहुंच

लेखक:लिडिया, बनाया गयाः 2023-07-12 15:29:54, अद्यतनः 2024-01-03 21:01:07

img

एफएमजेड क्वांट ट्रेडिंग प्लेटफॉर्म कस्टम प्रोटोकॉल कस्टम एक्सचेंजों तक पहुंच

कस्टम प्रोटोकॉल उपयोग प्रलेखन

आप इस सामान्य प्रोटोकॉल का उपयोग किसी भी एक्सचेंज का उपयोग करने के लिए कर सकते हैं जो एपीआई ट्रेडिंग प्रदान करता है, विशिष्ट एपीआई प्रोटोकॉल सीमित नहीं है, चाहे वह आराम हो, वेबसॉकेट, फिक्स... सभी का उपयोग करने के लिए एक्सेस किया जा सकता है। पायथन कस्टम प्रोटोकॉल उदाहरणःhttps://www.fmz.com/strategy/101399

1. कस्टम प्रोटोकॉल प्लग-इन ऑपरेशन, पोर्ट सेटिंग्स

कस्टम प्रोटोकॉल प्लगइन के लिए सुनने के पते और पोर्ट के लिए सेटिंग निम्नानुसार हो सकती हैः उदाहरण के लिए:http://127.0.0.1:6666/DigitalAssetयाhttp://127.0.0.1:6666/exchange.

हम इन सेट करने की जरूरत क्यों हैआईपीऔरपथ? क्योंकि जबविनिमय जोड़नापृष्ठ मेंएफएमजेड क्वांट प्लेटफ़ॉर्म डैशबोर्ड, Custom Protocol विकल्प का चयन करने से Service AddressAPI-KEY. यह सेवा पता डॉकर को सूचित करता है कि आईपी और बंदरगाह (डॉकर और कस्टम प्रोटोकॉल प्लगइन प्रोग्राम एक ही डिवाइस पर नहीं चल रहा हो सकता है) तक पहुंचने के लिए। उदाहरण के लिए, सेवा पता के रूप में भरा जा सकता हैhttp://127.0.0.1:6666/DigitalAsset. DigitalAssetकेवल एक उदाहरण है और अपनी पसंद के नाम से प्रतिस्थापित किया जा सकता है।

एफएमजेड क्वांट प्लेटफ़ॉर्म के एड एक्सचेंज पृष्ठ पर, आमतौर पर एक्सचेंज कॉन्फ़िगरेशन के लिए केवलaccess keyऔरsecret keyहालांकि, कुछ एक्सचेंजों एपीआई इंटरफेस के लिए ट्रेडिंग पासवर्ड पास करने की आवश्यकता होती है (जैसे, कुछ एक्सचेंजों के ऑर्डर प्लेसमेंट इंटरफेस) । ऐसे मामलों में, चूंकि कस्टम प्रोटोकॉल पेज में इस जानकारी को दर्ज करने के लिए अतिरिक्त नियंत्रण नहीं हैं, इसलिए हम अतिरिक्त आवश्यक कॉन्फ़िगरेशन जानकारी को शामिल कर सकते हैंsecret key(याaccess keyअगर जानकारी संवेदनशील नहीं है) तो, कस्टम प्रोटोकॉल प्लगइन कार्यक्रम में, हम एक स्ट्रिंग निष्पादित कर सकते हैंsplitइस डेटा को अलग करने के लिए ऑपरेशन, जैसा कि उदाहरण छवि में दिखाया गया है।

img

और फिर प्लगइन में, इसे प्राप्त करने के लिए प्रक्रियाXXX_PassWord. उदाहरण के लिए, इस पोस्ट के अंत में पूर्ण उदाहरण में, newBitgo फ़ंक्शन मेंः

func newBitgo(accessKey, secretKey string) *iBitgo {
    s := new(iBitgo)
    s.accessKey = accessKey
    s.secretKey = secretKey
    // Additional configuration information in the secretKey can be separated here and can be written as in the following comment
    /*
    arr := strings.SplitN(secretKey, ",", 2)
    if len(arr) != 2 {
        panic("Configuration error!")
    }
    s.secretKey = arr[0]   // secret key 
    s.passWord = arr[1]    // XXX_PassWord
    */
    s.apiBase = "https://www.bitgo.cn"
    s.timeout = 20 * time.Second
    s.timeLocation = time.FixedZone("Asia/Shanghai", 8*60*60)

    return s
}

अनुरोध डेटा में पैरामीटर को फिर से पार्स करते हुए, डॉकर अनुरोध डेटा को भेजता हैः

"secret_key" : "XXX",

प्लगइन इस प्रकार की जानकारी वाले आने वाले डेटा को प्राप्त करता है और अल्पविराम विभाजक के आधार पर XXX_PassWord को अलग करता है, ताकि यह अतिरिक्त पारित डेटा प्राप्त कर सके।

एक समग्र कस्टम प्रोटोकॉल प्लगइन का उदाहरणmainकार्य:Goभाषा विवरण:

func main(){
    var addr = flag.String("b", "127.0.0.1:6666", "bing addr")   // Set command line parameters, default value description, port setting 6666
    flag.Parse()                                                 // Parsing the command line
    if *addr == "" {
        flag.Usage()                                             // Display the command line description
        return 
    }
    basePath := "/DigitalAsset"
    log.Println("Running ", fmt.Sprintf("http://%s%s", *addr, basePath), "...")   // Print listening port information
    http.HandleFunc(basePath, OnPost)
    http.ListenAndServe(*addr, nil)
}

2. प्रतिक्रिया कार्य

Custom Protocol Plugin कार्यक्रम लगातार आने वाले के लिए एक निर्दिष्ट पोर्ट पर सुनता हैrequest. एक बार अनुरोध प्राप्त होने के बाद, यह निष्पादित करने के लिए प्रतिक्रिया फ़ंक्शन को बुलाता है और फिर अनुरोध डेटा से मापदंडों का विश्लेषण करता है। डॉकर द्वारा भेजे गए अनुरोध डेटा हैंः

/* JSON structure of request, FMZ Quant call GetTicker, docker sent to the custom protocol plugin case example (the value of params may be different for each API call, here the method is ticker):
{
    "access_key" : "XXX",               // `json:"access_key"`
    "secret_key" : "XXX",               // `json:"secret_key"`
    "nonce" : "1502345965295519602",    // `json:"nonce"`
    "method" : "ticker",                // `json:"method"`
    "params" : {                        // `json:"params"`
                   "symbol" : "btc",
                   ...
               },                       // The parameters are slightly different for each request. That is, different FMZ Quant APIs are called in the strategy with different parameters, which are described in the following sections for each API.
}
*/

तो, के आधार परMethodक्षेत्र मेंrequestJSON द्वारा प्राप्त संरचना अनुरोध deserializing शरीर डेटा यूनिवर्सल प्रोटोकॉल प्लगइन कार्यक्रम में प्राप्त, हम एक का उपयोग कर सकते हैंswitchडॉकर पर बुलाए जा रहे विभिन्न एफएमजेड क्वांट एपीआई को वर्गीकृत करने और संभालने के लिए कथन (यानी, पहचानें कि कौन सा एफएमजेड क्वांटAPIडॉकर पर चल रही रणनीति कॉल कर रही है):

उदाहरण मेंGoभाषाः

switch request.Method {    // M of request.Method is capitalized here, the body of the request received by the custom protocol program for the JSON data, in the Go language, the anti-JSON serialization (Unmarshal) is a structure, the first letter of the field must be capitalized
  case "accounts" :        // When the exchange.GetAccount() function is called in the bot strategy on the docker, the docker sends in a request where the Body carries data with a method attribute value of accounts
      data, err = e.GetAccount(symbol)
  case "ticker" :
      data, err = e.GetTicker(symbol)
  case "depth" :
      data, err = e.GetDepth(symbol)
  case "trades" :
      data, err = e.GetTrades(symbol)
  case "trade" :
  ...
  default:
      ...

इन शाखाओं को निष्पादित करने के बाद, लौटाए गए डेटा को उस संरचना में लिखा जाना चाहिए जिसका उपयोग कस्टम प्रोटोकॉल प्लगइन प्रोग्राम डॉकर के अनुरोध का जवाब देने के लिए करेगा.

गो भाषा में उदाहरणः

defer func(){                                // Handling of closing work 
      if e := recover(); e != nil {          // The recover() function is used to catch panic, e ! = nil, i.e. an error has occurred
          if ee, ok := e.(error); ok {       // Type derivation, successful derivation assigns ee.Error() to e
              e = ee.Error()                 // Call the Error method to get the returned error string
          }
          ret = map[string]string{"error": fmt.Sprintf("%v", e)}
      }
      b, _ := json.Marshal(ret)              // Encode the result obtained from this call, ret, assign it to b, and write it into the response pointer
      w.Write(b)
      //fmt.Println("after w.Write the b is", string(b))     // test
  }()

3. एपीआई कॉल के प्रकार

मोटे तौर पर दो श्रेणियों में विभाजितः

  1. सार्वजनिक इंटरफेस जिन्हें हस्ताक्षर की आवश्यकता नहीं होती है, जैसेः

GetTicker()

GetDepth()

GetTrades()

GetRecords(period)

  1. उपयोगकर्ता इंटरफ़ेस जिन्हें हस्ताक्षर करने की आवश्यकता है, जैसेः

Buy, Sell

GetOrder(id)

GetOrders()

GetAccount()

CancelOrder(id)... हस्ताक्षर विधियां विनिमय से विनिमय में भिन्न हो सकती हैं, और आवश्यकताओं के अनुसार विशेष रूप से लिखी जाने की आवश्यकता है।

4. विभिन्न एफएमजेड क्वांट एपीआई इंटरफेस को कॉल करते समय कस्टम प्रोटोकॉल प्लगइन और डॉकर के बीच बातचीत के लिए डेटा प्रारूपः

कुछ FMZ क्वांट एपीआई इंटरफेस, जैसेGetName(), GetLabel(), आदि को अनुरोध नहीं भेजते हैं।कस्टम प्रोटोकॉल प्लगइनजब बुलाया जाता है। कॉल करते समयexchange.GetName(), सार्वभौमिक प्लगइन में कॉन्फ़िगर किया गया एक्सचेंज Exchange लौटाएगा.

    1. GetTicker: वर्तमान टिकर डेटा प्राप्त करने के लिए प्रयोग किया जाता है.

..methodमेंrequestद्वारा भेजा गयाडॉकरसुनने प्रतिक्रिया समारोह के लिए हैticker.

डॉकर पैरामीटर भेजता हैःrequest.Params.symbol, जो डॉकर द्वारा रोबोट के पेज पर सेट मुद्रा के आधार पर भेजा जाता है।

जब डॉकर कस्टम प्रोटोकॉल प्लगइन का अनुरोध करता है तो अनुरोध शरीर में ले जाने वाला डेटा प्रारूप (JSON)

{
    "access_key" : "access_key",
    "secret_key" : "secret_key",
    "nonce" :      "1500793319499",            // millisecond timestamp
    "method" :     "ticker",
    "params" :     {"symbol" : "ETH_BTC"},     // Take the ETH_BTC trading pair for example
}

डॉकर को भेजे जाने वाले अंतिम रिटर्न मान की संरचना: (यानी उस प्रारूप में जिसमें डेटा एक्सचेंज इंटरफेस के बाद कॉमन प्रोटोकॉल प्लग-इन द्वारा अनुरोध किए जाने के बाद डॉकर को लौटाया जाता है)

जेएसओएन संरचना

{
    "data": {
        "time": 1500793319499,  // Millisecond timestamp, integer
        "buy": 1000,            // floating-point type as follows
        "sell": 1001,
        "last": 1005,
        "high": 1100,
        "low": 980,
        "vol": 523,
    }
}
    1. GetRecords: एक्सचेंज द्वारा प्रदान किए गए K-लाइन डेटा को पुनर्प्राप्त करने के लिए उपयोग किया जाता है. (डॉकर द्वारा अनुरोधित मापदंडों के आधार पर)

..methodमेंrequestडॉकर द्वारा सुनवाई प्रतिक्रिया समारोह के लिए भेजा जाता हैrecords.

डॉकर पैरामीटर भेजता हैःrequest.Params.period, जो कि पहले पैरामीटर से जुड़ा हुआ हैexchange.GetRecordsकार्य।request.Params.periodमिनटों में अवधि का प्रतिनिधित्व करता है. उदाहरण के लिए, दैनिक अवधि है60*24, जो कि है1440. request.Params.symbolनिर्धारित मुद्रा के आधार पर डॉकर द्वारा भेजा जाता है।

जब डॉकर कस्टम प्रोटोकॉल प्लगइन का अनुरोध करता है तो अनुरोध शरीर में ले जाने वाला डेटा प्रारूप.

{
    "access_key" : "access_key",
    "secret_key" : "secret_key",
    "nonce" :      "1500793319499",            // millisecond timestamp
    "method" :     "records",
    "params" :     {"symbol" : "ETH_BTC", "period" : "1440"},     // Example of an ETH_BTC pair with a daily K-period
}

डॉकर को भेजे गए अंतिम रिटर्न मान की संरचनाः

जेएसओएन संरचना

{
    "data": [
            [1500793319, 1.1, 2.2, 3.3, 4.4, 5.5],         // "Time":1500793319000,"Open":1.1,"High":2.2,"Low":3.3,"Close":4.4,"Volume":5.5
            [1500793259, 1.01, 2.02, 3.03, 4.04, 5.05],
            ...
    ]
}

जा भाषा परीक्षण डेटाः

ret_records = []interface{}{
    [6]interface{}{1500793319, 1.1, 2.2, 3.3, 4.4, 5.5}, 
    [6]interface{}{1500793259, 1.01, 2.02, 3.03, 4.04, 5.05}
}

एफएमजेड क्वांट प्लेटफार्मLogप्रदर्शनrecordsडेटाः

[
    {"Time":1500793319000,"Open":1.1,"High":2.2,"Low":3.3,"Close":4.4,"Volume":5.5},
    {"Time":1500793259000,"Open":1.01,"High":2.02,"Low":3.03,"Close":4.04,"Volume":5.05}
]

नोट: 1. दो आयामी सरणी में पहला तत्व प्रकार का हैintऔर एक टाइमस्टैम्प का प्रतिनिधित्व करता है। 2. डॉकर स्वचालित रूप से टाइमस्टैम्प को 1000 से गुणा करेगा, जैसा कि ऊपर उल्लेख किया गया है।

    1. GetDepth: एक्सचेंज से गहराई की जानकारी (ऑर्डर बुक, ask1, ask2... bid1, bid2...) प्राप्त करता है.

..methodमेंrequestडॉकर द्वारा सुनवाई प्रतिक्रिया समारोह के लिए भेजा जाता हैdepth.

डॉकर पैरामीटर भेजता हैःrequest.Params.symbol, जो रणनीति में निर्धारित मुद्रा के आधार पर डॉकर द्वारा भेजा जाता है।

अनुरोध शरीर में ले जाने वाला डेटा प्रारूप जब डॉकर कस्टम प्रोटोकॉल प्लगइन का अनुरोध करता है

{
    "access_key" : "access_key",
    "secret_key" : "secret_key",
    "nonce" :      "1500793319499",            // millisecond timestamp
    "method" :     "depth",
    "params" :     {"symbol" : "ETH_BTC"},     // Take the ETH_BTC trading pair for example
}

डॉकर को भेजे गए अंतिम रिटर्न मान की संरचनाः

जेएसओएन संरचना

{
    "data" : {
        "time" : 1500793319499,
        "asks" : [ [1000, 0.5], [1001, 0.23], [1004, 2.1], ... ],
        "bids" : [ [999, 0.25], [998, 0.8], [995, 1.4], ... ],
    }
}
    1. GetTrades: एक निश्चित अवधि के भीतर पूरे एक्सचेंज के ट्रेडिंग रिकॉर्ड प्राप्त करें (अपने ट्रेडों को छोड़कर)

..methodमेंrequestडॉकर द्वारा सुनवाई प्रतिक्रिया समारोह को भेजा जाता है:trades.

डॉकर द्वारा भेजे गए पैरामीटर: का मानrequest.Params.symbolव्यापार मुद्रा है, उदाहरण के लिएःbtc, जो रणनीति सेटिंग्स के आधार पर डॉकर द्वारा भेजा जाता है।

कस्टम प्रोटोकॉल प्लगइन का अनुरोध करते समय डॉकर द्वारा ले जाने वाला डेटा प्रारूप निम्नानुसार है

{
    "access_key" : "access_key",
    "secret_key" : "secret_key",
    "nonce" :      "1500793319499",            // millisecond timestamp
    "method" :     "trades",
    "params" :     {"symbol" : "ETH_BTC"},     // Take the ETH_BTC trading pair for example
}

डॉकर को भेजे गए अंतिम रिटर्न मान की संरचनाः

जेएसओएन संरचना

{ 
    "data": [
        {
            "id": 12232153,
            "time" : 1529919412968,
            "price": 1000,
            "amount": 0.5,
            "type": "buy",             // "buy"、"sell"
        },{
            "id": 12545664,
            "time" : 1529919412900,
            "price": 1001,
            "amount": 1,
            "type": "sell",
        },{
            ...
        }
    ]
}
    1. GetAccount: खाता परिसंपत्ति जानकारी प्राप्त करें.

..methodमेंrequestडॉकर द्वारा सुनवाई प्रतिक्रिया समारोह को भेजा जाता है:accounts.

डॉकर द्वारा भेजे गए पैरामीटर: (नोटः आम तौर पर, यह खाते की सभी संपत्ति प्राप्त करने के लिए है! कृपया यह देखने के लिए एक्सचेंज इंटरफ़ेस देखें कि यह व्यक्तिगत संपत्ति या कुल संपत्ति जानकारी प्राप्त करने के लिए है)

कस्टम प्रोटोकॉल प्लगइन का अनुरोध करते समय डॉकर द्वारा ले जाने वाला डेटा प्रारूप निम्नानुसार है

{
    "access_key" : "access_key",
    "secret_key" : "secret_key",
    "nonce" :      "1500793319499",            // millisecond timestamp
    "method" :     "accounts",
    "params" :     {},                         
}

डॉकर को भेजे गए अंतिम रिटर्न मान की संरचनाः

जेएसओएन संरचना

{
    "data": [
        {"currency": "btc", "free": 1.2, "frozen": 0.1},
        {"currency": "ltc", "free": 25, "frozen": 2.1},
        {"currency": "ltc", "free": 25, "frozen": 2.1},
        ...
    ],
    "raw" : {...}             // It is possible to write the raw message (response) returned by the exchange when the plugin accesses the exchange
}
    1. खरीदें, बेचेंः व्यापार के लिए आदेश (बाजार आदेश या सीमा आदेश) दें।

..methodमेंrequestडॉकर द्वारा सुनवाई प्रतिक्रिया समारोह को भेजा जाता है:trade.

डॉकर द्वारा भेजे गए पैरामीटरःrequest.Params.type: डॉकर द्वारा भेजा जाता है कि क्या यह कॉल कर रहा है के आधार परexchange.Buyयाexchange.Sell, request.Params.price: के पहले पैरामीटरAPIरणनीति में बुलाया गया कार्य,request.Params.amount: के दूसरे पैरामीटरAPIरणनीति में बुलाया गया कार्य,request.Params.symbol: निर्धारित व्यापार मुद्रा के आधार पर डॉकर द्वारा भेजा जाता है।

कस्टम प्रोटोकॉल प्लगइन का अनुरोध करते समय डॉकर द्वारा ले जाने वाला डेटा प्रारूप निम्नानुसार है

{
    "access_key" : "access_key",
    "secret_key" : "secret_key",
    "nonce" :      "1500793319499",            // millisecond timestamp
    "method" :     "trade",
    "params" :     {
                       "symbol" : "ETH_BTC", 
                       "type" : "buy", 
                       "price" : "1000", 
                       "amount" : "1"
                   },                          // Example of an ETH_BTC trading pair, "type": "buy" buy request, price 1000, quantity 1
}

डॉकर को भेजे गए अंतिम रिटर्न मान की संरचनाः

जेएसओएन संरचना

{
    "data": {
        "id": 125456,      // Order id returned after placing an order
                           // If the order id is in the form of a string like "asdf346sfasf532"
                           // Here the id can also be a string type
    }
}
    1. GetOrder: ऑर्डर आईडी के अनुसार एक विशिष्ट ऑर्डर की जानकारी प्राप्त करें

..methodमेंrequestडॉकर द्वारा सुनवाई प्रतिक्रिया समारोह को भेजा जाता है:order.

डॉकर द्वारा भेजे गए पैरामीटरःrequest.Params.id, request.Params.symbol.

कस्टम प्रोटोकॉल प्लगइन का अनुरोध करते समय डॉकर द्वारा ले जाने वाला डेटा प्रारूप निम्नानुसार है

{
    "access_key" : "access_key",
    "secret_key" : "secret_key",
    "nonce" :      "1500793319499",            // millisecond timestamp
    "method" :     "order",
    "params" :     {"symbol" : "ETH_BTC", "id" : "XXX"},     // Take the ETH_BTC trading pair and order ID XXX as an example. Please note that some exchanges use numerical order IDs, such as 123456, while others use string order IDs, such as poimd55sdfheqxv. The specific format of the order ID depends on the exchange.
}

डॉकर को भेजे गए अंतिम रिटर्न मान की संरचनाः

जेएसओएन संरचना

{ 
    "data": {
        "id": 2565244,
        "amount": 0.15,
        "price": 1002,
        "status": "open",    // "open": pending, "closed": closed, "canceled": canceled
        "deal_amount": 0,
        "type": "buy",       // "buy"、"sell"
        "avg_price": 0,      // If not provided by the exchange, it can be assigned a value of 0 during processing
    }
}
    1. GetOrders: सभी अधूरे आदेशों के लिए जानकारी प्राप्त करें

..methodमेंrequestडॉकर द्वारा सुनवाई प्रतिक्रिया समारोह के लिए भेजा जाता हैorders.

डॉकर द्वारा भेजे गए पैरामीटरःrequest.Params.symbol

कस्टम प्रोटोकॉल प्लगइन का अनुरोध करते समय डॉकर द्वारा ले जाने वाला डेटा प्रारूप निम्नानुसार है

{
    "access_key" : "access_key",
    "secret_key" : "secret_key",
    "nonce" :      "1500793319499",            // millisecond timestamp
    "method" :     "orders",
    "params" :     {"symbol" : "ETH_BTC"},     // Take the ETH_BTC trading pair for example
}

डॉकर को भेजे गए अंतिम रिटर्न मान की संरचनाः

जेएसओएन संरचना

{
    "data": [{
        "id": 542156,
        "amount": 0.25,
        "price": 1005,
        "deal_amount": 0,
        "type": "buy",      // "buy"、"sell"
        "status": "open",   // "open"
    },{
        ...
    }]
}
    1. CancelOrder: निर्दिष्ट आदेश आईडी के साथ आदेश रद्द करें

..methodमेंrequestडॉकर द्वारा सुनवाई प्रतिक्रिया समारोह के लिए भेजा जाता हैcancel.

डॉकर द्वारा भेजे गए पैरामीटरःrequest.Params.id(स्ट्रिंग प्रकार, रणनीति द्वारा बुलाए गए एपीआई फ़ंक्शन का पहला पैरामीटर),request.Params.symbol(उदाहरण के लिए, बीटीसी, रणनीति द्वारा निर्धारित मुद्रा के आधार पर डॉकर द्वारा भेजा गया)

कस्टम प्रोटोकॉल प्लगइन का अनुरोध करते समय डॉकर द्वारा ले जाने वाला डेटा प्रारूप निम्नानुसार है

{
    "access_key" : "access_key",
    "secret_key" : "secret_key",
    "nonce" :      "1500793319499",            // millisecond timestamp
    "method" :     "cancel",
    "params" :     {"symbol" : "ETH_BTC", "id" : "XXX"},     // Take an ETH_BTC trading pair with an id of "XXX" (same as the GetOrder function's parameter id) for example
}

डॉकर को भेजे गए अंतिम रिटर्न मान की संरचनाः

जेएसओएन संरचना

{
    "data": true,        // true or false
}
    1. आईओ: कॉलexchange.IOएफएमजेड क्वांट प्लेटफॉर्म का कार्य

..methodमेंrequestडॉकर द्वारा सुनवाई प्रतिक्रिया समारोह के लिए भेजा के साथ शुरू होता है_api_.

कस्टम प्रोटोकॉल प्लगइन का अनुरोध करते समय डॉकर द्वारा ले जाने वाला डेटा प्रारूप निम्नानुसार है

{
    "access_key" : "access_key",
    "secret_key" : "secret_key",
    "nonce" :      "1500793319499",            // millisecond timestamp
    "method" :     "__api_XXX",                // XXX is the API interface for the specific exchange (base address not included)
    "params" :     {"borrow_id" : "123", "symbol" : "cny"},      // Specifically, the parameters passed into the IO function
}

डॉकर को भेजे गए अंतिम रिटर्न मान की संरचनाः

{
    "data": {...}       // The return value of a specific interface call
}

उदाहरण के तौर पर, रणनीति कॉल में कहा गया हैः

var io_str = exchange.IO("api", "POST", "cancel_borrow", "symbol=cny&borrow_id=123")

प्लगइन में परीक्षण कोड (जाओ भाषा):

fmt.Println("request.Method:", request.Method, "request.Params:", request.Params)

प्लगइन कमांड लाइनः 2017/08/31 10:19:59 दौड़ रहा हैhttp://127.0.0.1:6666/DigitalAsset

प्लगइन कमांड लाइन प्रिंटआउट काः request.Method, request.Paramsडॉकर द्वारा भेजे गए अनुरोध शरीर में, अनुरोध में पार्स किए गए डेटा निम्नानुसार हैं:request.Methodहै__api_cancel_borrow request.Paramsहै{"borrow_id" : "123", "symbol" : "cny"}

आप इन के हैंडलिंग अनुकूलित कर सकते हैंexchange.IOकॉल जो सीधे एक्सचेंज का उपयोग करते हैंAPI.

# Attention:
# When calling exchange.IO("api", "POST", "/api/v1/getAccount", "symbol=BTC_USDT"), 
# If the second parameter is not POST but: exchange.IO("api", "GET", "/api/v1/getAccount", "symbol=BTC_USDT")
# is the GET method, which is then stored in the header Http-Method in the http request accepted by the custom protocol plugin.
# So you need to refer to the following sample code for the custom protocol handling IO function implementation:
// tapiCall function definition
func (p *iStocksExchange) tapiCall(method string, params map[string]string, httpType string) (js *Json, err error) {
    ...
}

// In the OnPost function
if strings.HasPrefix(request.Method, "__api_") {
    var js *Json
    js, err = e.tapiCall(request.Method[6:], request.Params, r.Header.Get("Http-Method"))
    ...
}
  • विनिमय के लिए समर्थन.GetRawJSON:

अंतर्निहित प्रणाली स्वचालित रूप से कॉल को संभालती हैexchange.GetRawJSON, तो प्लगइन में इसे लागू करने की कोई जरूरत नहीं है.

  • विनिमय के लिए समर्थन.जाओ:

अंतर्निहित प्रणाली स्वचालित रूप से कॉल को संभालती हैexchange.Go, तो वहाँ प्लगइन में इसे संभालने के लिए कोई जरूरत नहीं है.

var beginTime = new Date().getTime()
var ret = exchange.Go("GetDepth")
var endTime = new Date().getTime()
Log(endTime - beginTime, "#FF0000")

// Sleep(2000)
beginTime = new Date().getTime()
Log(exchange.GetTicker())
endTime = new Date().getTime()
Log(endTime - beginTime, "#FF0000")
var depth = ret.wait()
Log("depth:", depth)

img

img

# Note: If you specify a timeout when waiting using exchange. 
#      Always make sure to obtain the final data so that the concurrent threads of the application can be reclaimed.
  • फ्यूचर्स फंक्शंस के लिए समर्थनः

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

जब रणनीति में निम्नलिखित कार्यों को बुलाया जाता है, तोRpcप्लगइन कार्यक्रम द्वारा प्राप्त अनुरोध अन्य इंटरफेस से थोड़ा अलग है. आप के प्रारूप पर ध्यान देने की जरूरत हैRpcRequestकस्टम प्रोटोकॉल प्लगइन प्रोग्राम में. मुख्य अंतर यह है कि पैराम्स का मूल्य एक यौगिक संरचना है.

SetContractType अनुबंध कोड सेट करें।

{"access_key":"123","method":"io","nonce":1623307269528738000,"params":{"args":["quarter"],"code":2},"secret_key":"123"}

दिशा सेट करें वायदा आदेशों के लिए दिशा निर्धारित करता है।

{"access_key":"123","method":"io","nonce":1623308734966484000,"params":{"args":["closesell"],"code":1},"secret_key":"123"}

सीमा स्तर सेट करें वायदा लीवरेज सेट करता है।

{"access_key":"123","method":"io","nonce":1623308734966939000,"params":{"args":[12],"code":0},"secret_key":"123"}

स्थिति प्राप्त करें वायदा स्थिति प्राप्त करें। कबexchange.GetPosition()कहा जाता है:

{"access_key":"123","method":"io","nonce":1623308734967442000,"params":{"args":[],"code":3},"secret_key":"123"}

कबexchange.GetPosition("swap")कहा जाता है:

{"access_key":"123","method":"io","nonce":1623308734967442000,"params":{"args":["swap"],"code":3},"secret_key":"123"}
  • कस्टम प्रोटोकॉल प्लगइन (बिटगो एक्सचेंज तक पहुँच) का पूर्ण गो भाषा उदाहरण
/*
GOOS=linux GOARCH=amd64 go build -ldflags '-s -w -extldflags -static' rest_bitgo.go
*/
package main

import (
    "bytes"
    "crypto/md5"
    "encoding/hex"
    "encoding/json"
    "errors"
    "flag"
    "fmt"
    "io/ioutil"
    "log"
    "net/http"
    "net/url"
    "sort"
    "strconv"
    "strings"
    "time"
)

func toFloat(s interface{}) float64 {
    var ret float64
    switch v := s.(type) {
    case float64:
        ret = v
    case float32:
        ret = float64(v)
    case int64:
        ret = float64(v)
    case int:
        ret = float64(v)
    case int32:
        ret = float64(v)
    case string:
        ret, _ = strconv.ParseFloat(strings.TrimSpace(v), 64)
    }
    return ret
}

func float2str(i float64) string {
    return strconv.FormatFloat(i, 'f', -1, 64)
}

func toInt64(s interface{}) int64 {
    var ret int64
    switch v := s.(type) {
    case int:
        ret = int64(v)
    case float64:
        ret = int64(v)
    case bool:
        if v {
            ret = 1
        } else {
            ret = 0
        }
    case int64:
        ret = v
    case string:
        ret, _ = strconv.ParseInt(strings.TrimSpace(v), 10, 64)
    }
    return ret
}

func toString(s interface{}) string {
    var ret string
    switch v := s.(type) {
    case string:
        ret = v
    case int64:
        ret = strconv.FormatInt(v, 10)
    case float64:
        ret = strconv.FormatFloat(v, 'f', -1, 64)
    case bool:
        ret = strconv.FormatBool(v)
    default:
        ret = fmt.Sprintf("%v", s)
    }
    return ret
}

type Json struct {
    data interface{}
}

func NewJson(body []byte) (*Json, error) {
    j := new(Json)
    err := j.UnmarshalJSON(body)
    if err != nil {
        return nil, err
    }
    return j, nil
}

func (j *Json) UnmarshalJSON(p []byte) error {
    return json.Unmarshal(p, &j.data)
}

func (j *Json) Get(key string) *Json {
    m, err := j.Map()
    if err == nil {
        if val, ok := m[key]; ok {
            return &Json{val}
        }
    }
    return &Json{nil}
}

func (j *Json) CheckGet(key string) (*Json, bool) {
    m, err := j.Map()
    if err == nil {
        if val, ok := m[key]; ok {
            return &Json{val}, true
        }
    }
    return nil, false
}

func (j *Json) Map() (map[string]interface{}, error) {
    if m, ok := (j.data).(map[string]interface{}); ok {
        return m, nil
    }
    return nil, errors.New("type assertion to map[string]interface{} failed")
}

func (j *Json) Array() ([]interface{}, error) {
    if a, ok := (j.data).([]interface{}); ok {
        return a, nil
    }
    return nil, errors.New("type assertion to []interface{} failed")
}

func (j *Json) Bool() (bool, error) {
    if s, ok := (j.data).(bool); ok {
        return s, nil
    }
    return false, errors.New("type assertion to bool failed")
}

func (j *Json) String() (string, error) {
    if s, ok := (j.data).(string); ok {
        return s, nil
    }
    return "", errors.New("type assertion to string failed")
}

func (j *Json) Bytes() ([]byte, error) {
    if s, ok := (j.data).(string); ok {
        return []byte(s), nil
    }
    return nil, errors.New("type assertion to []byte failed")
}

func (j *Json) Int() (int, error) {
    if f, ok := (j.data).(float64); ok {
        return int(f), nil
    }

    return -1, errors.New("type assertion to float64 failed")
}

func (j *Json) MustArray(args ...[]interface{}) []interface{} {
    var def []interface{}

    switch len(args) {
    case 0:
    case 1:
        def = args[0]
    default:
        log.Panicf("MustArray() received too many arguments %d", len(args))
    }

    a, err := j.Array()
    if err == nil {
        return a
    }

    return def
}

func (j *Json) MustMap(args ...map[string]interface{}) map[string]interface{} {
    var def map[string]interface{}

    switch len(args) {
    case 0:
    case 1:
        def = args[0]
    default:
        log.Panicf("MustMap() received too many arguments %d", len(args))
    }

    a, err := j.Map()
    if err == nil {
        return a
    }

    return def
}

func (j *Json) MustString(args ...string) string {
    var def string

    switch len(args) {
    case 0:
    case 1:
        def = args[0]
    default:
        log.Panicf("MustString() received too many arguments %d", len(args))
    }

    s, err := j.String()
    if err == nil {
        return s
    }

    return def
}

func (j *Json) MustInt64() int64 {
    var ret int64
    var err error
    switch v := j.data.(type) {
    case int:
        ret = int64(v)
    case int64:
        ret = v
    case float64:
        ret = int64(v)
    case string:
        if ret, err = strconv.ParseInt(v, 10, 64); err != nil {
            panic(err)
        }
    default:
        ret = 0
        //panic("type assertion to int64 failed")
    }
    return ret
}

func (j *Json) MustFloat64() float64 {
    var ret float64
    var err error
    switch v := j.data.(type) {
    case int:
        ret = float64(v)
    case int64:
        ret = float64(v)
    case float64:
        ret = v
    case string:
        v = strings.Replace(v, ",", "", -1)
        if ret, err = strconv.ParseFloat(v, 64); err != nil {
            panic(err)
        }
    default:
        ret = 0
        //panic("type assertion to float64 failed")
    }
    return ret
}

type iBitgo struct {
    accessKey     string
    secretKey     string
    currency      string
    opCurrency    string
    baseCurrency  string
    secret        string
    secretExpires int64
    apiBase       string
    step          int64
    newRate       float64
    timeout       time.Duration
    timeLocation  *time.Location
}

type MapSorter []Item

type Item struct {
    Key string
    Val string
}

func NewMapSorter(m map[string]string) MapSorter {
    ms := make(MapSorter, 0, len(m))

    for k, v := range m {
        if strings.HasPrefix(k, "!") {
            k = strings.Replace(k, "!", "", -1)
        }
        ms = append(ms, Item{k, v})
    }

    return ms
}

func (ms MapSorter) Len() int {
    return len(ms)
}

func (ms MapSorter) Less(i, j int) bool {
    //return ms[i].Val < ms[j].Val // Sort by value
    return ms[i].Key < ms[j].Key // Sort by key
}

func (ms MapSorter) Swap(i, j int) {
    ms[i], ms[j] = ms[j], ms[i]
}

func encodeParams(params map[string]string, escape bool) string {
    ms := NewMapSorter(params)
    sort.Sort(ms)

    v := url.Values{}
    for _, item := range ms {
        v.Add(item.Key, item.Val)
    }
    if escape {
        return v.Encode()
    }
    var buf bytes.Buffer
    keys := make([]string, 0, len(v))
    for k := range v {
        keys = append(keys, k)
    }
    sort.Strings(keys)
    for _, k := range keys {
        vs := v[k]
        prefix := k + "="
        for _, v := range vs {
            if buf.Len() > 0 {
                buf.WriteByte('&')
            }
            buf.WriteString(prefix)
            buf.WriteString(v)
        }
    }
    return buf.String()
}

func newBitgo(accessKey, secretKey string) *iBitgo {
    s := new(iBitgo)
    s.accessKey = accessKey
    s.secretKey = secretKey
    s.apiBase = "https://www.bitgo.cn"
    s.timeout = 20 * time.Second
    s.timeLocation = time.FixedZone("Asia/Shanghai", 8*60*60)

    return s
}

func (p *iBitgo) apiCall(method string) (*Json, error) {
    req, err := http.NewRequest("POST", fmt.Sprintf("%s/appApi.html?%s", p.apiBase, method), nil)
    if err != nil {
        return nil, err
    }
    req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        return nil, err
    }
    defer resp.Body.Close()
    b, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        return nil, err
    }
    return NewJson(b)
}

func (p *iBitgo) GetTicker(symbol string) (ticker interface{}, err error) {
    var js *Json
    js, err = p.apiCall("action=market&symbol=" + symbol)
    if err != nil {
        return
    }
    dic := js.Get("data")
    ticker = map[string]interface{}{
        "time": js.Get("time").MustInt64(),
        "buy":  dic.Get("buy").MustFloat64(),
        "sell": dic.Get("sell").MustFloat64(),
        "last": dic.Get("last").MustFloat64(),
        "high": dic.Get("high").MustFloat64(),
        "low":  dic.Get("low").MustFloat64(),
        "vol":  dic.Get("vol").MustFloat64(),
    }
    return
}

func (p *iBitgo) GetDepth(symbol string) (depth interface{}, err error) {
    var js *Json
    js, err = p.apiCall("action=depth&symbol=" + symbol)
    if err != nil {
        return
    }
    dic := js.Get("data")

    asks := [][2]float64{}
    bids := [][2]float64{}

    for _, pair := range dic.Get("asks").MustArray() {
        arr := pair.([]interface{})
        asks = append(asks, [2]float64{toFloat(arr[0]), toFloat(arr[1])})
    }

    for _, pair := range dic.Get("bids").MustArray() {
        arr := pair.([]interface{})
        bids = append(bids, [2]float64{toFloat(arr[0]), toFloat(arr[1])})
    }
    depth = map[string]interface{}{
        "time": js.Get("time").MustInt64(),
        "asks": asks,
        "bids": bids,
    }
    return
}

func (p *iBitgo) GetTrades(symbol string) (trades interface{}, err error) {
    var js *Json
    js, err = p.apiCall("action=trades&symbol=" + symbol)
    if err != nil {
        return
    }
    dic := js.Get("data")
    items := []map[string]interface{}{}
    for _, pair := range dic.MustArray() {
        item := map[string]interface{}{}
        arr := pair.(map[string]interface{})
        item["id"] = toInt64(arr["id"])
        item["price"] = toFloat(arr["price"])
        item["amount"] = toFloat(arr["amount"])
        // trade.Time = toInt64(arr["time"]) * 1000
        if toString(arr["en_type"]) == "bid" {
            item["type"] = "buy"
        } else {
            item["type"] = "sell"
        }
        items = append(items, item)
    }
    trades = items
    return
}

func (p *iBitgo) GetRecords(step int64, symbol string) (records interface{}, err error) {
    var js *Json
    js, err = p.apiCall(fmt.Sprintf("action=kline&symbol=%s&step=%d", symbol, step*60))
    if err != nil {
        return
    }
    items := []interface{}{}
    for _, pair := range js.Get("data").MustArray() {
        arr := pair.([]interface{})
        if len(arr) < 6 {
            err = errors.New("response format error")
            return
        }
        item := [6]interface{}{}
        item[0] = toInt64(arr[0])
        item[1] = toFloat(arr[1])
        item[2] = toFloat(arr[2])
        item[3] = toFloat(arr[3])
        item[4] = toFloat(arr[4])
        item[5] = toFloat(arr[5])

        items = append(items, item)
    }
    records = items
    return
}

func (p *iBitgo) tapiCall(method string, params map[string]string) (js *Json, err error) {
    if params == nil {
        params = map[string]string{}
    }
    params["api_key"] = p.accessKey
    h := md5.New()
    h.Write([]byte(encodeParams(params, false) + "&secret_key=" + p.secretKey))
    params["sign"] = strings.ToUpper(hex.EncodeToString(h.Sum(nil)))
    params["action"] = method
    qs := encodeParams(params, false)

    req, err := http.NewRequest("POST", fmt.Sprintf("%s/appApi.html?%s", p.apiBase, qs), nil)
    if err != nil {
        return nil, err
    }
    req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        return nil, err
    }
    defer resp.Body.Close()
    b, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        return nil, err
    }
    js, err = NewJson(b)
    if js != nil {
        if code := js.Get("code").MustInt64(); code != 200 {
            s := js.Get("msg").MustString()
            if s == "" {
                s = fmt.Sprintf("%v", toString(js.data))
            }
            return nil, errors.New(s)
        }
    }
    return js, err
}

func (p *iBitgo) GetAccount(symbol string) (account interface{}, err error) {
    var js *Json
    js, err = p.tapiCall("userinfo", nil)
    if err != nil {
        return
    }
    mp := js.Get("data")
    assets := map[string]map[string]interface{}{}
    for k := range mp.MustMap() {
        dic := mp.Get(k)
        if k == "free" {
            for c := range dic.MustMap() {
                if _, ok := assets[c]; !ok {
                    assets[c] = map[string]interface{}{}
                }
                assets[c]["currency"] = c
                assets[c]["free"] = dic.Get(c).MustFloat64()
            }
        } else if k == "frozen" {
            for c := range dic.MustMap() {
                if _, ok := assets[c]; !ok {
                    assets[c] = map[string]interface{}{}
                }
                assets[c]["currency"] = c
                assets[c]["frozen"] = dic.Get(c).MustFloat64()
            }
        }
    }
    accounts := []map[string]interface{}{}
    for _, pair := range assets {
        accounts = append(accounts, pair)
    }

    account = accounts
    return
}

func (p *iBitgo) Trade(side string, price, amount float64, symbol string) (orderId interface{}, err error) {
    var js *Json
    js, err = p.tapiCall("trade", map[string]string{
        "symbol": symbol,
        "type":   side,
        "price":  float2str(price),
        "amount": float2str(amount),
    })
    if err != nil {
        return
    }
    orderId = map[string]int64{"id": js.Get("orderId").MustInt64()}
    return
}

func (p *iBitgo) GetOrders(symbol string) (orders interface{}, err error) {
    var js *Json
    js, err = p.tapiCall("entrust", map[string]string{"symbol": symbol})
    if err != nil {
        return
    }
    items := []map[string]interface{}{}
    for _, ele := range js.Get("data").MustArray() {
        mp := ele.(map[string]interface{})
        item := map[string]interface{}{}
        item["id"] = toInt64(mp["id"])
        item["amount"] = toFloat(mp["count"])
        if _, ok := mp["prize"]; ok {
            item["price"] = toFloat(mp["prize"])
        } else {
            item["price"] = toFloat(mp["price"])
        }
        item["deal_amount"] = toFloat(mp["success_count"])

        if toInt64(mp["type"]) == 0 {
            item["type"] = "buy"
        } else {
            item["type"] = "sell"
        }
        item["status"] = "open"
        items = append(items, item)
    }
    return items, nil
}

func (p *iBitgo) GetOrder(orderId int64, symbol string) (order interface{}, err error) {
    var js *Json
    js, err = p.tapiCall("order", map[string]string{"id": toString(orderId)})
    if err != nil {
        return
    }

    found := false
    item := map[string]interface{}{}
    for _, ele := range js.Get("data").MustArray() {
        mp := ele.(map[string]interface{})
        if toInt64(mp["id"]) != orderId {
            continue
        }
        item["id"] = toInt64(mp["id"])
        item["amount"] = toFloat(mp["count"])
        if _, ok := mp["prize"]; ok {
            item["price"] = toFloat(mp["prize"])
        } else {
            item["price"] = toFloat(mp["price"])
        }
        item["deal_amount"] = toFloat(mp["success_count"])

        if toInt64(mp["type"]) == 0 {
            item["type"] = "buy"
        } else {
            item["type"] = "sell"
        }
        switch toInt64(mp["status"]) {
        case 1, 2:
            item["status"] = "open"
        case 3:
            item["status"] = "closed"
        case 4:
            item["status"] = "cancelled"
        }
        found = true
        break
    }
    if !found {
        return nil, errors.New("order not found")
    }
    return item, nil
}

func (p *iBitgo) CancelOrder(orderId int64, symbol string) (ret bool, err error) {
    _, err = p.tapiCall("cancel_entrust", map[string]string{"id": strconv.FormatInt(orderId, 10)})
    if err != nil {
        return
    }
    ret = true
    return
}

type RpcRequest struct {        // The fields in a struct must start with an uppercase letter, otherwise they cannot be parsed correctly. Structs can have exported and unexported fields, where fields starting with an uppercase letter are considered exported.
                                // During unmarshaling, the JSON tag of a struct is used to match and find the corresponding field. Therefore, modifiers are required in this case.
    AccessKey string            `json:"access_key"`
    SecretKey string            `json:"secret_key"`
    Nonce     int64             `json:"nonce"`
    Method    string            `json:"method"`
    Params    map[string]string `json:"params"`
}

func OnPost(w http.ResponseWriter, r *http.Request) {
    var ret interface{}
    defer func() {
        if e := recover(); e != nil {
            if ee, ok := e.(error); ok {
                e = ee.Error()
            }
            ret = map[string]string{"error": fmt.Sprintf("%v", e)}
        }
        b, _ := json.Marshal(ret)
        w.Write(b)
    }()

    b, err := ioutil.ReadAll(r.Body)
    if err != nil {
        panic(err)
    }
    var request RpcRequest
    err = json.Unmarshal(b, &request)
    if err != nil {
        panic(err)
    }
    e := newBitgo(request.AccessKey, request.SecretKey)
    symbol := request.Params["symbol"]
    if s := request.Params["access_key"]; len(s) > 0 {
        e.accessKey = s
    }
    if s := request.Params["secret_key"]; len(s) > 0 {
        e.secretKey = s
    }
    if symbolIdx, ok := map[string]int{
        "btc":  1,
        "ltc":  2,
        "etp":  3,
        "eth":  4,
        "etc":  5,
        "doge": 6,
        "bec":  7,
    }[strings.Replace(strings.ToLower(symbol), "_cny", "", -1)]; ok {
        symbol = toString(symbolIdx)
    }
    var data interface{}
    switch request.Method {
    case "ticker":
        data, err = e.GetTicker(symbol)
    case "depth":
        data, err = e.GetDepth(symbol)
    case "trades":
        data, err = e.GetTrades(symbol)
    case "records":
        data, err = e.GetRecords(toInt64(request.Params["period"]), symbol)
    case "accounts":
        data, err = e.GetAccount(symbol)
    case "trade":
        side := request.Params["type"]
        if side == "buy" {
            side = "0"
        } else {
            side = "1"
        }
        price := toFloat(request.Params["price"])
        amount := toFloat(request.Params["amount"])
        data, err = e.Trade(side, price, amount, symbol)
    case "orders":
        data, err = e.GetOrders(symbol)
    case "order":
        data, err = e.GetOrder(toInt64(request.Params["id"]), symbol)
    case "cancel":
        data, err = e.CancelOrder(toInt64(request.Params["id"]), symbol)
    default:
        if strings.HasPrefix(request.Method, "__api_") {
            data, err = e.tapiCall(request.Method[6:], request.Params)
        } else {
            panic(errors.New(request.Method + " not support"))
        }
    }
    if err != nil {
        panic(err)
    }
    ret = map[string]interface{}{
        "data": data,
    }

    return
}

func main() {
    var addr = flag.String("b", "127.0.0.1:6666", "bind addr")
    flag.Parse()
    if *addr == "" {
        flag.Usage()
        return
    }
    basePath := "/exchange"
    log.Println("Running ", fmt.Sprintf("http://%s%s", *addr, basePath), "...")
    http.HandleFunc(basePath, OnPost)
    http.ListenAndServe(*addr, nil)
}

अधिक