fxcm / ForexConnectAPI

Designed to trade, retrieve live/history price. Intended to be used to build auto-trading robots, custom trading on FXCM accounts.
132 stars 47 forks source link

get.history Issues? #17

Closed jimmylai-hk closed 1 year ago

jimmylai-hk commented 1 year ago

I have no issues when I use the following code to download the instrument (from 1-1-2020 to 12-31-2022)

import datetime as dt import pandas as pd import numpy as np symbol = "EUR/USD" timeframe ="D1"

with ForexConnect() as fx: init_forexconnect(fx, ACCOUNT_ID,PASSWORD) year = 2010 start_day = dt.datetime.strptime(str(1)+"."+str(1)+"."+str(2020), '%m.%d.%Y') end_day = dt.datetime.strptime(str(12)+"."+str(31)+"."+str(2022), '%m.%d.%Y') print(start_day, end_day) history = fx.get_history(symbol, timeframe, start_day, end_day)

However, when I changed the end_day to 7-7-2023, I have the following error messages.

Trading session status: CONNECTING Trading session status: CONNECTED 2020-01-01 00:00:00 2023-07-07 00:00:00 Trading session status: DISCONNECTING Trading session status: DISCONNECTED

Exception Traceback (most recent call last)

in () 13 end_day = dt.datetime.strptime(str(7)+"."+str(7)+"."+str(2023), '%m.%d.%Y') 14 print(start_day, end_day) ---> 15 history = fx.get_history(symbol, timeframe, start_day, end_day) ~\Anaconda3\lib\site-packages\forexconnect\ForexConnect.py in get_history(self, instrument, timeframe, date_from, date_to, quotes_count, candle_open_price_mode) 458 self._com.candle_open_price_mode = candle_open_price_mode 459 --> 460 reader = self._com.get_history(instrument, timeframe, date_from, date_to, quotes_count) 461 if timeframe.unit == fxcorepy.O2GTimeFrameUnit.TICK: 462 result = np.zeros(len(reader), np.dtype([('Date', "M8[ns]"), ('Bid', "f8"), ("Ask", "f8")])) Exception: QuotesManager error: Failed to extract the archive. Cause: Failed to extract the archive. Cause: code: LoadingError subcode: -1 I used the following code to reproduce the above issues. with ForexConnect() as fx: init_forexconnect(fx, ACCOUNT_ID,PASSWORD) year = 2010 start_day = dt.datetime.strptime(str(1)+"."+str(1)+"."+str(2020), '%m.%d.%Y') end_day = dt.datetime.strptime(str(7)+"."+str(7)+"."+str(2023), '%m.%d.%Y') print(start_day, end_day) history = fx.get_history(symbol, timeframe, start_day, end_day) Please check and many thanks in advance.
FXCMAPI commented 1 year ago

Dear client

This has been fixed, please try again and let me know if you still have issue

Best regards Lei

