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

feat: Example of event trading framework using client. #34

Merged
merged 24 commits into from
Jun 30, 2023

Conversation

adamamsmith
Copy link
Contributor

@adamamsmith adamamsmith commented Jun 8, 2023

Demonstrate how to build an event based system around the client in rubi-py.

The most important components of this are:

  • the BaseEventTradingFramework which is the main loop of and just listens to and directs messages off the queue
  • the EventQueue's which ensure concurrent handling of events
  • and the ThreadedTransactionManager which allows placement of transactions in a concurrent manner

Still needs a lot of cleanup atm.

@adamamsmith adamamsmith added documentation Improvements or additions to documentation enhancement New feature or request labels Jun 8, 2023
@adamamsmith adamamsmith self-assigned this Jun 8, 2023
@adamamsmith adamamsmith changed the title Example of event trading framework using client. WIP: Example of event trading framework using client. Jun 8, 2023
@adamamsmith adamamsmith marked this pull request as draft June 8, 2023 07:31
@adamamsmith adamamsmith changed the title WIP: Example of event trading framework using client. feat: Example of event trading framework using client. Jun 29, 2023
@adamamsmith adamamsmith requested a review from bghughes June 29, 2023 09:10
@adamamsmith adamamsmith requested a review from ishandhanani June 29, 2023 09:10
@adamamsmith adamamsmith marked this pull request as ready for review June 29, 2023 09:11
@adamamsmith
Copy link
Contributor Author

adamamsmith commented Jun 29, 2023

Note that this changes a few things in the rubi client @denverbaumgartner @ishandhanani:

  1. A bug on place_market_order with worse_execution_price. The price wasn't multipleid by the order size which means most market orders failed

  2. An issue in _start_default_event_poller where the node deleted the filter and the poller continually errored but didn't do anything about it or notify the framework. Now the poller will recreate the filter.

  3. Some tinkering with the gas values of various methods on market.py

  4. Finally the client no longer throws and exception if a transaction fails but rather returns the transaction result. This allows better handling of failures where a trading framework can see the failure and then respond instead of crashing (up for more convo on this though)

Otherwise everything else is just additions!

starting_quote_asset_amount: Decimal,
starting_base_asset_average_price: Optional[Decimal],
# Grid
fair_price: Decimal,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed offline with @adamamsmith - the ability to update fair_price, with the necessary actions to happen when updated, will make this a very modular order management system that can be utilized in a variety ways!

@@ -15,3 +15,4 @@ token_addresses:
WETH: "0x4200000000000000000000000000000000000006"
OP: "0xCeE7148028Ff1B08163343794E85883174a61393"
USDC: "0xe432f229521eE954f80C83257485405E3d848d17"
USDT: "0xd70734ba8101ec28b38ab15e30dc9b60e3c6f433"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirmed, USDT address supported by the app. can't wait till we have a token list, will be a programmatic way to approach token validation. can even be a part of the CI pipeline

:return: the max approval amount of a uint256 token in Decimal representation
:rtype: Decimal
"""
max_uint256 = "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this totally works, was wondering if there is a reason we didn't do something like:
return self.to_decimal(number=2**256 - 1)

@@ -418,7 +418,7 @@ def batch_requote(
buy_amts: List[int],
buy_gems: List[ChecksumAddress],
nonce: Optional[int] = None,
gas: int = 3500000,
gas: int = 800000,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a cc to: #6

Copy link
Contributor

@denverbaumgartner denverbaumgartner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a really solid framework to build off of, had a good conversation offline with @adamamsmith about this and possible next steps. will turn some of the major points into tickets

@denverbaumgartner denverbaumgartner merged commit 26619d2 into master Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants