Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug, sim] When prob(up) < 0.5, trader profit is always zero #708

Closed
trentmc opened this issue Mar 1, 2024 · 1 comment · Fixed by #712
Closed

[Bug, sim] When prob(up) < 0.5, trader profit is always zero #708

trentmc opened this issue Mar 1, 2024 · 1 comment · Fixed by #712
Assignees
Labels
Type: Bug Something isn't working

Comments

@trentmc
Copy link
Member

trentmc commented Mar 1, 2024

The issue

Via #684, I just created a new plot:

2d scatterplot of (a) model's prob_up vs (b) trader profit.

An example plot is below. It's from running: pdr sim ppss.yaml

The values with prob(up) > 0.5 make sense.

But for prob(up) < 0.5, they're all zero. Something's up.

Example plot

Screenshot 2024-03-01 at 11 33 22

@trentmc
Copy link
Member Author

trentmc commented Mar 1, 2024

The problem was:

In a pred_down scenario, it bought back the same # usdcoins, that it had initially sold the tokens for. So its tokcoin balance was improving (if predicting well) but not its usdcoin balance.

This is incorrect, assuming we want to improve the usdcoin balance.

To be correct: It needed to buy the same # tokcoins.

In the PR, the key fix is when the trader exits the trading position in the case of not pred_up.

Here's the old code:

            self._buy(trueprice_eth, usdcoin_amt_spend=usdcoin_amt_recd)

New code:

            # we'd sold, so buy back the same # tokcoins as we sold
            # (do *not* buy back the same # usdcoins! Not the same thing!)
            target_tokcoin_amt_recd = tokcoin_amt_send
            p = self.ppss.trader_ss.fee_percent
            usdcoin_amt_send = target_tokcoin_amt_recd * (1 - p) * trueprice
            tokcoin_amt_recd = self._buy(trueprice, usdcoin_amt_send)

trentmc added a commit that referenced this issue Mar 1, 2024
Fixes #708. The key fix is when the trader exits the trading position in the case of `not pred_up`. 

Related change made: removed Eth stuff from sim_engine. Why: this is _sim_ and doesn't deal with blockchain; the Eth stuff was hurting understandability, including my work to solve this ticket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant