Git Product home page Git Product logo

ejtradermt's Introduction

Pypi Publish Release License

EjtraderMT Python Metatrader 5 API

Install stable version using pip
pip install ejtraderMT -U

From source code

for developers attention may contain countless bugs

git clone https://github.com/ejtraderLabs/ejtraderMT
cd ejtraderMT
python setup.py install

or 

pip install git+https://github.com/ejtraderLabs/ejtraderMT.git

Runing Metatrader 5 on Docker or windows machine

Easy way is using docker make sure to have docker runing on your machine

docker volume create ejtraderMT
docker run -d --restart=always -p 5900:5900 -p 15555:15555 -p 15556:15556 -p 15557:15557 -p 15558:15558 --name ejtraderMT -v ejtraderMT:/data ejtrader/metatrader:5

or docker compose

version: '3.8'
services:
  app:
    container_name: metatrader
    image: ejtrader/metatrader:5
    restart: unless-stopped
    ports:
      - '5900:5900'
      - '15555:15555'
      - '15556:15556'
      - '15557:15557'
      - '15558:15558'
    volumes:
      - ejtraderMT:/data
 
      
volumes:
  ejtraderMT: {}

Dockerfile and source for Docker wine vnc github

Access Metatrader 5 via VNC

download VNC VIEWER or any other vnc client of your preference: Download

username: root
password: root

harder way installing direct to your Metatrader 5 on Windows Machine

First download MQL5 source code and install it on the Metatrader 5 github

second download and install Microsoft Visual C++ 2015 Download

import

from ejtraderMT import Metatrader

Connect Metatrader 5

make sure ejtraderMT expert are load on the chart

'''
to change the host IP example Metatrader("192.168.1.100") ou
you can use doman example  "metatraderserverdomain.com"

for you local time on the Dataframe  Metatrader(tz_local=True)
attention utc time is the default for Dataframe index "date"


for real volume for active like WIN futures ou centralized market use Metatrader(real_volume=True)
attention tick volume is the default


to use more than one option just use , example Metatrader(host='hostIP',tz_local=True)
'''
api = Metatrader()

Account information

accountInfo = api.accountInfo()
print(accountInfo)
print(accountInfo['broker'])
print(accountInfo['balance'])

Economic Calendar

symbol = "EURUSD"
fromDate = "20/08/2021"
toDate = "24/08/2022"

calendar = api.calendar(symbol,fromDate,toDate)
print(calendar)

	              currency	impact	event	country	actual	forecast	previous
