Skip to content

Bug in the How To Trade script? #2

@alisalama

Description

@alisalama

Really like your work. Super interesting stuff and largely aligns with how I see trading. Nice stuff!


https://github.com/romanmichaelpaolucci/Quant-Guild-Library/blob/6a2ccea4ac4a176ab7a39dff7ae3041ac270ff0d/2025 Video Lectures/22. How to Trade/how_to_trade.ipynb#L256

As per youtube comment on https://www.youtube.com/watch?v=NqOj__PaMec, I think there is an issue in the "One Quant Trader " game.

  1. It seems to play for too long after the Probability has dropped below 50% and not lose enough.
  2. It also seems to pretty much always win when above 50% - so when Expected Probability = 1 it always wins.

Can see it at 9:35, it continues to play and win all the way up to step 400, whereas clearly the average past about 180 is below 50% and so it should lose for a bit and stop around 210. Can see similar behaviour in a lot of the others too.


I think this is the error you are returning the wealth_path from dynamic_probability_game, but then re-naming it returns, presumably by accident.

And so I think you are doing "prev_outcomes = (returns[t-window_size:t] > 0).astype(int)" where returns = last 30 cumulative returns, not individual last 30 flips.

def dynamic_probability_game(n_steps):
    ...
    return wealth_path, probabilities;

def adaptive_strategy(n_steps, window_size=30):
    """Simulate game with adaptive probability estimation."""
    returns, true_probs  = dynamic_probability_game(n_steps)

So you just need to change:

return wealth_path, probabilities;

to

return returns, probabilities

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions