DEV Community

Roland HUON
Roland HUON

Posted on

An AI wrote this currency converter for my trading app. Would you merge it?

I asked Claude Opus 5.5 to build a personal trading dashboard: news, what to invest in, a confidence index, returns. Along the way it wrote the function that converts every position into my portfolio currency before computing totals.

Here it is, unedited:

@cached(ttl=3600)
def fx_rate(from_ccy: str, to_ccy: str) -> float:
    if not from_ccy or not to_ccy or from_ccy == to_ccy:
        return 1.0
    # Les cotations londoniennes sont en pence (GBp)
    factor = 1.0
    if from_ccy == "GBp":
        from_ccy, factor = "GBP", 0.01
    if from_ccy == to_ccy:
        return factor
    q = quotes([f"{from_ccy}{to_ccy}=X"])
    rate = next(iter(q.values()), {}).get("price")
    return (rate or 1.0) * factor
Enter fullscreen mode Exit fullscreen mode

(The comment is in French because I am. It says London quotes are in pence.)

What you need to know

quotes() is the market data helper:

quotes(["EURUSD=X"])   # β†’ {"EURUSD=X": {"price": 1.0874}}
quotes(["XXXUSD=X"])   # β†’ {}  when the provider fails or the symbol is unknown
Enter fullscreen mode Exit fullscreen mode

And this is roughly how it's used (simplified):

for p in positions:
    value = p.qty * p.price
    total += value * fx_rate(p.ccy, base_ccy)
Enter fullscreen mode Exit fullscreen mode

The session started from this prompt, which I wrote in French:

I want to build a platform to organise and plan my trading. I need to know about the news instantly, see what I can invest in, see the confidence index, how many people bought shares in it, the returns, etc. Plan what you need to set up for this.

Your call

You're the reviewer. Merge, request changes, or reject β€” and leave the one comment you'd actually post on the PR.

Start your comment with your decision in capitals: MERGE, CHANGES or REJECT. If you don't want to spoil it for others, you can hide the reasoning:

CHANGES
{% details my comment %}
your review comment here
{% enddetails %}
Enter fullscreen mode Exit fullscreen mode

One thing to keep in mind: flagging something that isn't actually wrong counts against you. Blocking a good PR has a cost too.

I'll post the answer on Friday, and go through every comment: the right call, the right reason, and the comments that looked convincing but weren't.

Top comments (0)