University of Glasgow · FACULTY OF FINANCE

ACCFIN5277 Finance Programming in Python and Databases

- one subject, every graph, every model, every mark
12 Chapters52-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
The Complete Study & Assessment Guide · 2026/27

ACCFIN5277 Overview

Finance Programming in Python and Databases
— turn returns, matrices and Python code into answers you can defend
  • 15 credits
  • University of Glasgow
  • 2026/27 session
  • Postgraduate level
  • Individual portfolio

Finance Programming in Python and Databases is a postgraduate course at the University of Glasgow that joins three skills a quantitative finance role expects: the mathematics of returns and prices, the matrix language behind statistical models, and the Python code that turns both into reproducible numbers.

  • Assessed by One individual portfolio: online numerical answers plus a written reflective component.
  • Hardest step Keeping numerical answers inside a narrow marking tolerance from raw data to final figure.
  • Core habit Write each formula by hand, code it, then confirm both agree on a small case.
  • Mathematics thread Gross returns multiply, log returns add, and prices discount certain cash flows.
Why read this guide

What you get in the full ACCFIN5277 Study & Assessment Guide

  1. 12 chapters, 52 pages — every assessed topic
  2. 37 original practice questions, most with model answers
  3. 12 worked examples, solved the way ACCFIN5277 marks
  4. 19 computed figures, redrawn from the course’s own numbers
  5. Before-you-submit checklist for the Portfolio (100%) — what markers reward, what costs marks

Free on this page: assessment table, chapter map, one worked example, key terms, FAQ. The rest is in the full study & assessment guide.

ACCFIN5277 · University of Glasgow
An independent, AskSia-authored study guide. AskSia is not affiliated with, endorsed by, or sponsored by University of Glasgow; the course code and name are used for identification only.
Assessment

How ACCFIN5277 is assessed

ComponentWeightFormat
Portfolio (individual take-home project)100%One individual portfolio of 1,000 words and objective questions. The objective component is submitted online in a Moodle quiz format and marks numerical answers within a narrow tolerance; the reflective component carries explanations, derivations and comments. The project files supply cleaned datasets so that every student starts from the same data.

The 100% weight and the 1,000-word length are published on the official University of Glasgow course catalogue page; the two-component structure and the numerical tolerance rule come from the course introduction lecture.

ACCFIN5277 assessment structureOne individual portfolio worth 100 percent, made of an objective component entered as an online quiz and a reflective written component.Individual portfolio 100%Objective componentonline quiz answersReflective componentexplanations and derivations
The whole course mark comes from one individual portfolio, which combines numerical answers entered in an online quiz with a written reflective component; the portfolio brief on Moodle sets out how marks divide between the two parts.
Other students are asking · ACCFIN5277

What other students are asking about ACCFIN5277

Where can I find lecture notes or study guides for ACCFIN5277 at glasgow?
The ACCFIN5277 study guide in AskSia Library covers Finance Programming in Python and Databases in 12 chapters, with the assessment table, a chapter-by-chapter topic map, key terms and a worked example, free to read on this page.
Is there a final exam in ACCFIN5277?
No final exam is listed in the offering this AskSia Library guide is built from; ACCFIN5277 is assessed by Portfolio (individual take-home project) 100%.
What does ACCFIN5277 cover on compounding, log returns and rate conversion?
In AskSia Library's ACCFIN5277 guide, the Compounding, Log Returns and Rate Conversion chapter explains financial mathematics. Multi-period compounding, compounding frequency, continuous compounding, log returns and converting a rate between horizons.
What does ACCFIN5277 cover on arithmetic and geometric average returns?
In AskSia Library's ACCFIN5277 guide, the Arithmetic and Geometric Average Returns chapter explains financial mathematics. What each average answers, why volatility opens a gap between them, and how to annualise a track record.
What does ACCFIN5277 cover on discount factors, zero-coupon bonds and yields?
In AskSia Library's ACCFIN5277 guide, the Discount Factors, Zero-Coupon Bonds and Yields chapter explains financial mathematics. Present value, zero-coupon prices, annual and continuous yields, the yield curve and rolling short bonds.
Weights, dates and every chapter are set out with their sources further down this page.
Contents · every chapter, one map

