fxmanager.dwx package

Package contents

This sub-package contains a modified version of Darwinex ZeroMQ connector which is used for connecting client code to MT4 trading platform.

Public Modules:
  • prices_subscription : This is a modified version of an example of using the Darwinex ZeroMQ Connector for Python 3 and MT4 PULL REQUEST.

  • rates_historic : This Module is used as an API to get historic data from the MT4 EA.

fxmanager.dwx.prices_subscriptions module

This is a modified version of an example of using the Darwinex ZeroMQ Connector for Python 3 and MetaTrader 4 PULL REQUEST.

The original example is referenced here, This Module is used as an API to get real time data from the MT4 EA. The user creates a ‘prices_subscriptions’ object with the desired symbols list in the client applicaction, then the real-time price feed can be accessed from the self._recent_prices dictionary.

Through commmand TRACK_PRICES, this client can select multiple SYMBOLS for price tracking. For example, to receive real-time bid-ask prices from symbols EURUSD and GDAXI, this client will send this command to the Server, through its PUSH channel:

“TRACK_PRICES;EURUSD;GDAXI”

Server will answer through the PULL channel with a json response like this:

{‘_action’:’TRACK_PRICES’, ‘_data’: {‘symbol_count’:2}}

or if errors, then:

{‘_action’:’TRACK_PRICES’, ‘_data’: {‘_response’:’NOT_AVAILABLE’}}

Once subscribed to this feed, it will receive through the SUB channel, prices in this format:

“EURUSD BID;ASK”

Original Author: raulMrello

Modified by : AbdullahBahi

class fxmanager.dwx.prices_subscriptions.prices_subscriptions(_name='PRICES_SUBSCRIPTIONS', _symbols=['EURUSD', 'GDAXI'], _delay=0.1, _broker_gmt=3, _verbose=False)

Bases: fxmanager.dwx.DWX_ZMQ_Strategy.DWX_ZMQ_Strategy

isFinished()

Check if execution finished

onPullData(data)

Callback to process new data received through the PULL port

onSubData(data)

Callback to process new data received through the SUB port

run()

Starts price subscriptions

stop()

unsubscribe from all market symbols and exits

fxmanager.dwx.rates_historic module

This Module is used as an API to get historic data from the MT4 EA.

This is a modified version of an example of using the Darwinex ZeroMQ Connector for Python 3 and MetaTrader 4 PULL REQUEST for v2.0.1 in which a Client requests rate history from a Daily from a start date to an end date. The user creates a ‘rates_historic’ object and using the methods ‘get_daily_candles’ and ‘get_period_candles’ the user client can get the historic data of the desired symbols.

The original example is referenced here.

Through commmand HIST, this client can select multiple rates from an INSTRUMENT (symbol, timeframe). For example, to receive rates from instruments EURUSD(M1), between two dates, it will send this command to the Server, through its PUSH channel:

“HIST;EURUSD;1;2019.01.04 00:00:00;2019.01.14 00:00:00”

Original Author: raulMrello

Modified by : AbdullahBahi

class fxmanager.dwx.rates_historic.rates_historic(_name='PRICES_SUBSCRIPTIONS', _delay=0.1, _broker_gmt=3, _verbose=False)

Bases: fxmanager.dwx.DWX_ZMQ_Strategy.DWX_ZMQ_Strategy

get_daily_candles(save_to='', currency_pair='', date='')

Request historic data and returns data of type ‘daily_candles’

get_period_candles(save_to='', currency_pair='', start='', end='')

Request historic data and returns data of type ‘period_candles’

isFinished()

Check if execution finished

onPullData(data)

Callback to process new data received through the PULL port

onSubData(data)

Callback to process new data received through the SUB port

stop()

unsubscribe from all market symbols and exits