In this chapter, we will cover the basics of technical analysis (TA) in Python. In short, TA is a methodology for determining (forecasting) the future direction of asset prices and identifying investment opportunities, based on studying past market data, especially the prices themselves and the traded volume.
We begin by introducing a simple way of visualizing stock prices using the candlestick chart. Then, we show how to calculate selected indicators (with hints on how to calculate others using selected Python libraries) used for TA. Using established Python libraries, we show how easy it is to backtest trading strategies built on the basis of TA indicators. In this way, we can evaluate the performance of these strategies in a real-life context (even including commission fees and so on).
At the end of the chapter, we also demonstrate how to create an interactive dashboard in Jupyter Notebook, which enables us to add and inspect the predefined TA indicators on the fly.
We present the following recipes in this chapter:
- Creating a candlestick chart
- Backtesting a strategy based on simple moving average
- Calculating Bollinger Bands and testing a buy/sell strategy
- Calculating the relative strength index and testing a long/short strategy
- Building an interactive dashboard for TA