for getting history data, I try to running the following example code but received the error:
Exception: QuotesManager error: HTTP request failed object='/pricearchive/catalog.xml' errorCode=400 code: QuotesServerConnectionError subcode: 400
I'm a bit confuse with that, is there any mistakes I have made in the code?
- Code: Select all
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(str_user_id, str_password, "fxcorporate.com/Hosts.jsp",
"Demo", session_status_callback=session_status_changed)
history = fx.get_history("AUD/USD", "m15",
datetime.datetime.strptime("11.22.2022 00:00:00", '%m.%d.%Y %H:%M:%S').replace(
tzinfo=datetime.timezone.utc),
datetime.datetime.strptime("11.23.2022 00:00:00", '%m.%d.%Y %H:%M:%S').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 a lot for the patient helping.