Skip to main content
KBS_Icon_questionmark link-ico

Algorithmic Finance

Key information

  • Module code:

    5QQMN534

  • Level:

    5

  • Semester:

      Spring

  • Credit value:

    15

Module description

What is the module about?

This module aims to introduce the students to various aspects of computer science applied to accounting and finance.

It will cover the main aspects of Python programming and algorithms used in finance.

Students will learn to write, critically assess, and correct computer programs and algorithms commonly used in accounting and finance.

It will discuss topics such as financial data extraction techniques with popular libraries, financial data analytics, financial algorithms, time series analysis, financial data processing & data visualization, input / output (IO) operations for “big data” analytics, algorithmic trading, statistical analysis including linear regression and factor models and algorithmic portfolio management.

Who should do this module?

Students who are interested in technical Python programming / coding and “hands on” practical financial data analytics and learning important financial algorithms specifically applied to accounting and finance.

 

Provisional Workshop Outline

Workshop 1: Mastering Basics - Numerical Computing with NumPy

• NumPy Introduction

• Arrays of Data

• Arrays with Python Lists

• Python array class

• Regular NumPy Arrays

• The Basics

• Multiple Dimensions

• Metainformation

• Reshaping and Resizing

• Boolean Arrays

• List Comprehension

• Speed Comparison

• Structured NumPy Arrays

• Vectorization of Code

• Basic Vectorization

• Memory Layout

• Conclusion

Workshop 2: Introduction to Data Analysis with Pandas

• Introduction to Pandas Data Structures

• Series

• DataFrame

• Index Objects

• Essential Functionality

• Reindexing,

• Dropping Entries

• Indexing, selection and filtering

• Data Alignment

• Function Mapping

• Sorting and Ranking

• Descriptive Statistics

• Correlation and Covariance

Workshop 3: Mastering Basics – Financial Data Analysis with Pandas

• Data Analysis with Pandas

• The DataFrame Class

• First Steps with a DataFrame Class

• * .loc and .iloc functions

• Second Steps with a DataFrame Class

• Basic Analytics

• Basic Visualisation

• The Series Class

• GroupBy Operations

• Complex Selection

• Concatenation, Joining and Merging

• Performance Aspects

• Conclusion

Workshop 4: Data Visualisation

• Data Visualisation

• Static 2D Plotting

• One Dimensional Data Sets

• Two Dimensional Data Sets

• Other plot styles

• Static 3D Plotting

• Interactive 2D Plotting

• Basic Plots

• Financial Plots (OHLC Candlesticks, Bollinger Bands, RSI)

• Conclusion

Workshop 5: Financial Data Extraction and Time Series Analysis

• Financial Data

• Data Import

• Summary Statistics

• Changes over Time

• Resampling

• Rolling Statistics

• AN overview

• Technical Analysis Example

• Correlation Analysis

• The Data

• Logarithmic Returns

• OLS Regression

• Correlation

• High Frequency Data

• Conclusion

EXTRA

Importing Data: Yahoo Finance

Importing Data: Pandas DataReader (v0.9)

Importing Data: Quandl

Importing Data: Alpha Vantage

Importing Data: Tiingo
Workshop 6: Financial Data Pre-processing

• Handling Missing Data

• Filtering Out Missing Data

• Filling Missing Data

• Data Transformation

• Removing Duplicates

• Transforming Data

• Replacing Values

• Renaming Indexes

• Detecting Filtering Outliers

• Converting prices to returns

• Introduction

• How to do simple and log returns

• Inflation Adjusted Returns

• Changing Frequency

• Introduction

• Monthly Volatility from Daily Returns

• Visualising Time Series Data

• Plot method of pandas

• Plotly and cufflinks

• Identifying outliers

• Investigating Stylized Facts of Asset Returns

• Non-Gaussian Distribution of Returns

• Volatility Clustering

• Absence of Autocorrelation in Returns

• Small and decreasing Autocorrelation in squared / absolute Returns

• Leverage Effect

Workshop 7: Input / Output Operations (Big Data Analytics)

• Basic I/O with Python

• Writing Objects to Disks

• Reading and Writing Text Files

• Working with SQL Databases

• Writing and Reading NumPy Arrays

• I/O with Pandas

• Working with SQL Databases

• From SQL to pandas

• Working with Csv Files

• Working with Excel Files

• I/O with PyTables

• Working with Tables

• Working with Compressed Tables

• Working with Arrays

• Out of Memory Computations

• I/O with TsTables

• Sample Data

• Data Storage

• Data Retrieval

• Conclusion

Workshop 8: Trading Strategies, Technical Analysis and Backtesting and FXCM Trading Platform

• Types of Strategies

• Backtesting System Design Considerations

• Types of Backtesting Approaches

• Python Tools for Backtesting

• Major Backtesting Considerations / Pitfalls

• Strategy Improvements

Chapter 15

• Simple Moving Average (SMA)

• Data Import

• Trading Strategy

• Vectorized Backtesting

• Optimisation

• Random Walk Hypothesis

• Linear OLS Regression

• The Data

• Regression

• Portfolio Statistics / Metrics

Chapter 14

• Getting Started

• Retrieving Data

• Retrieving Tick Data

• Retrieving Candle Data

• Working with the API

• Retrieving Historical Data

• Retrieving Streaming Data

• Placing Orders

• Account Information

• Conclusion

Workshop 9: Statistical Analysis and OLS Regression: CAPM and Multifactor Models

• Implementing CAPM in Python

• Implementing Fama French Three Factor Model

• Implementing Rolling Fama French Three Factor Model

• Implementing the Four and Five Factor Model

Workshop 10: Portfolio Management and Optimisation
• Introduction to Portfolio Metrics and Formulas
• Portfolio Performance Evaluation
• Portfolio Optimisation in Excel
• Portfolio Optimisation in Python• The Theory

• Optimal Portfolios (Minimum Variance and Max Sharpe Ratio

• Efficient Frontier

Assessment details

75% Individual Project

25% Group Project

Teaching pattern

Weekly Lecture

Weekly Tutorials

Suggested reading list

Main books

• Yves Hilpisch - Python for Finance 2nd Edition 2019: Chapter 4, 5, 7, 8, 9, 13, 14, 15
• Eryk Lewinson - Python for Finance Cookbook 2020: Chapter 1 & 4
• Wes Mckinney - Python for Data Analysis 2nd Edition 2018 Chapter 5 & 7

Example online references:

https://pandas.pydata.org/pandas-docs/stable/index.html
https://numpy.org/doc/2.2/user/whatisnumpy.html
https://www.w3schools.com/python/default.asp

Subject areas

Department


Module description disclaimer

King’s College London reviews the modules offered on a regular basis to provide up-to-date, innovative and relevant programmes of study. Therefore, modules offered may change. We suggest you keep an eye on the course finder on our website for updates.

Please note that modules with a practical component will be capped due to educational requirements, which may mean that we cannot guarantee a place to all students who elect to study this module.

Please note that the module descriptions above are related to the current academic year and are subject to change.