Sunday, July 6, 2025
Homeการซื้อขายการตรวจสอบการแลกเปลี่ยน crypto หลายรายการออนไลน์ผ่านห้องสมุด MQL5 สำหรับ node.js/ccxt - อื่น ๆ - 5 กรกฎาคม...

การตรวจสอบการแลกเปลี่ยน crypto หลายรายการออนไลน์ผ่านห้องสมุด MQL5 สำหรับ node.js/ccxt – อื่น ๆ – 5 กรกฎาคม 2025


ccxtappserverlib มีไว้สำหรับการทำงานกับการแลกเปลี่ยน crypto ทั้งหมด 100 อันดับจาก MQL5 ผ่าน Node.js และ เซิร์ฟเวอร์แอปพลิเคชัน CCXTและมันกำลังพัฒนาทีละขั้นตอน รุ่นเบต้าล่าสุดรวมถึงการแคชที่ได้รับการปรับปรุงให้ดีที่สุดของการแลกเปลี่ยน “ตลาด” (ข้อกำหนดของเครื่องมือและเงื่อนไขการซื้อขายอื่น ๆ ) การอ่านข้อความ WebSocket ที่ไม่ปิดกั้นและอื่น ๆ
ตัวอย่างเบื้องต้นของการใช้ห้องสมุด – สคริปต์ ccxtappsrvshowcase.mq5 – เคยเป็น โพสต์ในบล็อก ก่อนหน้านี้.
เป็นอีกตัวอย่างหนึ่งของการพัฒนาแอปพลิเคชันที่กำหนดเองโดยใช้ไลบรารีเราให้สคริปต์สำหรับการตรวจสอบแบบขนานของการแลกเปลี่ยนหลายรายการสำหรับประเภทของข้อมูลที่เลือก คุณสมบัตินี้ถูกนำไปใช้โดยการสมัครผ่าน CCXT บน node.js ไปยัง websocket “นาฬิกา” เฉพาะเช่น WatchOrderBookผู้เฝ้าดูWatchTradesฯลฯ สำหรับรายละเอียดโปรดดูทั่วไป เอกสาร CCXT และก้าวหน้ามากขึ้น CCXT Professional– เนื่องจากสคริปต์ควรจะใช้เฉพาะ API สาธารณะข้อมูลประจำตัวของผู้ใช้ไม่ได้เกี่ยวข้องที่นี่ แต่ห้องสมุดสนับสนุนพวกเขาในระดับเต็ม

นี่คือส่วนที่สำคัญที่สุดของการสาธิตสคริปต์ใหม่ multiexchangewatch.mq5 (มีให้พร้อมกับรุ่นเบต้าของห้องสมุด)

NB: หากสคริปต์กำลังทำงานเป็นครั้งแรกมันจะขอให้แกะแอปพลิเคชันเซิร์ฟเวอร์ CCXT (ด้วยตนเอง) (แยกเป็น CCXTAppSrvBundle.jsc จากทรัพยากรในตัว) และเรียกใช้ node.js ด้วย

ก่อนอื่นให้รวมส่วนหัว

#embody "ccxtjsmtlib.mqh" 
#embody "ccxtutil.mqh"
#embody <MQL5Book/Feedback.mqh>

ในอินพุตควรตั้งค่าเซิร์ฟเวอร์โหนด

enter group "Connection settings"
enter string NodeServer = "http://127.0.0.1:8124";
enter string NodeAuth = ""; 

จากนั้นระบุจำนวนการแลกเปลี่ยนที่คุณต้องการตรวจสอบทัศนคติและนาฬิกาประเภทหนึ่ง โดยค่าเริ่มต้นสคริปต์จะดูหนังสือสั่งซื้อสำหรับ BCH/USDT

ในการเติมอินพุตเหล่านี้อย่างถูกต้องด้วยค่าที่ต้องการคุณอาจต้องส่งออกรายการการแลกเปลี่ยนที่รองรับและตลาดของพวกเขาล่วงหน้า สามารถดูได้ในสคริปต์ตัวอย่างอื่น ccxtappsrvshowcase.mq5ให้มาพร้อมกับ lib

enter string Exchanges = "ascendex,bitmart,binance"; 
enter string Ticker = "BCH/USDT";
enter string Watch = "watchOrderBook";
enter uint WatchingDuration = 10; 

