Resampling data for Sunday / Monday data


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.


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\ 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.’)
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))

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?


@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’))