From d1eb7a9eaf5b45f8fe00f8f39e308d3421e3d80e Mon Sep 17 00:00:00 2001 From: Chihiro Hio Date: Tue, 20 Feb 2024 21:55:15 +0900 Subject: [PATCH] feat: rename options fields --- alpaca/trading/models.py | 14 ++++++++------ examples/options-trading-basic.ipynb | 9 +++++---- .../trading/trading_client/test_account_routes.py | 14 ++++++++------ 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/alpaca/trading/models.py b/alpaca/trading/models.py index 98934593..f8680579 100644 --- a/alpaca/trading/models.py +++ b/alpaca/trading/models.py @@ -493,9 +493,10 @@ class TradeAccount(ModelWithID): sma (Optional[str]): Value of Special Memorandum Account (will be used at a later date to provide additional buying_power) daytrade_count (Optional[int]): The current number of daytrades that have been made in the last 5 trading days (inclusive of today) - option_approved_level (Optional[int]): The option trading level that was approved for this account. + options_buying_power (Optional[str]): Your buying power for options trading + options_approved_level (Optional[int]): The options trading level that was approved for this account. 0=disabled, 1=Covered Call/Cash-Secured Put, 2=Long Call/Put. - option_trading_level (Optional[int]): The effective option trading level of the account. This is the minimum between account option_approved_level and account configurations max_option_trading_level. + options_trading_level (Optional[int]): The effective options trading level of the account. This is the minimum between account options_approved_level and account configurations max_options_trading_level. 0=disabled, 1=Covered Call/Cash-Secured Put, 2=Long """ @@ -529,8 +530,9 @@ class TradeAccount(ModelWithID): last_maintenance_margin: Optional[str] = None sma: Optional[str] = None daytrade_count: Optional[int] = None - option_approved_level: Optional[int] = None - option_trading_level: Optional[int] = None + options_buying_power: Optional[str] = None + options_approved_level: Optional[int] = None + options_trading_level: Optional[int] = None class AccountConfiguration(BaseModel): @@ -546,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_option_trading_level (Optional[str]): The desired maximum option trading level. 0=disabled, 1=Covered Call/Cash-Secured Put, 2=Long Call/Put. + max_options_trading_level (Optional[str]): The desired maximum options trading level. 0=disabled, 1=Covered Call/Cash-Secured Put, 2=Long Call/Put. """ dtbp_check: DTBPCheck @@ -557,7 +559,7 @@ class AccountConfiguration(BaseModel): suspend_trade: bool trade_confirm_email: TradeConfirmationEmail ptp_no_exception_entry: bool - max_option_trading_level: Optional[str] = None + max_options_trading_level: Optional[str] = None class CorporateActionAnnouncement(ModelWithID): diff --git a/examples/options-trading-basic.ipynb b/examples/options-trading-basic.ipynb index f72adf0c..b0bd146f 100644 --- a/examples/options-trading-basic.ipynb +++ b/examples/options-trading-basic.ipynb @@ -133,9 +133,10 @@ "outputs": [], "source": [ "# check trading account\n", - "# There are two new columns in the account object:\n", - "# - option_approved_level\n", - "# - option_trading_level\n", + "# There are trhee new columns in the account object:\n", + "# - options_buying_power\n", + "# - options_approved_level\n", + "# - options_trading_level\n", "acct = trade_client.get_account()\n", "acct" ] @@ -147,7 +148,7 @@ "outputs": [], "source": [ "# check account configuration\n", - "# - we have new field `max_option_trading_level`\n", + "# - we have new field `max_options_trading_level`\n", "acct_config = trade_client.get_account_configurations()\n", "acct_config" ] diff --git a/tests/trading/trading_client/test_account_routes.py b/tests/trading/trading_client/test_account_routes.py index 5dd1e1a2..1d963c2e 100644 --- a/tests/trading/trading_client/test_account_routes.py +++ b/tests/trading/trading_client/test_account_routes.py @@ -38,8 +38,9 @@ def test_get_account(reqmock: Mocker, trading_client: TradingClient): "trade_suspended_by_user": false, "trading_blocked": false, "transfers_blocked": false, - "option_approved_level": "1", - "option_trading_level": "1" + "options_buying_power": "262113.632", + "options_approved_level": "1", + "options_trading_level": "1" } """, ) @@ -48,8 +49,9 @@ def test_get_account(reqmock: Mocker, trading_client: TradingClient): assert reqmock.called_once assert isinstance(account, TradeAccount) - assert account.option_approved_level == 1 - assert account.option_trading_level == 1 + assert account.options_buying_power == "262113.632" + assert account.options_approved_level == 1 + assert account.options_trading_level == 1 def test_get_account_configurations(reqmock: Mocker, trading_client: TradingClient): @@ -65,7 +67,7 @@ def test_get_account_configurations(reqmock: Mocker, trading_client: TradingClie "pdt_check": "entry", "trade_confirm_email": "all", "ptp_no_exception_entry": false, - "max_option_trading_level": "1" + "max_options_trading_level": "1" } """, ) @@ -73,7 +75,7 @@ def test_get_account_configurations(reqmock: Mocker, trading_client: TradingClie account_configurations = trading_client.get_account_configurations() assert reqmock.called_once assert isinstance(account_configurations, AccountConfiguration) - assert account_configurations.max_option_trading_level == "1" + assert account_configurations.max_options_trading_level == "1" def test_set_account_configurations(reqmock: Mocker, trading_client: TradingClient):