It seems there is timestamp bug when it comes to Tick, because the timestamp for each update is not set to milliseconds, only showing the seconds.
For example I currently get the following timestamps.
2019-06-24 19:13:43
2019-06-24 19:13:43
2019-06-24 19:13:43
2019-06-24 19:13:43
2019-06-24 19:13:43
Should be something like this.
2019-06-24 19:13:43.022
2019-06-24 19:13:43.053
2019-06-24 19:13:43.068
2019-06-24 19:13:43.070
This is a fairly critical bug because there is no way to eliminate 'out of order' ticks/updates, what is the best way to fix this?
- Code: Select all
import pandas as pd
import datetime
import csv
import numpy as np
data_file='C:\\Users\\FOREXCONNECT_DB.csv'
from forexconnect import fxcorepy, ForexConnect
def session_status_changed(session: fxcorepy.O2GSession,
status: fxcorepy.AO2GSessionStatus.O2GSessionStatus):
print("Trading session status: " + str(status))
def main():
with ForexConnect() as fx:
try:
fx.login(REAL_ACCOUNT_ID, PASSWORD, "fxcorporate.com/Hosts.jsp",
"Real", session_status_callback=session_status_changed)
history = fx.get_history("EUR/USD", "t1",
datetime.datetime.strptime("08.06.2020 17:51:21.000", '%m.%d.%Y %H:%M:%S.%f').replace(
tzinfo=datetime.timezone.utc),
datetime.datetime.strptime("08.06.2020 18:00:21.000", '%m.%d.%Y %H:%M:%S.%f').replace(
tzinfo=datetime.timezone.utc))
np.savetxt(data_file, history, delimiter=",")
print("Date, Bid, Ask")
for row in history:
print("{0:s}, {1:,.5f}, {2:,.5f}".format(
pd.to_datetime(str(row['Date'])).strftime('%m.%d.%Y %H:%M:%S.%f'), row['Bid'], row['Ask']))
# row['BidLow'], row['BidClose'], row['Volume']))
except Exception as e:
print("Exception: " + str(e))
try:
fx.logout()
except Exception as e:
print("Exception: " + str(e))
if __name__ == "__main__":
main()
Thanks for your help
Cheers