date							
2021-08-20 06:00:00	EUR	2	PPI m/m(ppi-mm)	Germany(DE)	1.9	0.9	1.3
2021-08-20 06:00:00	EUR	1	PPI y/y(ppi-yy)	Germany(DE)	10.4	9.4	8.5
2021-08-20 17:00:00	USD	2	Baker Hughes US Oil Rig Count(baker-hughes-us-...	United States(US)	405	None	397
2021-08-20 17:00:00	USD	2	Baker Hughes US Total Rig Count(baker-hughes-u...	United States(US)	503	None	500
2021-08-20 19:30:00	EUR	1	CFTC EUR Non-Commercial Net Positions(cftc-eur...	European Union(EU)	57.6 K	None	33.9 K
...	...	...	...	...	...	...	...
2022-08-24 14:30:00	USD	1	EIA Heating Oil Stocks Change(eia-heating-oil-...	United States(US)	0.845 M	-0.013 M	0.249 M
2022-08-24 14:30:00	USD	1	EIA Gasoline Stocks Change(eia-gasoline-stocks...	United States(US)	-0.027 M	-1.829 M	-4.642 M
2022-08-24 14:30:00	USD	1	EIA Refinery Crude Oil Daily Inputs Change(eia...	United States(US)	-0.168 M	None	-0.158 M
2022-08-24 14:30:00	USD	1	EIA Refinery Utilization Rate Change(eia-refin...	United States(US)	0.3	None	-0.8
2022-08-24 17:00:00	USD	1	5-Year Note Auction(5-year-note-auction)	United States(US)	3.23	None	2.86

History Dataframe Ready

History from Date to Date

# you can add unlimited actives to list  ["EURUSD","GBPUSD","AUDUSD"]
symbol = "EURUSD"
timeframe = "M1"
fromDate = "20/02/2021"
toDate = "24/02/2021"

history = api.history(symbol,timeframe,fromDate,toDate)
print(history)
                        open     high      low    close  volume  spread
date
2021-02-21 23:00:00  1.21135  1.21138  1.21131  1.21134     7.0      35
2021-02-21 23:01:00  1.21130  1.21135  1.21130  1.21135     6.0      43
2021-02-21 23:04:00  1.21150  1.21184  1.21134  1.21184    13.0      31
2021-02-21 23:05:00  1.21163  1.21207  1.21148  1.21181    39.0      42
2021-02-21 23:06:00  1.21189  1.21193  1.21182  1.21182    17.0      64
...                      ...      ...      ...      ...     ...     ...
2021-02-24 02:56:00  1.21629  1.21629  1.21590  1.21594    51.0       5
2021-02-24 02:57:00  1.21592  1.21592  1.21574  1.21574    34.0       5
2021-02-24 02:58:00  1.21574  1.21579  1.21572  1.21575    35.0       5
2021-02-24 02:59:00  1.21576  1.21588  1.21573  1.21582    55.0       5
2021-02-24 03:00:00  1.21583  1.21601  1.21578  1.21598    80.0       5

[3104 rows x 6 columns]

History by period unit like 27 candles

# you can add unlimited actives to list  ["EURUSD","GBPUSD","AUDUSD"]
symbol = "EURUSD"
timeframe = "M1"
fromDate = 27

history = api.history(symbol,timeframe,fromDate)
print(history)

                        open     high      low    close  volume  spread
date
2021-02-26 19:23:00  1.20846  1.20857  1.20837  1.20856    84.0       5
2021-02-26 19:24:00  1.20855  1.20858  1.20842  1.20847    71.0       5
2021-02-26 19:25:00  1.20846  1.20849  1.20832  1.20845    69.0       5
2021-02-26 19:26:00  1.20844  1.20845  1.20823  1.20833    64.0       5
2021-02-26 19:27:00  1.20833  1.20836  1.20821  1.20834    53.0       5
...                      ...      ...      ...      ...     ...     ...
2021-02-26 22:55:00  1.20721  1.20730  1.20718  1.20719    46.0      13
2021-02-26 22:56:00  1.20718  1.20738  1.20718  1.20731    39.0      12
2021-02-26 22:57:00  1.20730  1.20731  1.20716  1.20717    45.0      18
2021-02-26 22:58:00  1.20716  1.20731  1.20694  1.20704    77.0      16
2021-02-26 22:59:00  1.20702  1.20705  1.20702  1.20704    16.0      37

History for lastest period gread for predict

# you can add unlimited actives to list  ["EURUSD","GBPUSD","AUDUSD"]
symbol = "EURUSD"
timeframe = "M1"
fromDate = 27

history = api.history(symbol,timeframe)
print(history)

                        open     high      low    close  volume  spread
date
2021-02-26 19:23:00  1.20846  1.20857  1.20837  1.20856    84.0       5
2021-02-26 19:24:00  1.20855  1.20858  1.20842  1.20847    71.0       5
2021-02-26 19:25:00  1.20846  1.20849  1.20832  1.20845    69.0       5
2021-02-26 19:26:00  1.20844  1.20845  1.20823  1.20833    64.0       5
2021-02-26 19:27:00  1.20833  1.20836  1.20821  1.20834    53.0       5

History for multiple symbols merged dataframe

# you can add unlimited actives to list  ["EURUSD","GBPUSD","AUDUSD"] etc
symbol = ["EURUSD","GBPUSD"]
timeframe = "M1"
fromDate = "20/02/2021"
toDate = "24/02/2021"


history = api.history(symbol,timeframe,fromDate,toDate)
print(history)


                        open     high      low    close  volume  spread  gbpusd_open  gbpusd_high  gbpusd_low  gbpusd_close  gbpusd_volume  gbpusd_spread
date
2021-02-21 23:00:00  1.21135  1.21138  1.21131  1.21134     7.0      35      1.40113      1.40113     1.40110       1.40110            2.0            130
2021-02-21 23:04:00  1.21150  1.21184  1.21134  1.21184    13.0      31      1.40119      1.40119     1.40119       1.40119            1.0            102
2021-02-21 23:05:00  1.21163  1.21207  1.21148  1.21181    39.0      42      1.40174      1.40174     1.40167       1.40168           11.0             61
2021-02-21 23:06:00  1.21189  1.21193  1.21182  1.21182    17.0      64      1.40156      1.40170     1.40132       1.40155           10.0             46
2021-02-21 23:07:00  1.21181  1.21182  1.21180  1.21182     4.0      82      1.40156      1.40156     1.40156       1.40156            1.0             63
...                      ...      ...      ...      ...     ...     ...          ...          ...         ...           ...            ...            ...
2021-02-24 02:56:00  1.21629  1.21629  1.21590  1.21594    51.0       5      1.41833      1.41835     1.41786       1.41800           62.0              8
2021-02-24 02:57:00  1.21592  1.21592  1.21574  1.21574    34.0       5      1.41798      1.41801     1.41765       1.41766           54.0              8
2021-02-24 02:58:00  1.21574  1.21579  1.21572  1.21575    35.0       5      1.41767      1.41789     1.41767       1.41768           64.0              8
2021-02-24 02:59:00  1.21576  1.21588  1.21573  1.21582    55.0       5      1.41769      1.41782     1.41764       1.41769           42.0              9
2021-02-24 03:00:00  1.21583  1.21601  1.21578  1.21598    80.0       5      1.41770      1.41797     1.41746       1.41784           95.0              8

[3097 rows x 12 columns]

Live streaming Price

from ejtraderMT import Metatrader

api = Metatrader()

symbols = ["EURUSD","GBPUSD","AUDUSD"]
timeframe = "TICK"


# stream price
while True:
    price = api.price(symbols,timeframe)
    print(price)

Live streaming events

from ejtraderMT import Metatrader


api = Metatrader()

symbols = ["EURUSD","GBPUSD","AUDUSD"]
timeframe = "TICK"


# stream event
while True:
    event = api.event(symbols,timeframe)
    print(event)

Trading and Orders Manipulation

You can create market or pending order with the commands.

Market Orders

# symbol, volume, stoploss, takeprofit, deviation
api.buy("EURUSD", 0.01, 1.18, 1.19, 5)
api.sell("EURUSD", 0.01, 1.18, 1.19, 5)

Limit Orders

# symbol, volume, stoploss, takeprofit, price, deviation
api.buyLimit("EURUSD", 0.01, 1.17, 1.19, 1.18, 5)
api.sellLimit("EURUSD", 0.01, 1.20, 1.17, 1.19, 5)

Stop Orders

#symbol, volume, stoploss, takeprofit, price, deviation
api.buyStop("EURUSD", 0.01, 1.18, 1.20, 1.19, 5)
api.sellStop("EURUSD", 0.01, 1.19, 1.17, 1.18, 5)

Positions & Manipulation

positions = api.positions()


if 'positions' in positions:
    for position in positions['positions']:
        api.CloseById(position['id'])

Orders & Manipulation

orders = api.orders()

if 'orders' in orders:
    for order in orders['orders']:
        api.CancelById(order['id'])

Modify possition

api.positionModify( id, stoploss, takeprofit)

Modify order

api.orderModify( id, stoploss, takeprofit, price)

close by symbol

api.CloseBySymbol("EURUSD")

close particial

# id , volume
api.ClosePartial( id, volume)

If you want to cancel all Orders

api.cancel_all()

if you want to close all positions

api.close_all()

# Project Based and reference thanks for

Ding Li @dingmaotu
https://github.com/dingmaotu/mql-zmq

Nikolai khramkov @khramkov
https://github.com/khramkov/MQL5-JSON-API


New funcion persistent history Data on SQLite Multithrering

for saving to database

from ejtraderMT import Metatrader

api = Metatrader()

symbols = ["EURUSD"] # you can also use combind dataframe = ["EURUSD","GBPUSD","AUDUSD"]
timeframe = "M1"
# saving 20 years of OHLC
fromDate = "01/01/2001"
toDate = "01/01/2021"


api.history(symbol,timeframe,fromDate,toDate,database=True)

# or you could only pass from Date you want to start


"""
you can pull the history and save using only fromDate
its will pull history fromDate till now

api.history(symbol,timeframe,fromDate,database=True)
"""

# example of saving 20 years of M1 OHLC takes around 3 minutes on a 4 core CPU

 30%|█████████████████████████████████▋                              | 2174/7305 [01:10<02:28, 34.60it/s]

Read from Database

from ejtraderMT import Metatrader

api = Metatrader()

symbol = ["EURUSD"]



data = api.history(symbol)

# example reading 20 year of M1 OHLC takes around 2 seconds read more than 7 million canldes
Elapsed run time: 2.041501855 seconds
                        date     open     high      low    close  volume  spread
0        2001-01-01 04:02:00  0.94220  0.94220  0.94220  0.94220     1.0      50
1        2001-01-01 04:03:00  0.94240  0.94240  0.94240  0.94240     1.0      50
2        2001-01-01 10:47:00  0.94250  0.94250  0.94250  0.94250     1.0      50
3        2001-01-01 11:40:00  0.94190  0.94190  0.94190  0.94190     1.0      50
4        2001-01-01 14:45:00  0.93970  0.93990  0.93970  0.93990     3.0      50
...                      ...      ...      ...      ...      ...     ...     ...
7286195  2020-12-31 17:56:00  1.22147  1.22152  1.22147  1.22152    20.0       8
7286196  2020-12-31 17:57:00  1.22152  1.22162  1.22148  1.22157    58.0       8
7286197  2020-12-31 17:58:00  1.22157  1.22167  1.22152  1.22166    77.0       9
7286198  2020-12-31 17:59:00  1.22167  1.22177  1.22154  1.22154   129.0       8
7286199  2020-12-31 18:00:00  1.22156  1.22156  1.22155  1.22155     2.0      11

[7286200 rows x 7 columns]

Future add comming soon

economic calendar
level 1 for futures only
level 2 for futures only


ejtradermt's People

Contributors

traderpedroso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ejtradermt's Issues

Data socket timeout ERROR MT5 DOCKER AND WINDOWS

I was using the Docker version with mac and linux fine but suddenly the library stopped working. I thought that was the time to get Windows VPS so i now i have already installed all needed bu i'm having the same error.

Code i'm running:

from ejtraderMT import Metatrader
api = Metatrader()

ERROR WINDOWS:

Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\ejtraderMT\api\mql.py", line 71, in _pull_reply
msg = self.sys_socket.recv_json()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\zmq\sugar\socket.py", line 1009, in recv_json
msg = self.recv(flags)
^^^^^^^^^^^^^^^^
File "zmq\backend\cython\socket.pyx", line 805, in zmq.backend.cython.socket.Socket.recv
File "zmq\backend\cython\socket.pyx", line 841, in zmq.backend.cython.socket.Socket.recv
File "zmq\backend\cython\socket.pyx", line 199, in zmq.backend.cython.socket._recv_copy
File "zmq\backend\cython\socket.pyx", line 194, in zmq.backend.cython.socket._recv_copy
File "zmq\backend\cython\checkrc.pxd", line 22, in zmq.backend.cython.checkrc._check_rc
zmq.error.Again: Resource temporarily unavailable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Administrator\met.py", line 3, in
api = Metatrader()
^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\ejtraderMT\api\mql.py", line 138, in init
self.__utc_brocker_offset = self.___utc_brocker_offset()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\ejtraderMT\api\mql.py", line 407, in ___utc_brocker_offset
broker = self.accountInfo()
^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\ejtraderMT\api\mql.py", line 279, in accountInfo
return self.__api.Command(action="ACCOUNT")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\ejtraderMT\api\mql.py", line 113, in Command
return self._pull_reply()
^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\ejtraderMT\api\mql.py", line 73, in _pull_reply
raise zmq.NotDone("Data socket timeout ERROR")
zmq.error.NotDone: Data socket timeout ERROR

Multi account

hi , do you have any idea about add feature to support multi account ?

Data Socket Timeout

Hi.
Thanks for your ejtraderMT,
i'm trying to use it but i'm keep facing error and i've launched it on docker,
this is the code that i'm trying to execute:
image

this is the parameter:
image

and this is my containers:
image

what did i missed? can you help me, please

this is the error:

Again Traceback (most recent call last)
File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:71, in Functions._pull_reply(self)
70 try:
---> 71 msg = self.sys_socket.recv_json()
72 except zmq.ZMQError:

File ~\AppData\Roaming\Python\Python310\site-packages\zmq\sugar\socket.py:1009, in Socket.recv_json(self, flags, **kwargs)
990 """Receive a Python object as a message using json to serialize.
991
992 Keyword arguments are passed on to json.loads
(...)
1007 for any of the reasons :func:~Socket.recv might fail
1008 """
-> 1009 msg = self.recv(flags)
1010 return self._deserialize(msg, lambda buf: jsonapi.loads(buf, **kwargs))

File zmq\backend\cython\socket.pyx:805, in zmq.backend.cython.socket.Socket.recv()

File zmq\backend\cython\socket.pyx:841, in zmq.backend.cython.socket.Socket.recv()

File zmq\backend\cython\socket.pyx:199, in zmq.backend.cython.socket._recv_copy()

File zmq\backend\cython\socket.pyx:194, in zmq.backend.cython.socket._recv_copy()

File ~\AppData\Roaming\Python\Python310\site-packages\zmq\backend\cython\checkrc.pxd:22, in zmq.backend.cython.checkrc._check_rc()

Again: Resource temporarily unavailable

During handling of the above exception, another exception occurred:

NotDone Traceback (most recent call last)
Cell In[1], line 3
1 from ejtraderMT import Metatrader
----> 3 api = Metatrader(host='localhost', debug=False)
5 symbol = "EURUSD"
6 fromDate = "01/01/2023"

File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:138, in Metatrader.init(self, host, real_volume, tz_local, dbtype, dbhost, dbport, dbpass, dbuser, dbname, debug)
136 self.__utc_timezone = timezone("UTC")
137 self.__my_timezone = get_localzone()
--> 138 self.__utc_brocker_offset = self.___utc_brocker_offset()
139 # db settings
140 self.dbtype = dbtype or "SQLITE" # SQLITE OR INFLUXDB

File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:407, in Metatrader.___utc_brocker_offset(self)
405 utc = datetime.now(self.__utc_timezone).strftime("%Y-%m-%d %H:%M:%S")
406 try:
--> 407 broker = self.accountInfo()
408 broker = datetime.strptime(broker["time"], "%Y.%m.%d %H:%M:%S")
409 except KeyError:

File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:279, in Metatrader.accountInfo(self)
278 def accountInfo(self):
--> 279 return self.__api.Command(action="ACCOUNT")

File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:113, in Functions.Command(self, **kwargs)
110 self._send_request(request)
112 # return server reply
--> 113 return self._pull_reply()

File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:73, in Functions._pull_reply(self)
71 msg = self.sys_socket.recv_json()
72 except zmq.ZMQError:
---> 73 raise zmq.NotDone("Data socket timeout ERROR")
74 return msg

NotDone: Data socket timeout ERROR

How get clean data and how get last candle?

After long work, i compiled on windows VPS and now is working but i'm some questions.

Could I receive clean data without loading bar ? I mean.. when i'm getting the candles avoid to print the loading bar.
Screenshot 2023-11-20 at 00 26 15

How could get only the last candle? I tried to:

    symbol = "EURUSD"
    timeframe = "M15"
    fromDate =  2

    history = api.history(symbol,timeframe,fromDate)

[]
But getting :
Screenshot 2023-11-20 at 00 30 11

And any alternative to mt5.symbol_info(symbol) ???

AttributeError: 'Functions' object has no attribute 'streaming_socket'

When i run ->

from ejtraderMT import Metatrader

api = Metatrader()

symbols = ["EURUSD","GBPUSD","AUDUSD"]
timeframe = "TICK"

# stream price
while True:
    price = api.price(symbols,timeframe)
    print(price)

I have this output ->

Exception in thread Thread-1 (_price):
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ejtraderMT/api/mql.py", line 420, in _price
    connect = self.__api.live_socket()
              ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Functions' object has no attribute 'live_socket'. Did you mean: 'sys_socket'?


All other functions are working.

SECUR32_initNTLMSP ntlm_auth was not found or is outdated.

Getting the following errors when using docker-compose setup

2023-07-15 11:04:37,778 INFO reaped unknown pid 1066 (exit status 0)
01e4:err:winediag:SECUR32_initNTLMSP ntlm_auth was not found or is outdated. Make sure that ntlm_auth >= 3.0.25 is in your path. Usually, you can find it in the winbind package of your distribution.
01e4:fixme:thread:SetThreadStackGuarantee (0x225ef0): stub
01e4:fixme:iphlpapi:GetTcpStatisticsEx unimplemented for IPv6
01fe:fixme:kernelbase:AppPolicyGetThreadInitializationType 0xfffffffffffffffa, 0xcffdc0
01fb:fixme:kernelbase:AppPolicyGetThreadInitializationType 0xfffffffffffffffa, 0x111fdc0
01e4:fixme:ntdll:NtQuerySystemInformationEx Relationship filtering not implemented: 0x1
01e4:fixme:ntdll:NtQuerySystemInformationEx Relationship filtering not implemented: 0x1
01e4:fixme:ntdll:NtQueryInformationToken QueryInformationToken( ..., TokenElevation, ...) semi-stub
01f3:err:winediag:SECUR32_initNTLMSP ntlm_auth was not found or is outdated. Make sure that ntlm_auth >= 3.0.25 is in your path. Usually, you can find it in the winbind package of your distribution.
01f3:fixme:thread:SetThreadStackGuarantee (0x53e030): stub
01f7:fixme:kernelbase:AppPolicyGetThreadInitializationType 0xfffffffffffffffa, 0x50dfdc0
01e4:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
01e4:err:winediag:nodrv_CreateWindow Make sure that your X server is running and that $DISPLAY is set correctly.
01f3:fixme:kernelbase:AppPolicyGetProcessTerminationMethod 0xfffffffffffffffa, 0x53fce0
2023-07-15 11:04:39,541 INFO success: metatrader entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2023-07-15 11:04:39,541 INFO reaped unknown pid 1099 (exit status 0)
01e4:fixme:kernelbase:AppPolicyGetProcessTerminationMethod 0xfffffffffffffffa, 0x22fce0
2023-07-15 11:04:40,763 INFO exited: metatrader (exit status 69; not expected)
2023-07-15 11:04:40,765 INFO spawned: 'metatrader' with pid 1102
No protocol specified

Have tried on 2 separate machines, 1st on linux docker and then on docker for windows

Python não comunica com o MT5

Estou usando o MT5 o Docker usando a sua imagem(Dockerfile) está rodando tudo bem, porem nao consigo comunicar pelo python.

image

PYTHON SCRIPT:

from ejtraderMT import Metatrader

api = Metatrader()
symbol = ["PETR4"]
timeframe = "M15"
fromDate = "20/02/2021"
toDate = "24/02/2021"

history = api.history(symbol,timeframe,fromDate,toDate)
print(history)

image

image

O que estou fazendo de errado?

error 5040 Damaged parameter of string type

Hello thank you for making this api available very grateful to you.

I've been using many functions but when I call api.positions() and api.orders() I get these errors, I don't know what it is, I did a search and found this khramkov/MQL5-JSON-API#11.

positions = api.positions()
orders = api.orders()

print(positions)
print(orders)

#output

{"error":true,"lastError":"5040","description":"Damaged parameter of string type","function":"GetPositions"}

{"error":true,"lastError":"5040","description":"Damaged parameter of string type","function":"GetPositions"}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.