Resampling data for Sunday / Monday data

Hi,

I noticed FXCM has Sunday data. I would like to resample this so the Sunday data is merged with the Monday. anyone has ideas for this?

I’ve tried figuring it out but can’t manage it.

thanks

Hello @Jens,
A member of my API team tried to test out some code like this but couldn’t find any Sunday candles. Candles returned by fxcmpy have index as date+time of the candle start, which is 5pm NY time of previous day. This means that candles with a date of Sunday are actually for Monday.
For example, a candle of 2018-11-25 22:00 (Sunday) is actually a candle for 2018-11-26 (Monday).
Could this be the issue you are having with the code?

Hi @Jens

I had problems with Sunday candles as well when downloading the price data (I think from the python API). From memory it is because the python API downloads the data as GMT time. However some of the FXCM trade servers run on 2 or 3 hour offsets like my AUD server.

Basically just adjust the time offset when downloading the data until it lines up with 5 full trading days.

1 Like

thanks a lot both, very helpful. I’ll try and fix that now.

there only seems to be an issue connecting to fxcm now?

when I run the following, I’m getting an error

 con = fxcmpy.fxcmpy(access_token=token, log_level="error", log_file=None)

|ERROR|2018-12-01 08:26:15,624|Socket returns an error: (‘Connection aborted.’, OSError("(10054, ‘WSAECONNRESET’)",)).

ServerError Traceback (most recent call last)
in ()
----> 1 con = fxcmpy.fxcmpy(access_token=token, log_level=“error”, log_file=None)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\fxcmpy\fxcmpy.py in init(self, access_token, config_file, log_file, log_level, server, proxy_url, proxy_port, proxy_type)
234 raise ServerError(‘Can not find FXCM Server.’)
235 elif self.connection_status == ‘aborted’:
–> 236 raise ServerError(‘Can not connect to FXCM Server.’)
237
238 self.collect_account_ids()

ServerError: Can not connect to FXCM Server.

I didn’t change anything. this code always used (I’ve ran the necessary libraries before too). anyone else encountering this?

I upgraded fxcmpy and the error is fixed now. Still having issues with the timezones. I’ve tried the following:

df = con.get_candles('GBP/USD', period='D1',start= dt.datetime(2016, 1, 1),end = dt.datetime(2018, 6, 10))
df.reset_index(inplace=True)
df.date= df.date.dt.tz_localize('US/Eastern').dt.tz_convert('Europe/Dublin')

it doesn’t change anything though. I think also because the data is downloaded already that wouldn’t make any difference. how to do change it while downloading the data?

thanks

@Jens, try localizing it to UTC instead of Eastern before converting it. Try

df = con.get_prices(‘EUR/USD’)
df = df.tz_localize(pytz.timezone(‘UTC’))
df = df.tz_convert(pytz.timezone(‘Europe/Dublin’))

Dear QN - Team!

I am currentley in Brazil and not in Austria were my account is registred.
I get the following error message from a jupyter notebook that allways used to work:

|ERROR|2020-03-27 03:17:28,169|Socket returns unknown error.


ServerError Traceback (most recent call last)
in
2 window_size = 30
3 skip = 1
----> 4 con = fxcmpy.fxcmpy(access_token = TOKEN, log_level = ‘error’, server=‘demo’)
5 get_accounts_summary = con.get_accounts_summary()[‘equity’][0]
6 initial_money = get_accounts_summary

~\Anaconda3\lib\site-packages\fxcmpy\fxcmpy.py in init(self, access_token, config_file, log_file, log_level, server, proxy_url, proxy_port, proxy_type)
216 raise ServerError(‘Can not find FXCM Server.’)
217 elif self.connection_status == ‘aborted’:
–> 218 raise ServerError(‘Can not connect to FXCM Server.’)
219
220 self.collect_account_ids()

ServerError: Can not connect to FXCM Server.

Can this be a similar error like the one above?

Thanks a lot for your reply

Matthias Wiedemann