What ACCFIN5277 covers

Twelve chapters follow the three course components: financial mathematics, financial statistics with linear algebra, and Python programming with NumPy, loops, functions and Matplotlib.

01

Returns, Dividends and Inflation

Financial mathematics. Gross and net returns, the dividend and price components of a stock return, and real returns after inflation.

Returns, Dividends and Inflation sets up the single quantity the rest of the course manipulates. A gross return is the amount you get back for each unit invested, and the net return is that ratio minus one.

  • Gross return R and net return r
  • Units, horizon and compounding frequency
  • Price and dividend parts of a stock return
  • Dividend yield, dividend growth and capital gain
  • Consumer price index and gross inflation
  • Exact real returns versus the subtraction shortcut
In the full guide: 3 pages · 2 practice questions · 1 figure
02

Compounding, Log Returns and Rate Conversion

Financial mathematics. Multi-period compounding, compounding frequency, continuous compounding, log returns and converting a rate between horizons.

Compounding, Log Returns and Rate Conversion covers how returns combine across time and how one rate is restated on another clock.

  • Chaining one-period gross returns
  • Reinvested dividends inside a compounded return
  • Nominal rates credited n times a year
  • Continuous compounding and the exponential limit
  • Log returns that add across periods
  • Aggregating versus annualising with R(h) to the power h'/h
In the full guide: 4 pages · 2 practice questions · 2 figures
03

Arithmetic and Geometric Average Returns

Financial mathematics. What each average answers, why volatility opens a gap between them, and how to annualise a track record.

Arithmetic and Geometric Average Returns separates two numbers that are often both called the average return.

  • Arithmetic average as a one-period expectation
  • Geometric average as realised compound growth
  • Geometric average via the mean log return
  • Arithmetic and geometric mean inequality
  • Half-variance approximation for the gap
  • Annualised returns for a multi-year track record
In the full guide: 3 pages · 2 practice questions · 2 figures
04

Discount Factors, Zero-Coupon Bonds and Yields

Financial mathematics. Present value, zero-coupon prices, annual and continuous yields, the yield curve and rolling short bonds.

Discount Factors, Zero-Coupon Bonds and Yields turns certain future payments into prices.

  • Discount factors under annual and continuous compounding
  • Zero-coupon bond prices as pure discount factors
  • Converting a zero price into annual and log yields
  • The yield curve and the term structure
  • Pricing coupon bonds as bundles of zeros
  • Rolling short bonds, liquidation risk and reinvestment risk
In the full guide: 4 pages · 2 practice questions · 2 figures
05

Law of One Price and Arbitrage

Financial mathematics. Replicating a coupon bond with zero-coupon bonds, pricing by no arbitrage and building the trade when prices disagree.

Law of One Price and Arbitrage explains why the zero-coupon prices of the previous chapter fix the price of every other certain stream of payments.

  • Replicating a coupon bond with zero-coupon bonds
  • The law of one price
  • Building the trade when a bond is cheap or rich
  • Formal definition of an arbitrage
  • Pricing by no arbitrage and its two propositions
  • Short selling through a reverse repurchase agreement
In the full guide: 3 pages · 2 practice questions · 1 figure
06

Vectors, Norms and Inner Products

Financial statistics. Vector notation, addition, transposes, inner products, the Euclidean norm, orthogonality and linear independence.

Vectors, Norms and Inner Products introduces the notation that the statistics half of the course is written in.

  • Column vectors, elements and dimension
  • Element-wise addition, subtraction and the axioms
  • Transpose and the inner product
  • Conformity of dimensions
  • Euclidean norm and orthogonality
  • Linear independence and functions of vectors
In the full guide: 3 pages · 2 practice questions · 1 figure
07

Matrix Rank, Determinants and Inverses

Financial statistics. Special matrices, transpose and trace, conformable products, rank, determinants, singularity and inversion.

