from dataclasses import dataclass
from datetime import datetime
from py_alpaca_api.models.model_utils import KEY_PROCESSORS, extract_class_data
@dataclass
[docs]
class AccountModel:
[docs]
options_approved_level: int
[docs]
options_trading_level: int
[docs]
regt_buying_power: float
[docs]
daytrading_buying_power: float
[docs]
effective_buying_power: float
[docs]
non_marginable_buying_power: float
[docs]
options_buying_power: float
[docs]
pending_transfer_in: float
[docs]
pattern_day_trader: bool
[docs]
transfers_blocked: bool
[docs]
trade_suspended_by_user: bool
[docs]
long_market_value: float
[docs]
short_market_value: float
[docs]
position_market_value: float
[docs]
maintenance_margin: float
[docs]
last_maintenance_margin: float
[docs]
intraday_adjustments: int
[docs]
pending_reg_taf_fees: float
############################################
# Data Class Account Conversion Functions
############################################
[docs]
def account_class_from_dict(data_dict: dict) -> AccountModel:
"""Converts a dictionary into an instance of the `AccountModel`.
Args:
data_dict (dict): A dictionary containing the data for the `AccountModel` instance.
Returns:
AccountModel: An instance of the `AccountModel` created from the provided dictionary.
"""
account_data = extract_class_data(data_dict, KEY_PROCESSORS, AccountModel)
return AccountModel(**account_data)