Developing Intra Day Algorithmic Trading Applications

Intra Day Algorithmic Trading Applications are often referred to as trading robots.  These systems monitor a set of market indicators for a particular asset class and security to buy/sell then exit those positions based using those indicators.  The intent of this article isn’t to explain trading strategies, but how to build a trading robot.   The following core topics should be considered when building a trading robot.

Core Topics

1.       Have a trading strategy that is understood and vetted before you trade with real money.

2.       Understand the context of when your strategy is most successful.

3.       Know your data requirements and data sources.

4.       Select a trading platform with a supported API that meets data requirements and provides liquidity for your asset class.

5.       Start small and build through iterations

6.       Do not reinvent the wheel

Trading Strategy Development

If you are just getting started, this area can be quite intimidating.  My advice is to begin with something very simple.  Building on a well understood strategy is the best way to learn.  For Intra Day Strategies, it is difficult to test them without some sort of automation which is where a trading robot can be very valuable.  To get started, just copy a simple strategy, like the one below. 

Indicators Used -

EMA 9, 50 and 200 – Exponential Moving Average based on the last 9, 50 or 200 candles.  The ‘exponential’ prefix indicates that the most recent price in the candle is given more weight.  Again, a candle can be any amount of time, but it is best to select candle timeframes in whole minutes.

Stoch RSI is an abbreviation for Stochastic Relative Strength Indicator and it ranges from zero to 1.  I won’t go into the math, but the key is that it helps identify overbought and oversold situations. Our rule indicates that an RSI indicator below .30 is signaling an oversold condition.  The K line is the fast moving RSI moving average (usually < 3 candles) and the D line is the slow moving average (> 3 candles).

The strategy we are using will employ the following rules.

-          EMA 9 is higher than EMA 50 and EMA 50 is higher than EMA 200

-          STOCH RSI is below 30 trending and STOCH line K cross above D

-          Entry price: close of previous candle

-          Exit price when STOCH RSI line K crosses below D

Understanding The Context Of When Your Strategy Is Most Successful

The strategy above is inherently a bullish trading strategy, given it will trigger a buy trade when the short term EMA (9) is higher than the 50 and the 50 is higher than the 200.   So, knowing this, you would not want to turn on your trading robot during overly negative market sentiment.  This takes experience and patience, which is why you back test your strategy before you run into production.

Data Requirements and Data Sources

The data requirements are usually based on the indicators used and what is being traded.  For the indicators in our strategy, the Open, High, Low and Close values of the instrument being traded is all that is required.  This information is available for free from Yahoo Finance or other trading platforms (RobinHood, TD Ameritrade, E-Trade, etc.).  Again, for those beginners, you should pick a platform which has some prepackaged API modules in a computer language that is understood (ie. Python is very well supported across these three).

Trading Platform API’s

Selecting a trading platform (and the associated API) should be determined by what you are trading and number of trades you expect to generate.  If you are getting started with US Equities, it the best to learn with the platform API’s which are free (RobinHood, TD Ameritrade, E-Trade, etc.).   However, to just build something that doesn’t necessarily submit trades on an automated basis, you can build this in Excel to provide buy and sell signals.

Start Small And Build Through Iterations

My next post will provide an example bot using Excel for the trading strategy above for US Equities.  I will then migrate that to a working Python script using an API for buy and sell notifications, but it will not submit any trades in subsequent post.

Do Not Reinvent The Wheel

The are many examples of publicly available code for trading indicator calculations and using trading platform API’s.  I would suggest you search through the following repositories.

Github – Search for Robinhood, TD-Ameritrade or E-Trade (literally hundreds of examples)

https://developer.etrade.com/home

https://robin-stocks.readthedocs.io/en/latest/index.html

https://tda-api.readthedocs.io/en/latest/

https://developer.tdameritrade.com/apis

Previous
Previous

Excel Based Trading Algorithm

Next
Next

SEC Edgar 10-Q and 10-K Data Extracts