Skip to content

Commit

Permalink
fix: use int for max_options_trading_level of AccountConfiguration (#423
Browse files Browse the repository at this point in the history
)
  • Loading branch information
hiohiohio authored Mar 18, 2024
1 parent bd58705 commit 7b521ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion alpaca/trading/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def set_account_configurations(
if self._use_raw_data:
return response

return AccountConfiguration(**json.loads(response))
return AccountConfiguration(**response)

# ############################## WATCHLIST ################################# #

Expand Down
4 changes: 2 additions & 2 deletions alpaca/trading/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,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_options_trading_level (Optional[str]): The desired maximum options trading level. 0=disabled, 1=Covered Call/Cash-Secured Put, 2=Long Call/Put.
max_options_trading_level (Optional[int]): The desired maximum options trading level. 0=disabled, 1=Covered Call/Cash-Secured Put, 2=Long Call/Put.
"""

dtbp_check: DTBPCheck
Expand All @@ -559,7 +559,7 @@ class AccountConfiguration(BaseModel):
suspend_trade: bool
trade_confirm_email: TradeConfirmationEmail
ptp_no_exception_entry: bool
max_options_trading_level: Optional[str] = None
max_options_trading_level: Optional[int] = None


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

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


def test_set_account_configurations(reqmock: Mocker, trading_client: TradingClient):
Expand All @@ -89,11 +89,12 @@ def test_set_account_configurations(reqmock: Mocker, trading_client: TradingClie
"pdt_check": "both",
"trade_confirm_email": "all",
"ptp_no_exception_entry": False,
"max_options_trading_level": 1,
}
)
reqmock.patch(
f"{BaseURL.TRADING_PAPER.value}/v2/account/configurations",
json=json.dumps(new_account_configurations.model_dump()),
json=new_account_configurations.model_dump(),
)

account_configurations = trading_client.set_account_configurations(
Expand Down

0 comments on commit 7b521ee

Please sign in to comment.