-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: draft rebalancing create portfolio * feat: get all portfolios and create subscription * feat: get portfolio by ID * feat: update portfolio by ID * feat: inactivate portfolio by ID * feat: get all subscriptions * feat: get subscription by ID * feat: delete subscription by ID * feat: manual run endpoint * feat: list all runs with page iteration * feat: get and cancel run endpoints * fix: pagination like other endpoints * fix: missing client docstrings * chore: adjust typing * chore: black * feat: adjust rebalancing --------- Co-authored-by: Chihiro Hio <[email protected]>
- Loading branch information
1 parent
ff70877
commit 9e6dcd9
Showing
8 changed files
with
1,387 additions
and
13 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
from .funding import * | ||
from .trading import * | ||
from .journals import * | ||
from .rebalancing import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from datetime import datetime | ||
from typing import List, Optional | ||
from uuid import UUID | ||
|
||
from alpaca.broker.enums import PortfolioStatus, RunInitiatedFrom, RunStatus, RunType | ||
from alpaca.broker.models import Order | ||
from alpaca.broker.requests import RebalancingConditions, Weight | ||
from alpaca.common.models import ValidateBaseModel as BaseModel | ||
|
||
|
||
class Portfolio(BaseModel): | ||
""" | ||
Portfolio response model. | ||
https://docs.alpaca.markets/reference/get-v1-rebalancing-portfolios | ||
""" | ||
|
||
id: UUID | ||
name: str | ||
description: str | ||
status: PortfolioStatus | ||
cooldown_days: int | ||
created_at: datetime | ||
updated_at: datetime | ||
weights: List[Weight] | ||
rebalance_conditions: Optional[List[RebalancingConditions]] = None | ||
|
||
|
||
class Subscription(BaseModel): | ||
""" | ||
Subscription response model. | ||
https://docs.alpaca.markets/reference/get-v1-rebalancing-subscriptions-1 | ||
""" | ||
|
||
id: UUID | ||
account_id: UUID | ||
portfolio_id: UUID | ||
created_at: datetime | ||
last_rebalanced_at: Optional[datetime] = None | ||
|
||
|
||
class SkippedOrder(BaseModel): | ||
""" | ||
Skipped order response model. | ||
https://docs.alpaca.markets/reference/get-v1-rebalancing-runs-run_id-1 | ||
""" | ||
|
||
symbol: str | ||
side: Optional[str] = None | ||
notional: Optional[str] = None | ||
currency: Optional[str] = None | ||
reason: str | ||
reason_details: str | ||
|
||
|
||
class RebalancingRun(BaseModel): | ||
""" | ||
Rebalancing run response model. | ||
https://docs.alpaca.markets/reference/get-v1-rebalancing-runs | ||
""" | ||
|
||
id: UUID | ||
account_id: UUID | ||
type: RunType | ||
amount: Optional[str] = None | ||
portfolio_id: UUID | ||
weights: List[Weight] | ||
initiated_from: Optional[RunInitiatedFrom] = None | ||
created_at: datetime | ||
updated_at: datetime | ||
completed_at: Optional[datetime] = None | ||
canceled_at: Optional[datetime] = None | ||
status: RunStatus | ||
reason: Optional[str] = None | ||
orders: Optional[List[Order]] = None | ||
failed_orders: Optional[List[Order]] = None | ||
skipped_orders: Optional[List[SkippedOrder]] = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.