แล้ว เริ่มต้น ตัวจัดการเหตุการณ์ทำงานได้ ความคิดเห็นแบบอินไลน์อธิบายกระบวนการ ฟังก์ชั่นการนำเข้าคลาสและวิธีการจากไลบรารีจะถูกเน้นเป็นสีเหลือง

string Trade();

void OnStart()
{
   
   
   
   PrintFormat("CCXT AppSrvLibrary model: %.2f", AppSrvLibraryVersion());
   const static string standing() = {"Cannot deploy",
      "App server ZIP is deployed, however not extracted",
      "App server information are deployed"};
   const int d = DeployCcxtAppServer();
   Print(standing(d + 1));
   if(d <= 0)
   {
      return; 
   }
   
   
   
   
   SetNodeServer(NodeServer, NodeAuth);

   CcxtLink *hyperlink = GetLink();
   
   
   

   
   
   AutoPtr<CcxtJsExchangeProIntf> ccxt();
   const int n = StringSplit(Exchanges, ',', Trade);
   ArrayResize(ccxt, n);
   
   for(int i = 0; i < n; i++)
   {
      ccxt(i) = CreateExchangePro(Trade(i)); 

      if(hyperlink.getLastHttpCode() != 200 || !ccxt(i)() || ccxt(i)()().t >= JS_NULL)
      {
         Print("Building failed for change: ", Trade(i));
         return;
      }
      
      const bool isPro = !!*ccxt(i)()("professional"); 
      
      if(!isPro)
      {
         PrintFormat("WARNING! %s is not PRO, there isn't any websocket help", Trade(i));
      }
      
      if(!ccxt(i)()("has")(Watch).get<bool>())
      {
         PrintFormat("WARNING! %s doesn't help '%s' subscriptions", Trade(i), Watch);
      }
   }
   
   
   
   int lively = 0;
   
   for(int i = 0; i < n; i++)
   {
      
      if(ccxt(i)().improve())
      {
         if(!ccxt(i)().watchAnything(StringFormat("%s("%s")", Watch, Ticker)))
         {
            PrintFormat("Cannot begin %s for %s", Watch, Trade(i));
            ccxt(i)().shut(); 
            ccxt(i) = NULL;
         }
         else
         {
            lively++;
         }
      }
      else
      {
         if(ccxt(i)().isConnected())
         {
            Print("Cannot improve to websockets");
            string headers()(2);
            if(ccxt(i)().ws().getHeaders(headers))
            {
               
            }
            ccxt(i)().ws().shut(); 
            ccxt(i)().shut();
            ccxt(i) = NULL;
         }
      }
   }
   
   if(!lively) return;

   
   PrintFormat("* Monitoring %d subscriptions", lively);

   const uint begin = GetTickCount();
   whereas(!IsStopped() && (!WatchingDuration || GetTickCount() - begin < WatchingDuration * 1000))
   {
      for(int i = 0; i < n; i++)
      {
         if(ccxt(i)() && ccxt(i)().isConnected())
         {
            AutoPtr<JsValue> j = ccxt(i)().readMessage(false); 
            if(j())
            {
               ChronoComment(j().stringify(0, 0)); 
            }
         }
      }
   }
  
   Print("* Unsubscribing...");
   for(int i = 0; i < n; i++)
   {
      if(ccxt(i)() && ccxt(i)().isConnected())
      {
         ccxt(i)().un().watchAnything(StringFormat("%s("%s")", Watch, Ticker));
      }
   }
   
   
   GracefullClose(ccxt); // not introduced right here within the weblog

   
   
   GracefullClose(ccxt, 5, true);
   
   Remark("");
}

เมื่อสคริปต์กำลังทำงานรายการหนังสือคำสั่งซื้อขาเข้า (JSON-Messages) จะถูกส่งออกและอัปเดตอย่างแข็งขันในแผนภูมิ

CCXT หลายนาฬิกาในการแลกเปลี่ยน crypto ที่แตกต่างกันใน Metatrader 5

ด้านบนของ dataflow นั้นง่ายต่อการใช้กลยุทธ์การเก็งกำไรที่หลากหลายและคำนวณสถิติรวม

(tagstotranslate) Trade (T) Crypto (T) Demo (T) Library (T) Script (T) CCXT (T) Node.js

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

ความเห็นล่าสุด