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

Drift rebalancer 5 #626

Merged
merged 15 commits into from
Nov 18, 2024
Merged

Drift rebalancer 5 #626

merged 15 commits into from
Nov 18, 2024

Conversation

brettelliot
Copy link
Collaborator

@brettelliot brettelliot commented Nov 15, 2024

This PR does two things (sorry - i found a bug and just fixed it).

  1. Refactors the DriftRebalancer stuff into components
  2. Fixes a bug in tradier_data. The recent changes i made to make tradier's get_historical_bars return the last N bars had an issue if you called it before market open. It would get one less bar then you asked for before market hours because it providded the last N bars from today... but before market hours there was no data for today. This is addressed now, and if you ask for data before market hours it will get you the last N bars excluding today. And it you ask for data during market hours, it will include todays bar in the N bars.

Description by Korbit AI

What change is being made?

Introduce a robust drift rebalancing framework with new components: DriftCalculationLogic, DriftRebalancerLogicBase, and LimitOrderDriftRebalancerLogic, and integrate these into a refactored DriftRebalancer strategy.

Why are these changes being made?

The changes enhance the drift rebalancing strategy by modularizing logic into distinct components for improved readability, maintainability, and testing. This refactoring addresses the need for a flexible and efficient approach to maintain target asset allocations, accounting for acceptable slippage and drift thresholds, and supports both rebalancing actions and limit order executions. The new framework also facilitates better testing and validation of each component's functionality, as evidenced by the added tests.

Is this description stale? Ask me to generate a new description by commenting /korbit-generate-pr-description

@brettelliot brettelliot requested a review from grzesir as a code owner November 15, 2024 00:56
Copy link
Contributor

korbit-ai bot commented Nov 15, 2024

Korbit doesn't automatically review large (500+ lines changed) pull requests such as this one. If you want me to review anyway, use /korbit-review.

Created a DriftRebalancerLogic to do all the things.
refactored tests for DriftCalculationLogic. Added relative drift_type
Remove the LimitOrder logic and baseOrder logic and replace with a singlular DriftOrderLogic that can handle limit and market orders
Added some tests for relative drift
Added tests for market orders in drift order logic
added pytest.ini to gitignore
update comments of drift rebalancer strategy
added check when current_weight and target_weight are zero (and test)
And more tests
@grzesir grzesir merged commit 5ba6c33 into dev Nov 18, 2024
1 check passed
@brettelliot brettelliot deleted the drift-rebalancer-5 branch November 18, 2024 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants