Skip to content

Commit

Permalink
feat: Adjust account configuration (#403)
Browse files Browse the repository at this point in the history
* feat: adjust AccountConfiguration model

* feat: adjust unit test for account configurations

* fix: removed not used enum
  • Loading branch information
hiohiohio authored Jan 25, 2024
1 parent 9853fcb commit 03fb917
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion alpaca/trading/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class TradeConfirmationEmail(str, Enum):
"""
Used for controlling when an Account will receive a trade confirmation email.
please see https://alpaca.markets/docs/api-references/broker-api/trading/trading-configurations/#attributes
please see https://docs.alpaca.markets/reference/getaccountconfig
for more info.
"""

Expand Down
2 changes: 2 additions & 0 deletions alpaca/trading/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ class AccountConfiguration(BaseModel):
suspend_trade (bool): If true Account becomes unable to submit new orders
trade_confirm_email (TradeConfirmationEmail): Controls whether Trade confirmation emails are sent.
ptp_no_exception_entry (bool): If set to true then Alpaca will accept orders for PTP symbols with no exception. Default is false.
max_option_trading_level (Optional[str]): The desired maximum option trading level. 0=disabled, 1=Covered Call/Cash-Secured Put, 2=Long Call/Put.
"""

dtbp_check: DTBPCheck
Expand All @@ -554,6 +555,7 @@ class AccountConfiguration(BaseModel):
suspend_trade: bool
trade_confirm_email: TradeConfirmationEmail
ptp_no_exception_entry: bool
max_option_trading_level: Optional[str] = None


class CorporateActionAnnouncement(ModelWithID):
Expand Down
4 changes: 3 additions & 1 deletion tests/trading/trading_client/test_account_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,16 @@ def test_get_account_configurations(reqmock: Mocker, trading_client: TradingClie
"max_margin_multiplier": "4",
"pdt_check": "entry",
"trade_confirm_email": "all",
"ptp_no_exception_entry": false
"ptp_no_exception_entry": false,
"max_option_trading_level": "1"
}
""",
)

account_configurations = trading_client.get_account_configurations()
assert reqmock.called_once
assert isinstance(account_configurations, AccountConfiguration)
assert account_configurations.max_option_trading_level == "1"


def test_set_account_configurations(reqmock: Mocker, trading_client: TradingClient):
Expand Down

0 comments on commit 03fb917

Please sign in to comment.