Matrix Rank, Determinants and Inverses extends vectors into rectangular arrays and asks the question every regression depends on: can this matrix be inverted?

  • Special matrices: zero, one, diagonal, identity, tridiagonal
  • Transpose, symmetry and the trace
  • Elementary operations and linear dependence
  • Rank, determinant and singularity
  • Conformable products, Kronecker and Hadamard products
  • Inverse via adjugate and determinant
In the full guide: 4 pages · 2 practice questions · 2 figures
08

Projection Matrices and Quadratic Forms

Financial statistics. Idempotent and projection matrices in least squares, quadratic forms and tests of definiteness.

Projection Matrices and Quadratic Forms explains two pieces of matrix algebra that sit underneath every regression in the course. An idempotent matrix returns itself when squared, and the identity minus an idempotent matrix is idempotent as well.

  • Idempotent matrices and the identity minus M
  • Least squares coefficients and conformity of dimensions
  • Projection matrix and residual maker
  • Trace equals rank for a projection
  • Quadratic forms and symmetric coefficient matrices
  • Definiteness tests for 2×2 matrices
In the full guide: 3 pages · 2 practice questions · 1 figure
09

Matrix Calculus and Least Squares

Financial statistics. Gradients of linear and quadratic forms, the normal equations and the second-order check for the least squares estimator.

Matrix Calculus and Least Squares derives the estimator that appears throughout financial statistics.

  • Derivative rows and gradient columns
  • Transpose of a product and scalar swaps
  • Gradients of linear and quadratic forms
  • Jacobian of a vector-valued function
  • Normal equations from the first-order condition
  • Second-order check on X'X
In the full guide: 4 pages · 3 practice questions · 2 figures
10

Return Statistics with NumPy Arrays

Statistics and NumPy. Arrays, special matrices, random draws with a seed, mean, standard deviation, percentiles, stacking and reshaping.

Return Statistics with NumPy Arrays joins the financial statistics block to the first programming sessions.

  • Arrays as coded vectors of observations
  • Mean, standard deviation, minimum, maximum and percentiles
  • Population versus sample divisor with ddof
  • Histograms and the shape of daily returns
  • Seeded random numbers for reproducible simulation
  • Special matrices, stacking, reshaping and padding
In the full guide: 4 pages · 2 practice questions · 2 figures
11

Loops, Conditionals and Functions in Python

Python programming. For and while loops, if, elif and else, functions with parameters and several return values, and loops inside functions.

Loops, Conditionals and Functions in Python covers the control structures that turn single calculations into automated routines.

  • For loops over lists, arrays and ranges
  • While loops, stopping conditions and safety limits
  • If, elif and else branching and test order
  • Classifying returns into volatility buckets
  • Defining functions with parameters and return values
  • Returning several results as a tuple
In the full guide: 3 pages · 3 practice questions · 1 figure
12

Visualising Financial Data with Matplotlib

Python applications. Line plots, titles, labels and legends, bar charts, histograms, time series and moving-average overlays.

Visualising Financial Data with Matplotlib closes the programming block by turning computed numbers into charts that communicate.

  • Importing libraries and loading price data
  • Line plots of a price or index series
  • Titles, axis labels and legends
  • Bar charts for categories and histograms for distributions
  • Trailing moving-average overlays and their lag
  • Reproducible charts generated from code
In the full guide: 3 pages · 2 practice questions · 1 figure

The course outline describes three components. Financial Mathematics runs first, Financial Statistics follows, and Python Programming and Applications occupies the second half of the eight weekly sessions.

Weekly problem sets come from the end-of-chapter exercises in the two set textbooks, and the course also supplies a set of linear algebra notes and the NumPy and pandas manuals.

The mathematics block starts from a single definition, the gross return as the amount received per unit invested, and builds outward: dividend and capital-gain components, real returns after inflation, compounding at different frequencies, continuously compounded log returns, and the difference between arithmetic and geometric averages.

It then prices certain cash flows through zero-coupon bond prices, defines yields and the yield curve, and uses the law of one price to show why a coupon bond must cost the same as the matching portfolio of zero-coupon bonds.

