Implementation-Shortfall Execution
Install and import
npm install fintech-algorithmsimport { implementationShortfallExecution } from "fintech-algorithms/execution-and-transaction-cost-analysis/cost-risk-optimization/implementation-shortfall-execution";Signature
implementationShortfallExecution(input)Minimises total shortfall against the arrival price, including the opportunity cost of quantity that never executes. Unexecuted quantity is a real cost, and a strategy measured only on filled shares hides it.
Parameters
| Name | Type | Notes |
|---|---|---|
input | ShortfallInput | Arrival price, quantity, impact and volatility parameters, and the urgency that trades impact against timing risk. |
Returns
{ schedule, expected_shortfall_bps, market_impact, timing_risk, opportunity_cost, … }
Shortfall decomposed into impact, timing risk and opportunity cost — the decomposition is what makes it actionable.
Errors
- When the arrival price is not positive — throws
Complexity: time O(steps),
space O(steps).
Worked example
executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.
Input
{
"remaining_quantity": 10000,
"side": "buy",
"decision_price_atoms": 1000000,
"current_price_atoms": 1001000,
"spread_bps": 4,
"impact_coefficient_bps": 35,
"average_daily_volume": 1000000,
"volatility_bps": 18,
"risk_aversion": 0.8,
"urgency_bps": 12,
"intervals_remaining": 8,
"max_child_quantity": 3000,
"candidate_step_quantity": 500,
"lot_size": 100
}Call
implementationShortfallExecution(input)Returns
object with 14 fields: side, decision_price_atoms, current_price_atoms, signed_move_bps, adverse_move_bps, remaining_quantity, selected_child_quantity, post_child_quantity, …
{
"side": "buy",
"decision_price_atoms": 1000000,
"current_price_atoms": 1001000,
"signed_move_bps": 10,
"adverse_move_bps": 10,
"remaining_quantity": 10000,
"selected_child_quantity": 3000,
"post_child_quantity": 7000,
"selected_total_score": 122453.181772,
"selected_immediate_cost_score": 6315,
"selected_opportunity_cost_score": 80500,
"selected_inventory_risk_score": 35638.181772,
"candidates": [
{
"child_quantity": 0,
"residual_quantity": 10000,
"immediate_cost_score": 0,
"opportunity_cost_score": 115000,
"inventory_risk_score": 50911.688245,
"total_score": 165911.688245
},
{
"child_quantity": 500,
"residual_quantity": 9500,
"immediate_cost_score": 1008.75,
"opportunity_cost_score": 109250,
"inventory_risk_score": 48366.103833,
"total_score": 158624.853833
},
{
"child_quantity": 1000,
"residual_quantity": 9000,
"immediate_cost_score": 2035,
"opportunity_cost_score": 103500,
"inventory_risk_score": 45820.519421,
"total_score": 151355.519421
}
],
"state": "execute-now"
}Other exports
This module also exports
almgrenChrissOptimalExecution, arrivalPriceExecution, liquiditySeekingExecution, opportunisticDarkPoolExecution, calculate. Every module additionally exports run as an alias of its
primary function, and a meta object carrying its catalog id, domain, family,
shape and article URL.
Diagrams
How it works
This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.
References
- The Implementation Shortfall: Paper versus Reality — Andre F. Perold
- Optimal Execution of Portfolio Transactions — Robert Almgren and Neil Chriss
- Staff Report on Algorithmic Trading in U.S. Capital Markets — Staff of the U.S. Securities and Exchange Commission
- FIX Algorithmic Trading Definition Language Online Specification — FIX Trading Community
- Evidence boundary