Decomposing Dual-Currency Trading Returns (USD vs COP) in Python

Leader ●1 ●15 ●39
calendar_today ago • schedule1 min read
— Originally published at guetaquant.com

Measuring trading performance solely in USD hides currency risk whenever living expenses, funding rails, and tax reporting are denominated in local currency such as Colombian Pesos (COP).

If you fund a USD account at exchange rate T_0, generate a dollar return r_USD, and withdraw at rate T_1, your true local-currency return r_COP follows a multiplicative relationship:

r_COP = r_USD + g_FX + (r_USD * g_FX)

where g_FX = (T_1 / T_0) - 1.

USD to COP currency risk and TRM return transformation diagram

For the full Spanish guide, official SFC TRM converter, and DIAN tax context, see Riesgo cambiario y TRM en trading desde Colombia.

Sensitivity matrix in Python

A +10% gain in USD during an 8% drop in USD/COP leaves only +1.20% real return in COP. Conversely, a -10% trading loss paired with an 8% peso appreciation compounds into -17.20% in local purchasing power.

def cop_return_matrix(usd_returns: list[float], fx_moves: list[float]) -> None:
    header = "USD \\ FX | " + " | ".join(f"{fx:+6.1%}" for fx in fx_moves)
    print(header)
    print("-" * len(header))
    for r_usd in usd_returns:
        row = [f"{(r_usd + fx + r_usd * fx):+6.2%}" for fx in fx_moves]
        print(f"{r_usd:+7.1%} | " + " | ".join(row))


cop_return_matrix([0.10, 0.05, -0.05, -0.10], [-0.08, 0.0, 0.08])

Official reference rate vs withdrawal rails

The official Colombian TRM certified by the Superintendencia Financiera is an interbank weighted average from the previous banking day, not an executable retail conversion price. Payment gateways, SWIFT wires, Rise/Wise rails, and stablecoin off-ramps add a conversion spread plus fixed transfer fees that should be deducted as funding friction in any net-return model.

Educational and quantitative analysis only (SFC Colombia Decreto 2555 de 2010). Not financial or tax advice.

Want more #python & #finance deep dives?

Join 6,132+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

More Posts

Local-First: The Browser as the Vault

Pocket Portfolio - Apr 20

Dashboard Operasional Armada Rental Mobil dengan Python + FastAPI

Masbadar - Mar 12

When One Python Process Fails, You Need to See All of Them

Tom Smithverified - Nov 23

The End of Data Export: Why the Cloud is a Compliance Trap

Pocket Portfolio - Apr 6

Stop trusting verdicts your policy no longer supports

VEACESLAV - Dec 1
chevron_left
1.8k Points • 55 Badges
Bogotá, Colombia • guetaquant.com
19Posts
2Comments
15Connections
Founder & Lead Quantitative Engineer at Gueta Quant (https://guetaquant.com).

I design open-source... Show more

Related Jobs

View all jobs →

Commenters (This Week)

4 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!