
Free first chapter
Pricing, Risk, and Portfolio Optimization from First Principles
Read the first chapter in your browser. It's free, with no account and no email needed.
Free to read. No account required.
Financial models can look like a wall of formulas, and a library call can hide what is really happening. If you want to understand pricing and risk rather than just run code, the best route is to derive the idea, implement it in Python, and check it against known results.
Financial Engineering with Python teaches that way. You begin with a reproducible workflow and environment, then move through time value of money and cash flow modeling, fixed income, bond pricing, and yield curves. You will learn derivatives foundations with binomial option pricing, then Black-Scholes, the Greeks, and hedging logic. Monte Carlo methods for derivatives come next, followed by portfolio theory and optimization. Risk gets its own chapters covering VaR, stress testing, and scenario analysis, along with the numerical methods that make the models work.
Work through the chapters in order. The book is designed to connect mathematical finance, numerical reasoning, and Python implementation instead of teaching those pieces separately.
Use a reproducible Python environment with NumPy, pandas, SciPy, Matplotlib, and testing support. Keep notebooks for exploration and scripts or modules for reusable implementations.
Do the derivation pass first, then implement the model, then validate it against known results or sanity checks. Treat assumptions as part of the lesson, not as footnotes.
A derivatives desk at a regional bank prices a structured note using a spreadsheet built three years ago by someone who has since left. The model produces a price. The trader quotes it to a client. Two weeks after the trade settles, the risk team discovers that the spreadsheet used a hardcoded volatility from 2019 and silently ignored a dividend schedule change. The mispricing costs the desk six figures.
This is not a technology failure. The spreadsheet computed exactly what it was told to compute. It is a workflow failure: no one verified the inputs, no one documented the assumptions, and no one validated the output against an independent benchmark before the price reached the client. The formula was correct. The process around it was not.
Financial engineering is not about knowing formulas. It is about building a workflow that connects market reality to model output through documented assumptions, tested implementations, and disciplined validation. This chapter establishes that workflow before any specific model is introduced.
Financial engineering is the application of mathematical methods and computational tools to problems in finance. That definition is accurate but incomplete. In practice, financial engineering is the discipline of building, implementing, and validating models that inform financial decisions — pricing, hedging, risk management, and portfolio construction.
The word engineering matters. Engineering disciplines do not simply derive equations. They build systems that work reliably under real-world conditions, with explicit tolerances, documented assumptions, and verification procedures. A civil engineer does not just compute the load-bearing capacity of a beam; they specify materials, account for environmental stress, and test the structure before anyone walks on it. Financial engineering operates under the same logic. A pricing model that produces a number is not finished until that number has been validated, its assumptions have been documented, and its limitations are understood.
Financial engineering spans four core activities. Each involves both mathematical reasoning and implementation discipline.
Valuation. Determining what a financial instrument is worth given current market conditions and a set of assumptions. Valuation is the foundation. Every other activity depends on the ability to assign defensible prices to instruments. Valuation models range from simple present-value calculations to Monte Carlo simulations of path-dependent derivatives.
Hedging. Constructing positions that offset specific risks in a portfolio. Hedging requires understanding how an instrument's value changes in response to market variables — interest rates, volatility, credit spreads, foreign exchange rates. The mathematical framework for hedging (sensitivity analysis, Greeks, replication arguments) builds directly on valuation models.
Risk measurement. Quantifying the potential for loss under various scenarios. Risk measurement includes Value at Risk (VaR), stress testing, scenario analysis, and sensitivity decomposition. Risk models consume valuation models as inputs: you cannot measure the risk of a position unless you can value it under different market states.
Portfolio construction. Selecting and sizing positions to achieve an investment objective subject to constraints. Portfolio construction draws on valuation (to understand what you own), risk measurement (to understand what can go wrong), and optimization (to find the best feasible allocation).
These four activities are not independent. They share mathematical foundations, data sources, and implementation infrastructure. A pricing function written for valuation will be reused for hedging sensitivities, risk scenario analysis, and portfolio analytics. This is why the workflow and project structure matter from the start: poorly organized code cannot support the interconnected demands of real financial engineering work.
Every financial model is a simplified representation of reality. Models are useful precisely because they are simpler than reality — they isolate the factors that matter most for a specific decision and ignore everything else. But simplification creates risk.
Model risk is the risk that a model produces incorrect outputs because its assumptions do not match the situation. Model risk is not a theoretical concern. It has caused billions of dollars in losses across the financial industry. The London Whale incident at JPMorgan in 2012, the mispricing of mortgage-backed securities before 2008, and countless smaller episodes all involved models that worked perfectly within their assumptions but were applied to situations where those assumptions broke down.
Assumptions are part of the model, not fine print. Every financial model carries assumptions about market behavior, instrument features, data quality, and mathematical approximations. When you build or use a model, you are implicitly asserting that these assumptions hold. If you cannot list the assumptions, you do not understand the model. If you have not tested what happens when the assumptions fail, you do not know how much to trust the output.
The practical implication is straightforward: every model implementation must carry explicit documentation of its assumptions, and every validation procedure must include checks that test whether those assumptions hold for the current application.
It helps to draw boundaries.
Financial engineering is not financial analysis. Financial analysts evaluate companies, interpret financial statements, and make investment recommendations. Financial engineers build the pricing and risk models that analysts may use as inputs, but the core skill set is mathematical modeling and implementation, not fundamental analysis.
Financial engineering is not algorithmic trading. Algorithmic trading systems execute trades based on signals, often at high frequency. Financial engineering provides the pricing and risk infrastructure that trading systems may consume, but trade execution, market microstructure, and latency optimization are separate disciplines.
Financial engineering is not data science applied to finance. Data science and financial engineering share tools (Python, statistics, numerical methods), but they ask different questions. A data scientist might predict stock returns from features. A financial engineer prices a derivative by constructing a replicating portfolio under no-arbitrage constraints. The reasoning frameworks are fundamentally different.
Valuation is the activity you will practice most in this book, and it follows a consistent workflow regardless of the instrument or model. Understanding this workflow before diving into specific models prevents the most common implementation failures.
The workflow has seven stages:
Before any computation, you must specify exactly what you are pricing. This sounds obvious, but ambiguity at this stage propagates through every subsequent step.
For a coupon bond, the instrument definition includes: face value, coupon rate, coupon frequency, maturity date, day-count convention, and any embedded options. For a European call option, the definition includes: underlying asset, strike price, expiration date, exercise style, and settlement convention.
The instrument definition should be precise enough that two independent analysts, given the same definition, would build the same cash-flow structure. If the definition is ambiguous — if "coupon rate" could mean annual or semi-annual, if the day-count convention is unspecified — the downstream computations will diverge.
Financial models can look like a wall of formulas, and a library call can hide what is really happening.
Free to read. No account required.