The FXCM Group is a holding company of Forex Capital Markets Limited (FXCM LTDhttps://www.fxcm.com/uk/), FXCM EU LTD (FXCM EUhttps://www.fxcm.com/eu/), FXCM Australia Pty. Limited (FXCM AUhttps://www.fxcm.com/au), FXCM South Africa (PTY) Ltd (FXCM ZAhttps://www.fxcm.com/za), FXCM Markets LLC (FXCM Marketshttps://www.fxcm.com/markets), and all affiliates of aforementioned firms, or other firms under the FXCM Group of companies [collectively "FXCM"]. The FXCM Group is headquartered at 20 Gresham Street, 4th Floor, London EC2V 7JE, United Kingdom. Read and understand the Terms and Conditions on the FXCM Group’s websites prior to taking further action.

FXCM LTD is authorised and regulated in the UK by the Financial Conduct Authority. Registration number 217689. Registered in England and Wales with Companies House company number 04072877.

Risk Warning: CFDs are complex instruments and come with a high risk of losing money rapidly due to leverage. 71% of retail investor accounts lose money when trading CFDs with this provider. You should consider whether you understand how CFDs work and whether you can afford to take the high risk of losing your money.

FXCM EU is a Cyprus Investment Firm ("CIF") registered with the Cyprus Department of Registrar of Companies (HE 405643) and authorised and regulated by the Cyprus Securities and Exchange Commission ("CySEC") under license number 392/20.

Risk Warning: CFDs are complex instruments and come with a high risk of losing money rapidly due to leverage. 75% of retail investor accounts lose money when trading CFDs with this provider. You should consider whether you understand how CFDs work and whether you can afford to take the high risk of losing your money.

FXCM AU is regulated by the Australian Securities and Investments Commission, AFSL 309763. FXCM AU ACN: 121934432. The information provided by FXCM AU is intended for residents of Australia and is not directed at any person in any country or jurisdiction where such distribution or use would be contrary to local law or regulation. Please read the full Terms and Conditionshttps://www.fxcm.com/au/legal/website-terms-and-conditions/.

Risk Warning: By trading, you could sustain a total loss of your deposited funds. The products may not be suitable for all investors. Please ensure that you fully understand the risks involved. If you decide to trade products offered by FXCM AU, you must read and understand the Financial Services Guidehttps://docs.fxcorporate.com/financial-services-guide-au.pdf, Product Disclosure Statementhttps://www.fxcm.com/au/legal/product-disclosure-statements/, Target Market Determinationhttps://www.fxcm.com/au/legal/target-market-determination/ and Terms of Businesshttps://docs.fxcorporate.com/tob_au_en.pdf.

FXCM ZA is an authorized Financial Services Provider and is regulated by the Financial Sector Conduct Authority under FSP No 46534.

Risk Warning: Our service includes products that are traded on margin and carry a risk of losses in excess of your deposited funds. The products may not be suitable for all investors. Please ensure that you fully understand the risks involved. Our FX and CFD prices are set by us, are not made on an Exchange and are not governed under the Financial Advisory and Intermediary Services Act.

FXCM Markets is incorporated in St Vincent and the Grenadines with company registration No. 1776 LLC 2022 and is an operating subsidiary within the FXCM group of companies (collectively, the "FXCM Group" or "FXCM"). FXCM Markets is not required to hold any financial services license or authorization in St Vincent and the Grenadines to offer its products and services.

Risk Warning: Losses can exceed deposited funds.

Information Security on Internet: To protect your privacy, do not access your trading account via public or shared computers or save your password locally in any computer or mobile device after logging in. FXCM will never ask you to send any of your personal information such as account number and password to us directly via e-mails. From: jimmylai @.> Sent: Sunday, July 9, 2023 8:48 PM To: fxcm/ForexConnectAPI @.> Cc: Subscribed @.***> Subject: [fxcm/ForexConnectAPI] get.history Issues? (Issue #17)

I have no issues when I use the following code to download the instrument (from 1-1-2020 to 12-31-2022)

import datetime as dt import pandas as pd import numpy as np symbol = "EUR/USD" timeframe ="D1"

with ForexConnect() as fx: init_forexconnect(fx, ACCOUNT_ID,PASSWORD) year = 2010 start_day = dt.datetime.strptime(str(1)+"."+str(1)+"."+str(2020), '%m.%d.%Y') end_day = dt.datetime.strptime(str(12)+"."+str(31)+"."+str(2022), '%m.%d.%Y') print(start_day, end_day) history = fx.get_history(symbol, timeframe, start_day, end_day)

However, when I changed the end_day to 7-7-2023, I have the following error messages.

Trading session status: CONNECTING Trading session status: CONNECTED 2020-01-01 00:00:00 2023-07-07 00:00:00 Trading session status: DISCONNECTING Trading session status: DISCONNECTED

Exception Traceback (most recent call last) in () 13 end_day = dt.datetime.strptime(str(7)+"."+str(7)+"."+str(2023), '%m.%d.%Y') 14 print(start_day, end_day) ---> 15 history = fx.get_history(symbol, timeframe, start_day, end_day)

~\Anaconda3\lib\site-packages\forexconnect\ForexConnect.py in get_history(self, instrument, timeframe, date_from, date_to, quotes_count, candle_open_price_mode) 458 self._com.candle_open_price_mode = candle_open_price_mode 459 --> 460 reader = self._com.get_history(instrument, timeframe, date_from, date_to, quotes_count) 461 if timeframe.unit == fxcorepy.O2GTimeFrameUnit.TICK: 462 result = np.zeros(len(reader), np.dtype([('Date', "M8[ns]"), ('Bid', "f8"), ("Ask", "f8")]))

Exception: QuotesManager error: Failed to extract the archive. Cause: Failed to extract the archive. Cause: code: LoadingError subcode: -1

I used the following code to reproduce the above issues.

with ForexConnect() as fx: init_forexconnect(fx, ACCOUNT_ID,PASSWORD) year = 2010 start_day = dt.datetime.strptime(str(1)+"."+str(1)+"."+str(2020), '%m.%d.%Y') end_day = dt.datetime.strptime(str(7)+"."+str(7)+"."+str(2023), '%m.%d.%Y') print(start_day, end_day) history = fx.get_history(symbol, timeframe, start_day, end_day)

Please check and many thanks in advance.

— Reply to this email directly, view it on GitHubhttps://github.com/fxcm/ForexConnectAPI/issues/17, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADDPMLZT5GTVC5O7QQ6346LXPNGLHANCNFSM6AAAAAA2D2QRSM. You are receiving this because you are subscribed to this thread.Message ID: @.**@.>>

jimmylai-hk commented 1 year ago

The issues fixed. Thanks.