mql5_zmq_backtrader package¶
Submodules¶
mql5_zmq_backtrader.adapter module¶
mql5_zmq_backtrader.cli module¶
Console script for mql5_zmq_backtrader.
mql5_zmq_backtrader.mql5_zmq_backtrader module¶
Main module.
mql5_zmq_backtrader.mt5broker module¶
-
class
mql5_zmq_backtrader.mt5broker.
MTraderBroker
(**kwargs)[source]¶ Bases:
backtrader.broker.BrokerBase
Broker implementation for MetaTrader 5.
This class maps the orders/positions from MetaTrader to the internal API of backtrader.
Params:
use_positions (Ram default:True): When connecting to the broker provider use the existing positions to kickstart the broker.
Set to False during instantiation to disregard any existing position
-
MTraderBroker
(datas=None)¶
-
buy
(owner, data, size, price=None, plimit=None, exectype=None, valid=None, tradeid=0, oco=None, trailamount=None, trailpercent=None, parent=None, transmit=True, **kwargs)[source]¶
-
frompackages
= ()¶
-
packages
= ()¶
-
params
¶ alias of
backtrader.metabase.AutoInfoClass_BrokerBase_MTraderBroker
-
class
mql5_zmq_backtrader.mt5broker.
MTraderCommInfo
[source]¶ Bases:
backtrader.comminfo.CommInfoBase
-
frompackages
= ()¶
-
getvaluesize
(size, price)[source]¶ Returns the value of size for given a price. For future-like objects it is fixed at size * margin
-
packages
= ()¶
-
params
¶ alias of
backtrader.metabase.AutoInfoClass_CommInfoBase_MTraderCommInfo
-
mql5_zmq_backtrader.mt5data module¶
-
class
mql5_zmq_backtrader.mt5data.
MTraderData
(**kwargs)[source]¶ Bases:
backtrader.feed.DataBase
MTrader Data Feed.
TODO: implement tick data. Main problem is that Backtrader is not tick oriented. TODO: test backfill_from
Params:
historical (default: False)
If set to True the data feed will stop after doing the first download of data.
The standard data feed parameters fromdate and todate will be used as reference.
backfill (default: True)
Perform backfilling after a disconnection/reconnection cycle. The gap duration will be used to download the smallest possible amount of data
backfill_from (default: None)
An additional data source can be passed to do an initial layer of backfilling. Once the data source is depleted and if requested, backfilling from IB will take place. This is ideally meant to backfill from already stored sources like a file on disk, but not limited to.
include_last (default: False)
Last historical candle is not closed. It will be updated in live stream
reconnect (default: True)
Reconnect when network connection is down
-
alias
= ()¶
-
aliased
= ''¶
-
frompackages
= ()¶
-
linealias
¶ alias of
backtrader.metabase.AutoInfoClass_la_LineSeries_la_DataSeries_la_OHLC_la_OHLCDateTime_la_AbstractDataBase_la_DataBase_la_MTraderData
-
lines
¶ alias of
backtrader.lineseries.Lines_LineSeries_DataSeries_OHLC_OHLCDateTime_AbstractDataBase_DataBase_MTraderData
-
packages
= ()¶
-
params
¶ alias of
backtrader.metabase.AutoInfoClass_LineRoot_LineMultiple_LineSeries_DataSeries_OHLC_OHLCDateTime_AbstractDataBase_DataBase_MTraderData
-
plotinfo
¶ alias of
backtrader.metabase.AutoInfoClass_pi_LineSeries_pi_DataSeries_pi_OHLC_pi_OHLCDateTime_pi_AbstractDataBase_pi_DataBase_pi_MTraderData
-
plotlines
¶ alias of
backtrader.metabase.AutoInfoClass_pl_LineSeries_pl_DataSeries_pl_OHLC_pl_OHLCDateTime_pl_AbstractDataBase_pl_DataBase_pl_MTraderData
-
setenvironment
(env)[source]¶ Receives an environment (cerebro) and passes it over to the store it belongs to
mql5_zmq_backtrader.mt5store module¶
-
class
mql5_zmq_backtrader.mt5store.
MTraderAPI
(host=None)[source]¶ Bases:
object
This class implements Python side for MQL5 JSON API See https://github.com/khramkov/MQL5-JSON-API for docs
-
class
mql5_zmq_backtrader.mt5store.
MTraderStore
(host='localhost')[source]¶ Bases:
object
Singleton class wrapping to control the connections to MetaTrader.
Balance update occurs at the beginning and after each transaction registered by ‘_t_streaming_events’.
-
BrokerCls
¶
-
DataCls
¶
-
frompackages
= ()¶
-
classmethod
getbroker
(*args, **kwargs)[source]¶ Returns broker with *args, **kwargs from registered BrokerCls
-
packages
= ()¶
-
params
¶ alias of
backtrader.metabase.AutoInfoClass_MTraderStore
-
-
class
mql5_zmq_backtrader.mt5store.
MetaSingleton
(name, bases, dct)[source]¶ Bases:
backtrader.metabase.MetaParams
Metaclass to make a metaclassed class a singleton
Module contents¶
Top-level package for mql5_zmq_backtrader. Project developed to work as a server for Python trading community. It is based on ZeroMQ sockets and uses JSON format to communicate messages. It is a python library for the ZeroMQ API within backtrader framework. It allows rapid trading algo development. For details of API behavior, please see the online API document.