Any python or fxcmp wrappers to calculate a forex instruments daily percentage increase

@QN_Liza looking to see if a python function exists already to get this info ?

Thks

@Femi.lewis fxcmpy does not have a function for this. You could pull the daily open/close prices with
df = con.get_candles(‘EUR/USD’, period=‘D1’) and potentially calculate the % change from there.

1 Like

Ok thats what i thought but just thought would ask any way

Thks liza

@QN_Liza any reason why the following code doe not subscribe to to EUR/USD
an when I I call con.get_prices() it says not subscribed or con.is_subscribed_market(‘EUR/USD’) returns false ??

import fxcmpy
con = fxcmpy.fxcmpy(config_file=‘fxcm.cfg’)
import datetime as dt
start = dt.datetime(2018, 1, 1)
stop = dt.datetime(2018, 1, 30)
con.get_instruments()
data = con.get_candles(‘EUR/USD’, period = ‘D1’, start = start, stop = stop)
con.subscribe_market_data(‘EUR/USD’)

data = con.get_prices(‘EUR/USD’)

Hi @Femi.lewis. In this code, the error was thrown because you are requesting live and historical data at the same time. The code con.get_prices(‘EUR/USD’) is used to get live prices and the line con.get_candles(‘EUR/USD’, period = ‘D1’, start = start, stop = stop) is used to get historical prices. You will need to take one of the lines of code out depending on whether you are wanting historical or live.

This is what I used to get the historical:

import fxcmpy
con = fxcmpy.fxcmpy(config_file=‘fxcm.cfg’)
import datetime as dt
start = dt.datetime(2018, 1, 1)
stop = dt.datetime(2018, 1, 30)
con.get_instruments()
data = con.get_candles(‘EUR/USD’, period = ‘D1’, start = start, stop = stop)
con.subscribe_market_data(‘EUR/USD’)
data

Thanks grace for your quick response

1 Like