Thursday, May 21, 2020

Getting FXCM Working With Python

While I will do a full review on Python for Finance once I am done with the book, enroute I will keep sharing some items I feel may be useful.

In chapter 14 the author demonstrates how a python program can connect to an online broker, FXCM. Just sharing detailed steps on how I got the API token.

1. Sign up for the demo account as suggested by the book. You will receive an email with a password.

2. Sign into your demo account, which for me looked as below:


3. Click the part highlighted in the picture above to bring up a context menu (shown below) and click “Token Management”.


4. You should see a dialog similar to the snapshot below. Enter the password you got on your email to generate the REST API token.


While the book recommends FXCM, I know that Oanda also provides a python wrapper. I won't be using FXCM as at the time of the blog it supported only currencies for algorithmic trading, while I was looking for indices. Only following currency pairs are supported:

('AUDCAD', 'AUDCHF', 'AUDJPY', 'AUDNZD', 'CADCHF', 'EURAUD', 'EURCHF', 'EURGBP', 'EURJPY', 'EURUSD', 'GBPCHF', 'GBPJPY', 'GBPNZD', 'GBPUSD', 'GBPCHF', 'GBPJPY', 'GBPNZD', 'NZDCAD', 'NZDCHF', 'NZDJPY', 'NZDUSD', 'USDCAD', 'USDCHF', 'USDJPY')

For fxcmpy to work, You would need the python-socketio installed.

Also, for In[1] on page 470, I could not get "from pylab import mpl, plt" to work. Changing to "from matplotlib.pylab import mpl, plt" fixed the problem for me.

No comments:

Post a Comment

Trading212 ISA: A Brilliant Choice Brilliantly Ignored!

 As far as tax saving schemes are concerned, Stock & Shares ISAs are an amazing value for money for knowledgeable retail investors. £20,...