That’s where the automated trading system comes into play.
In this article, we will discuss a framework for building the automated system.
And then, in following articles, we will build that system, piece-by-piece in Python.
Developing StrategiesTo build an automated trading system (ATS), one must first have a strategy or basket of strategies for stock selection.
We’re trying to automate a trader’s thinking.
If you can match or outperform index funds year-over-year you are doing something right.
You do not need out of this world returns to be a great trader or investor.
Sourcing trading strategies is not the most difficult thing in the world.
Of course, your own strategy developed from the ground up that performs well and produces reliable returns is preferable.
But oftentimes, some of the best strategies exist in the public sphere.
Of course, this runs the risk of washing out returns as the strategy goes mainstream.
But oftentimes, solid strategies fly right under the radar.
Here are some websites I frequent that I love to learn from and generate ideas for testing:https://quantocracy.
com/ (will certainly have to dig through the mud to find worthwhile strategies, but they’re here, just need to get past some of the less quantitative opinions)https://www.
aspx?sort=topic — great source for reading various research from professors, browse to desired topic and you can oftentimes find papers that study asset pricing relative to various economic factorsThe biggest thing I’ve learned with generating ideas, especially from the first two sites listed, collaboration is so so important.
When you have ideas, it is so valuable to discuss those ideas with other intelligent, right-minded individuals.
Grounded thinkers can usually point out holes or missing parts of your argument that must first be justified before putting your idea into practice.
At these sites listed, you can find all sorts of ideas and approaches that can serve as a baseline for how you develop your strategies.
Technology StackUnderstanding the technologies necessary for building your system is obviously a vital first step.
At the baseline, you must identify the programming languages, libraries, and tools you will leverage to make your system come together.
You need to identify where you will be gathering your data from.
You need to identify how you are going to process that data.
And you need to understand how you will leverage the technology to put trades into action.
Architecture for standard automated trading systemArguably the hardest part of this architecture is the data source.
Fortunately, more and more data sources are being made available every year that are democratizing financial data for non-industry people.
Many algorithmic folks prefer languages like C++ for their high performance and suitability for data-intensive tasks.
Personally, I prefer Python because it is what I am comfortable with, and I am not trading on the millisecond time frames that make languages like C++ necessary; although I understand the arguments for it and certainly understand there’s a reason job descriptions at firms like Citadel and Renaissance primarily include C++ (Python is creeping into many of these job descriptions as well).
The trading platform is completely dependent upon your needs.
Certain platforms are preferable depending on fee structure, available assets, customer service, and many other factors.
Most brokers will have some API for their simulated trading platform that will allow you to send and simulate trades from your language of choice.
Risk ManagementIt is definitely worth having a section on risk management.
It is no doubt that understanding and managing the risk of your strategies is vital.
Sure, maybe your strategy had huge returns this year.
But was that due to a sound strategy, or was it just lucky returns, garnered by taking on a massive risk profile.
There are many discussed industry standards around understanding risk, the most basic of which is standard deviation.
Standard DeviationStandard deviation measures the variance between each stock price in a set time period versus the mean stock price over that same period.
Standard DeviationBetaBeta provides a measure of the risk of a single asset relative to the entire market.
The wider market has a beta of 1.
Anything greater than one indicates higher volatility than the market; less than 1 indicates lower volatility than the market.
A beta of 1 indicates the asset moves in-step with the wider market.
Calculating BetaVaRValue at Risk (VaR) simply measures the probability of loss of an investment provided normal market conditions.
For example, if a given portfolio has a one-month 25% VaR of $100,000, this means there is a 25% chance the portfolio will lose 25% of its value in a one-month timeframe.
Portfolio managers will want to adjust their portfolio to a VaR that is suitable.
For example, someone near retirement would not want a high VaR as they need that money in retirement.
Someone with higher risk tolerance may not mind the higher probability of loss, provided this also allows for higher probability of high returns.
Sharpe RatioSharpe ratio is a widely used measure, developed by Nobel prize recipient William Sharpe.
It measures the performance of an asset, adjusting for its risk.
An automated trading system may seek to optimize certain metrics, and Sharpe Ratio is a popular one, for good reason.
Sharpe RatioIt looks a bit heavy, but it’s really quite simple.
Sharpe ratio can simply be measured as the expected value of the difference of the asset return minus the risk free rate, all divided by the standard deviation.
The risk free rate is the theoretical return rate which requires 0 risk.
This is usually defined as the 10-yr treasury rate (~2.
7% at time of writing).
A sharpe ratio of 1 is generally defined as acceptable, 2 being above average, and 3 being exceptionally good.
BacktestingYou may not want to wait for the markets in order to test your strategies.
This is where backtesting comes in.
Backtesting is the concept of testing your ideas on historical data.
Historical performance certainly doesn’t guarantee future returns, but it can go a long way towards growing confidence in your strategy.
With backtesting, you simply apply your strategy at a certain date, and test how that strategy would perform into the future.
Variance always plays a role, and we must be careful to not grow a biased view during our backtesting.
Make sure to test your idea on as many applicable stocks and situations as possible.
Then, when your satisfied with the results, see how your strategy matches up on live returns by simulating trades in real time, using your automated system.
ConclusionsWe discussed the basic outline for an automated trading system.
In future articles, we’ll dive deeper into the individual components.
The first topic of discussion will be connecting your program to an API for simulating trades and managing a simulated portfolio.
ReferencesValue at risk – WikipediaFor example, if a portfolio of stocks has a one-day 5% VaR of $1 million, that means that there is a 0.
orgSharpe ratio – WikipediaIn finance, the Sharpe ratio (also known as the Sharpe index, the Sharpe measure, and the reward-to-variability ratio)…en.
orgModern portfolio theory – WikipediaModern portfolio theory ( MPT), or mean-variance analysis, is a mathematical framework for assembling a portfolio of…en.