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

[Trader bot] Add approach1 to do simplistic trading #271

Closed
3 tasks done
idiom-bytes opened this issue Oct 21, 2023 · 0 comments · Fixed by #275
Closed
3 tasks done

[Trader bot] Add approach1 to do simplistic trading #271

idiom-bytes opened this issue Oct 21, 2023 · 0 comments · Fixed by #275
Labels
Type: Enhancement New feature or request

Comments

@idiom-bytes
Copy link
Member

idiom-bytes commented Oct 21, 2023

Status quo

The trader bot is implemented in predictoor/trader/trader_agent.py.

It has a do_trade() function.

  • It inputs two things:
    • the Feed object. Eg Binance ETH/USDT 5min
    • and the prediction: (amount staked up, amt staked down)
  • With those inputs, it trades according to its implemented strategy

Here's what the baseline do_trade() currently is:

 async def do_trade(feed: Feed, prediction: Tuple[float, float]):
    """
    @description
        This function is called each time there's a new prediction available.
        By default, it prints the signal.
        The user should implement their trading algorithm here.
    @params
        feed : Feed
            An instance of the Feed object.

        prediction : Tuple[float, float]
            A tuple containing two float values, the unit is ETH:
            - prediction[0]: Amount staked for the price going up.
            - prediction[1]: Total stake amount.
    @note
        The probability of the price going up is determined by dividing
        prediction[0] by prediction[1]. The magnitude of stake amounts indicates
        the confidence of the prediction. Ensure stake amounts
        are sufficiently large to be considered meaningful.
    """
    pred_nom, pred_denom = prediction
    print(f"      {feed} has a new prediction: {pred_nom} / {pred_denom}.")
    # Trade here
    # ...

The problem

Look at the bottom of do_trade(). It doesn't actually do any trading yet. Not even the simplest possible trading strategy: "buy if prediction is up; exit 5 min later".

We expect >1 trading strategies over time.

Predictoor bots handle this by having "approach1", "approach2", etc. We could do the same for trader bots.

DoD

  • Implement predictoor/trader/approach1/, where it implements do_trade() with the trading strategy: "buy if prediction is up; exit 5 min later".
  • Have good unit tests
  • Test that it works for real on mainnet

Related issues

  • pdr-backend#231 used to have "add strategy" plus "do backtesting". But 271 (this issue) does that. So 231 was de-scoped to just "do backtesting"
@idiom-bytes idiom-bytes added the Type: Enhancement New feature or request label Oct 21, 2023
@trentmc trentmc closed this as completed Oct 21, 2023
@trentmc trentmc reopened this Oct 21, 2023
@trentmc trentmc changed the title Implement naive trader Implement naive trader bot Oct 21, 2023
@trentmc trentmc changed the title Implement naive trader bot [trader] trader bot doesn't actually trade yet Oct 21, 2023
@trentmc trentmc changed the title [trader] trader bot doesn't actually trade yet [trader] baseline trader bot doesn't actually trade yet Oct 21, 2023
@trentmc trentmc changed the title [trader] baseline trader bot doesn't actually trade yet [trader bot] baseline trader bot doesn't actually trade yet Oct 21, 2023
@trentmc trentmc changed the title [trader bot] baseline trader bot doesn't actually trade yet [Trader bot] baseline trader bot doesn't actually trade yet Oct 21, 2023
@trentmc trentmc changed the title [Trader bot] baseline trader bot doesn't actually trade yet [Trader bot] Add strategy1 to do simplistic trading Oct 21, 2023
@trentmc trentmc changed the title [Trader bot] Add strategy1 to do simplistic trading [Trader bot] Add approach1 to do simplistic trading Oct 22, 2023
idiom-bytes added a commit that referenced this issue Nov 7, 2023
…esn't actually trade yet (#275)

* first pass

* cleaning up naive trader

* Completing MEXC integration

* Fixing CI/CD typesafe/lint/formatting errors

* Making tests pass w/ a mock binance implementation, while mexc remains e2e

* Fixing assert on len(settle_tokens)>1

* Fixing trader

* iterating on feedback

* Submitting tests although async tests for trader are currently skipping.

* Making async tests for trader_agent1 pass

* Adding pytest-asyncio to setup

* Fixing async test_take_step

* Fixing async tests such that CICD covers them

* Moved get_pred_properties test over to trader_agent

---------

Co-authored-by: idiom-bytes <idiom.bytes@gmail.com>
Co-authored-by: Idiom <69865342+idiom-bytes@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement New feature or request
Projects
None yet
2 participants