The statistics block treats vectors and matrices as tools rather than abstractions: inner products as portfolio sums, rank and determinants as tests of whether a regression can be solved, projection matrices as the geometry of fitted values, and matrix derivatives as the route to the least squares estimator.

The programming block moves into NumPy arrays and summary statistics, loops and conditional statements, functions, and Matplotlib charts of real price data.

Assessment is a single individual portfolio worth the whole course mark. It combines objective numerical answers entered online, where precision decides the mark, with a written reflective component of explanations, derivations and comments.

This guide therefore trains two habits together: computing to the required precision, and explaining in words why the computation is the right one.

Worked example · free

Average four annual fund returns two ways

Q [6 marks]. A fund returns +12%, -8%, +5% and +9% in four consecutive years. Starting from £10,000, find the terminal value, the arithmetic and geometric average annual returns, and explain which average describes the realised growth. The marks shown here are an original practice weighting, not a university marking scheme.
Starting from £10,000, the blue path follows actual returns of +12%, -8%, +5% and +9% to £11,792.93; the green constant 4.21% path ends at the same £11,792.93, Starting from £10,000, the blue path follows actual returns of +12%, -8%, +5% and +9% to £11,792.93; the green constant 4.21% path ends at the same £11,792.93, while the dashed 4.50% arithmetic path overshoots to £11,925.19.01234£10,000£11,000£12,000arithmetic 4.50%geometric 4.21%actual pathyear
Starting from £10,000, the blue path follows actual returns of +12%, -8%, +5% and +9% to £11,792.93; the green constant 4.21% path ends at the same £11,792.93, while the dashed 4.50% arithmetic path overshoots to £11,925.19.
  • 1Convert each net return to a gross return: 1.12, 0.92, 1.05 and 1.09.
  • 2Multiply the gross returns to compound the four years: 1.12 × 0.92 × 1.05 × 1.09 = 1.1793, so £10,000 grows to £11,792.93.
  • 1The arithmetic average is (12 - 8 + 5 + 9) / 4 = 4.50% per year.
  • 2The geometric average is 1.1793 raised to the power 1/4, minus one, which equals 4.21% per year; compounding 4.21% for four years reproduces £11,792.93.
The terminal value is £11,792.93. The arithmetic average is 4.50% and the geometric average is 4.21%; only the geometric figure, compounded for four years, returns the actual terminal wealth, so it is the right description of realised growth.
Sia tip — Check the geometric average by compounding it back: 1.0421 to the fourth power must give the product of the gross returns.
Glossary

Key terms

Gross return
The amount received at the end of a period for each unit invested at the start, written as capital R.
Net return
The gross return minus one, so a gain of five per cent appears as 0.05.
Dividend yield
The dividend per share divided by the share price, one component of a total stock return.
Real return
A return measured in goods rather than currency, found by dividing the gross nominal return by gross inflation.
Log return
The natural logarithm of a gross return, which adds across periods instead of multiplying.
Geometric average return
The constant per-period return that compounds to the same terminal wealth as the actual sequence of returns.
Zero-coupon bond
A bond paying one fixed amount at maturity and nothing before, so its price is a pure discount factor.
Yield to maturity
The single constant annual rate that makes the discounted promised cash flows equal to the bond price.
Law of one price
The principle that two investments with identical payoffs must trade at identical prices.
Inner product
The sum of element-by-element products of two vectors of equal length, which always gives a scalar.
Matrix rank
The largest number of linearly independent rows or columns a matrix contains.
Projection matrix
A square, symmetric matrix that equals its own square and maps data onto fitted values in least squares.
NumPy array
A grid of numbers in Python on which arithmetic and statistics apply to every element at once.
FAQ

ACCFIN5277 FAQ

How hard is this course for someone new to coding?

The outline itself warns that newcomers must build from foundations: verbal reasoning first, then a conceptual framework, then the quantitative steps. The first half is mathematics and matrix algebra, while Python carries the second half. Students without programming experience should install Anaconda early, run the session notebooks line by line and keep a log of errors they meet.

How is the course assessed?

A single individual portfolio carries the full course weight. The official catalogue describes it as about 1,000 words plus objective questions. The introduction lecture explains two parts: an objective component entered as a Moodle quiz, and a reflective component of explanations, derivations and comments. Supplied project files contain cleaned datasets, so everyone starts from identical inputs.

Why does numerical precision matter so much in the portfolio?

Objective answers are marked correct only when they fall inside a narrow tolerance band around the true value. The introduction lecture gives a standard deviation example where a band of a few hundredths separates right from wrong. Rounding intermediate results, using the wrong variance divisor or slicing the wrong date range can each push an otherwise sound method outside that band.

What Python should I know before the programming weeks?

The course expects a working Anaconda installation with Jupyter, VS Code or Spyder. The programming sessions cover NumPy arrays and statistics, special matrices and random numbers, loops and conditional statements, user-defined functions, and Matplotlib charts built from downloaded share prices. Practising array slicing and writing small functions before the second half pays back quickly.

Can I use AI tools for the portfolio work?

The course policy permits AI and other tools but warns that blind use can produce values outside the accepted range. Beginners are discouraged from leaning on AI because they need to build the foundations themselves, while confident programmers are encouraged to use it carefully without losing their own skills. Always verify any generated code by recomputing a small case by hand.

Which topics deserve the most revision time?

Return arithmetic underpins everything: gross versus net, compounding, log returns and the two averages. Zero-coupon pricing and the law of one price come next, then rank, inverses and the least squares formula. Finally, practise turning each formula into NumPy code and checking it against a hand calculation, because the portfolio rewards exact numbers produced by working code.

How should I plan study across the eight weeks?

Treat each week as one closed loop. Read the set textbook chapter, attempt its end-of-chapter problems, then rebuild the lecture examples in a notebook with fresh numbers. Keep one personal reference notebook of tested functions for returns, discounting, matrix algebra and plotting, so the portfolio becomes assembly and checking rather than writing code from scratch.

Chapter questions

Questions students ask in each ACCFIN5277 chapter

