| |
|
| |
|
| |
|
| |
|
| |
|
| | #property copyright "Antigravity"
|
| | #property link ""
|
| | #property version "1.00"
|
| |
|
| |
|
| | #include <Zmq/Zmq.mqh>
|
| |
|
| |
|
| | input string InpBindAddress = "tcp://0.0.0.0:5555";
|
| |
|
| | CZmq *g_publisher;
|
| |
|
| |
|
| |
|
| |
|
| | int OnInit()
|
| | {
|
| | Print("Initializing ZmqPublisher...");
|
| |
|
| | g_publisher = new CZmq();
|
| |
|
| | if(!g_publisher.Init(ZMQ_PUB)) {
|
| | Print("Failed to initialize ZMQ Publisher");
|
| | return(INIT_FAILED);
|
| | }
|
| |
|
| | if(!g_publisher.Bind(InpBindAddress)) {
|
| | Print("Failed to bind to ", InpBindAddress);
|
| | return(INIT_FAILED);
|
| | }
|
| |
|
| | Print("ZmqPublisher bound to ", InpBindAddress);
|
| | return(INIT_SUCCEEDED);
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| | void OnDeinit(const int reason)
|
| | {
|
| | Print("Deinitializing ZmqPublisher...");
|
| | if(g_publisher != NULL) {
|
| | g_publisher.Shutdown();
|
| | delete g_publisher;
|
| | g_publisher = NULL;
|
| | }
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| | void OnTick()
|
| | {
|
| | if(g_publisher == NULL) return;
|
| |
|
| | MqlTick tick;
|
| | if(SymbolInfoTick(_Symbol, tick)) {
|
| |
|
| |
|
| |
|
| | string json;
|
| | StringConcatenate(json, "{\"symbol\":\"", _Symbol,
|
| | "\",\"bid\":", DoubleToString(tick.bid, _Digits),
|
| | ",\"ask\":", DoubleToString(tick.ask, _Digits),
|
| | ",\"time\":", IntegerToString(tick.time),
|
| | "}");
|
| |
|
| | g_publisher.Send(json);
|
| |
|
| | }
|
| | }
|
| |
|
| |
|