Connect to the OANDA API

After you did setup your cloud environment including IPython/ Jupyter you are able to make the next steps.

Be sure that IPython is started and accessible. Perhaps you need to open a port on the firewall so that you can connect to IPython from anywhere. The default port is 9999.

But before you call OANDA API functions, there are still some prerequisites that need to be met. But luckily you can do everything from within IPython.

The first step is to obtain the python OANDA api wrapper and then configure your OANDA credentials. You can generate a token in the OANDA webinterface after you log in. Be sure to use a practice account for your first experiments.

And finally you need to do the import.

Those first three steps are shown on this IPython screenshot:


Now you're ready to connect to the API and play around with it to see if everything works as expected.

In my example I fetch a list of all instruments that are available for trading with OANDA, print a filtered list of instruments I'm interested in and then print the ask/ bid price of Gold (XAU/USD).

Read More 0 Comments

How to setup a cloud-based environment for automated trading with python

If you are going to practice and learn automated trading with python, the first step is to setup your environment and get comfortable with it.

Before you choose your platform and tools, there are some considerations you have to make regarding your requirements.

Here is the list of my main requirements;

  1. I need a state-of-the-art python environment that includes some kind of IDE.
  2. The environment must be ready to be deployed to some kind of cloud provider. An automated trading system should not be hosted on my PC that would need to be online 24/7 standing on my desk at home.
  3. I need a cloud provider who grants a maximum flexibility to me - no restrictions regarding outbound requests, no restriction regarding python modules that can be installed.
  4. I want to inspect my code and manage my trading from anywhere, if possible even with my mobile or a tablet computer.
  5. My main broker is Oanda - luckily Oanda provides a RESTful API and really good developer documentations.

Having these points in mind, my technology stack looks like this:

I use IPython in Jupyter Notebooks. To play around with this, you can use the Anaconda distribution and install it on your computer.

To bring this to the cloud, you would need a cloud service provider that gives you access via remote desktop connections or via ssh. There are a lot of python/ IPython service provider that offer free or paid Jupyter notebooks - I tried a lot of them, but most of them are too restrictive.

One option would be to setup a micro instance in the Amazon cloud and then install the Python/ anaconda/Jupyter stuff manually which is no big deal. If you register a developer account at AWS you can use the service free for one year.

I made a different choice - I registerd a Data Science Virtual Machine at the Microsoft Azure cloud.

This VM has everything pre-installed and there is not only the python-stuff, there is a lot of other fancy stuff that can be used for automated trading and quantitative analytics:

  • Microsoft R Server Developer Edition
  • Anaconda Python
  • Julia Pro developer edition,
  • Jupyter notebooks for R, Python and Julia
  • Visual Studio Community Edition with Python, R and node.js tools
  • and many many more ...

In my next blog post I will show how to install the oandapy package and use it with IPython to connect to the Oanda API.


TradingView's Pine Script finally has loops

According to a blog post on TradingView, Pine Script finally offers the possibility to use loops - a language feater, a lot of traders where missing.


Welcome ForexPython!

This is the place where I'm going to share news, ideas and other content on algorithmic trading and related topics.

Blog posts will contain:

  • Articles on algorithmic trading tools and techniques
  • Reviews on related books
  • Reviews on software, indicator packages, expert advisors
  • Code samples for python and other languages that can be used for algorithmic trading
  • Articles on trading strategies and how to automate them