You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
There is an issue when passing python datetime objects to copy_rates_range(symbol, timeframe, date_from, date_to)
Here is a part of the stack trace:
--- Logging error ---
Traceback (most recent call last):
File "C:\Program Files\Python\lib\logging\__init__.py", line 1081, in emit
msg = self.format(record)
File "C:\Program Files\Python\lib\logging\__init__.py", line 925, in format
return fmt.format(record)
File "C:\Program Files\Python\lib\logging\__init__.py", line 664, in format
record.message = record.getMessage()
File "C:\Program Files\Python\lib\logging\__init__.py", line 367, in getMessage
msg = str(self.msg)
File "d:\pydev\exol\backend\.venv\lib\site-packages\pymt5adapter\helpers.py", line 26, in __str__
res = f"{msg}\t{json.dumps(self)}"
File "C:\Program Files\Python\lib\json\__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "C:\Program Files\Python\lib\json\encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "C:\Program Files\Python\lib\json\encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "C:\Program Files\Python\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type datetime is not JSON serializable
Call stack:
File "C:\Program Files\Python\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\Python\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
I was able to solve this by passing timestamps instead of datetime objects, The docs says that either timestamp or datetime is acceptable. Have to mention that copy_rates_from() is fine with datetime.
The text was updated successfully, but these errors were encountered:
ahmadazizi
changed the title
copy_rates_range() does not work with datetime() objects
copy_rates_range() does not work with datetime objects
Sep 14, 2020
Hi,
There is an issue when passing python
datetime
objects tocopy_rates_range(symbol, timeframe, date_from, date_to)
Here is a part of the stack trace:
I was able to solve this by passing timestamps instead of
datetime
objects, The docs says that either timestamp ordatetime
is acceptable. Have to mention thatcopy_rates_from()
is fine withdatetime
.The text was updated successfully, but these errors were encountered: