0

I am trying to pull MT4 trade history data using the PyMT4ManagerAPI hosted here:

https://github.com/ipenn/PyMT4ManagerAPI

The API works fine to get open trades and users info. But when I try to get the historical trades, using the function TradesUserHistory(self, login, arg3, to, total) from the file MT4ManagerAPI.py, I get a strange error:

argument 3 of type '__time32_t const'

The parameters that I am using are login (Login ID of the user account), arg3 (datetime.date(2015,1,5)) to Pull history starting this date, to ( datetime.date(2019,1,5)) to Pull history till this date and total i.e. MT4ManagerAPI.intp() as required by the setup.

I am certain that the way in which I am passing the dates is not correct and am unable to find anything about converting Python datetime to __time32_t const type.

So, any guidance around that conversion would be appreciated.

Martin Evans
  • 45,791
  • 17
  • 81
  • 97
Rishi Mehta
  • 399
  • 3
  • 10

1 Answers1

0

Mt4 manager is using really old datatypes for everything. I have used int32 or int for seconds since epoch successfully in the past simply passing an int from C# into the c++ layer. Should be equivalent in python.

One noteworthy thing to consider is that MT4 folks did some time manipulation in C++ to get to actual time from __time32_t. This is an exerpt from MT4ManagerAPI.h:

//--- time conversion ratio
#define TIME_RATE         ((double)1.6777216)
//--- conversion from our time to standard __time32_t
#define STDTIME(custom_time) ((DWORD)((double)(custom_time)*TIME_RATE))
//--- conversion from standard __time32_t to our time
#define OURTIME(stdtime)     ((DWORD)((double)(stdtime)/TIME_RATE))

Although I never found uses of any of these 3 #defines I find the existence of TIME_RATE quiet dubious and you might need to use the fraction in places where timestamps don't seem to be behaving correctly.

Dmitry
  • 1,513
  • 1
  • 15
  • 33
  • This is an interesting observation Dmitry. I tried calling the function using different data type conversions but seems like none of them work. I tried fractions as well. Will update here if I have a breakthrough. – Rishi Mehta Jul 30 '19 at 11:14