Why does the course use gross returns instead of percentages?
Gross returns multiply cleanly across periods and keep limited liability visible, because a gross return can never fall below zero. Percentages are convenient for reporting, but every calculation in the course, from compounding to deflating, is simpler and less error-prone when you work with ratios close to one and convert to a percentage only at the end. Chapter 01 · Returns, Dividends and Inflation
Why do returns multiply over time instead of adding?
Each period's gain is earned on the balance left at the end of the previous period, including earlier gains. A pound that grows by 6% and then falls by 4% ends at 1.06 times 0.96, not at one plus the sum of the percentages. Adding net returns ignores this base effect and misstates multi-period performance. Chapter 02 · Compounding, Log Returns and Rate Conversion
Which average return should I report for a fund's past performance?
Report the geometric average when describing what investors actually earned over several years, because compounding that constant rate reproduces the fund's true cumulative growth. The arithmetic average answers a different question, namely the expected return in one randomly chosen period, and quoting it as historical growth overstates performance whenever returns varied. Chapter 03 · Arithmetic and Geometric Average Returns
Why is a zero-coupon bond price called a discount factor?
Because it pays exactly one unit at maturity and nothing else, its price per unit of face value is the amount you must give up today for that single certain payment. That is precisely what a discount factor measures, so every other bond can be built from zero prices and their maturities. Chapter 04 · Discount Factors, Zero-Coupon Bonds and Yields
What does the law of one price say about bonds?
It says that two investments delivering the same cash flows on the same dates must trade at the same price. A coupon bond can be copied by holding zero-coupon bonds for each coupon date and for maturity, so its price must equal the summed cost of those zeros, each weighted by the payment it replaces. Chapter 05 · Law of One Price and Arbitrage
What is the difference between an inner and an outer product?
Both multiply entries of two vectors, but the inner product transposes the first vector and adds the products into one number, while the outer product transposes the second and keeps every pairing in a square matrix. In finance the inner product gives totals such as portfolio value; the outer product appears later when building covariance-style tables. Chapter 06 · Vectors, Norms and Inner Products
How does a determinant relate to rank?
For a square matrix, a non-zero determinant means every row and column is linearly independent, so the rank equals the size and the matrix is full rank. A zero determinant means at least one column can be built from the others, the rank is smaller, and the matrix is singular. Computing the determinant is usually quicker than searching for combinations. Chapter 07 · Matrix Rank, Determinants and Inverses
What makes a matrix a projection matrix rather than just idempotent?
A projection matrix in the notes is idempotent and also symmetric. Idempotence alone means applying the matrix twice changes nothing more; symmetry adds that the discarded part is perpendicular to what is kept. The least squares matrix X(X'X)^-1X' has both properties, which is why fitted values and residuals are orthogonal, and why their squared lengths add up to the squared length of the data. Chapter 08 · Projection Matrices and Quadratic Forms
Is the derivative of a scalar function a row or a column?
In the notes the derivative of a scalar function with respect to a column vector is written as a row, called Df, and the gradient is its transpose, a column. Both carry the same partial derivatives. Keeping the distinction matters when you multiply the result by other matrices, because a row and a column do not conform in the same places. Chapter 09 · Matrix Calculus and Least Squares
Why load data into NumPy instead of working in a spreadsheet?
The course points out that code keeps the original file untouched, works on a copy in memory and records every step, so the full chain from input to output can be rerun. A spreadsheet edit is easy to make and hard to audit. In an assessment marked on numerical precision, being able to reproduce a figure exactly is worth more than speed. Chapter 10 · Return Statistics with NumPy Arrays
When should I use a while loop rather than a for loop?
Use a for loop when you know the sequence to visit, such as every price in a column. Use a while loop when the number of passes depends on the data, such as compounding until a target is met or repeating a calculation until it converges. In the second case always add a maximum pass count so a bad input cannot hang the program. Chapter 11 · Loops, Conditionals and Functions in Python
Do I need live Yahoo Finance data to practise plotting?
No. The session downloads share prices through a function built on the yfinance library, but any time series works for practice. The course market index file is a good choice because it never changes, so your chart and the numbers behind it can be compared with someone else's. Live downloads can differ from day to day as data providers revise histories. Chapter 12 · Visualising Financial Data with Matplotlib
Study strategy

How to prepare for the assessments

Study this course as one pipeline from definition to code. For every new idea, first write the defining equation on paper with its units and horizon, then compute one small case by hand, then reproduce that case in a Jupyter notebook, and only then scale the code to real data such as the course market index file.

This three-way agreement between paper, small code and full code is the best defence against the precision rule in the objective component. Build a personal function library as you go: gross and log returns, compounding and frequency conversion, the two averages, zero-coupon pricing and yields, matrix rank and inverse checks, least squares coefficients and a standard plotting routine.

Test each function on a case whose answer you already know. In the matrix weeks, always write the dimensions under every product before multiplying, because conformity errors are the most common failure in both algebra and NumPy. For the reflective component, practise explaining a result in two or three plain sentences: what was computed, why that method suits the question, and what the number means for an investor.

Keep raw data files unchanged and do all cleaning in code, so every result can be rerun from the start.

Study ACCFIN5277 with AI

Your AI Finance tutor for ACCFIN5277

Stuck on a hard ACCFIN5277 question? Sia is AskSia’s AI Finance tutor — ask any ACCFIN5277 Finance Programming in Python and Databases question and get a clear, step-by-step explanation grounded in how the course is actually taught and assessed. Read this whole study guide free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 26 of your subjects at University of Glasgow, plus 1,000+ more Bibles across the AskSia library.
Sia - your ACCFIN5277 tutor, unlimited, worked the way the exam marks it
The full 52-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$0.99 Trial
30-day money-back · cancel in one tap · how it works
ACCFIN5277 · Finance Programming in Python and Databases - independent study guide on the AskSia Library. More University of Glasgow subjects · Microeconomics across all universities