darwinex / dwx-zeromq-connector

Wrapper library for algorithmic trading in Python 3, providing DMA/STP access to Darwinex liquidity via a ZeroMQ-enabled MetaTrader Bridge EA.
https://blog.darwinex.com/zeromq-interface-python-r-metatrader4/
BSD 3-Clause "New" or "Revised" License
346 stars 228 forks source link

How can I change the port defined in DWX_ZeroMQ_Connector() #108

Closed ZixiSu closed 3 years ago

ZixiSu commented 3 years ago

class DWX_ZeroMQ_Connector():

"""
Setup ZeroMQ -> MetaTrader Connector
"""
def __init__(self, 
             _ClientID='dwx-zeromq',    # Unique ID for this client
             _host='localhost',         # Host to connect to
             _protocol='tcp',           # Connection protocol
             _PUSH_PORT=32778,          # Port for Sending commands
             _PULL_PORT=32779,          # Port for Receiving responses
             _SUB_PORT=32771,           # Port for Subscribing for prices
             _delimiter=';',
             _pulldata_handlers = [],   # Handlers to process data received through PULL port.
             _subdata_handlers = [],    # Handlers to process data received through SUB port.
             _verbose=True,             # String delimiter
             _poll_timeout=1000,        # ZMQ Poller Timeout (ms)
             _sleep_delay=0.001,        # 1 ms for time.sleep()
             _monitor=False):           # Experimental ZeroMQ Socket Monitoring

In class DWX_ZeroMQ_Connector(), can we change the _PUSH_PORT = 32778 to 32768?

elvinex commented 3 years ago

Hi,

It should work if you also change the port number in the parameters of the MT4 EA so that both are referring to the same ports.

ZixiSu commented 3 years ago

Hi,

It should work if you also change the port number in the parameters of the MT4 EA so that both are referring to the same ports.

May I ask what the port number range I can use? a random number? like32555?

elvinex commented 3 years ago

You can use netstat -ab in windows powershell to see used ports. Most ports above 10,000 should be fine.