A small script that reads open FX positions and flags anything drifting past a set threshold — before month-end close finds it for you.
This is a personal, non-commercial side project I built to learn — not a product or service, and not connected to any company I work with.
Post #9 walked through why an FX loss stays invisible until month-end close: an invoice gets booked at one rate, on one day, and nothing re-checks that rate again until the payment lands and someone reconciles it, weeks later.
This script is the small, personal experiment I put together to see what a daily check would actually need to compute. It doesn't trade anything and doesn't touch a real account — it just reads a list of open positions and does the one comparison nobody runs until close.
"None of this needs to be complicated. It just needs to run before the rate has finished moving, not after."
| ID | Client | Pair | Amount | Booked | Current | Variance | Flag |
|---|---|---|---|---|---|---|---|
| FX-01 | Iota Digital | EUR/USD | 95,000 | 1.0750 | 1.1100 | −€2,786.51 | ⚠ Flag |
| FX-05 | Xi Manufacturing | EUR/USD | 61,000 | 1.0800 | 1.1150 | −€1,772.96 | ⚠ Flag |
| FX-04 | Nu Consulting | EUR/CHF | 27,000 | 0.9550 | 0.9700 | −€437.20 | Clear |
| FX-02 | Kappa Logistics | EUR/GBP | 42,000 | 0.8600 | 0.8550 | +€285.60 | Clear |
Real output from running the script below against the sample CSV, threshold set to ±2.0% — see the full run further down.
# Clone the repo
git clone https://github.com/LuliBobo/cfo-agents.git
cd cfo-agents
# position_id,client,currency_pair,amount_foreign,booked_rate,current_rate,invoice_date FX-01,Iota Digital,EUR/USD,95000,1.0750,1.1100,2026-07-15 FX-02,Kappa Logistics,EUR/GBP,42000,0.8600,0.8550,2026-07-22
python fx_monitor_agent.py data/fx_positions.csv --threshold 2.0
================================================================ FX Monitoring Agent — Open Position Check ================================================================ [Step 1] Loaded 6 open position(s) from CSV [Step 2] Comparing booked rate vs current rate for each position [Step 3] Flagging anything past ±2.0% variance FX-01 Iota Digital EUR/USD 1.0750 1.1100 −2,786.51 −3.15% ⚠ FLAG FX-05 Xi Manufacturing EUR/USD 1.0800 1.1150 −1,772.96 −3.14% ⚠ FLAG [Step 4] 2 of 6 position(s) flagged [Step 5] Net unrealized FX variance: €−4,622.49
A plain CSV of open positions. Export it from anywhere or type it by hand.
fx_positions.csv → Python
Standard-library Python — no external packages, no API keys required to run it.
python3 fx_monitor_agent.py
A configurable percentage decides what gets flagged versus what's normal noise.
--threshold 2.0
Nothing here touches a real account, a bank feed, or a trading platform — sample data only.
0 API keys
The FX Monitoring Agent lives in the same personal, non-commercial repository as the earlier demos in this series.
Post #10 stays with money already in the business — cash sitting in the account, earning nothing, for reasons that have nothing to do with not knowing better.
No spam. One post per week. Unsubscribe any time.