Source code for py_alpaca_api.models.account_model

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] id: str
[docs] account_number: str
[docs] status: str
[docs] crypto_status: str
[docs] options_approved_level: int
[docs] options_trading_level: int
[docs] currency: str
[docs] buying_power: float
[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] bod_dtbp: float
[docs] cash: float
[docs] accrued_fees: float
[docs] pending_transfer_in: float
[docs] portfolio_value: float
[docs] pattern_day_trader: bool
[docs] trading_blocked: bool
[docs] transfers_blocked: bool
[docs] account_blocked: bool
[docs] created_at: datetime
[docs] trade_suspended_by_user: bool
[docs] multiplier: int
[docs] shorting_enabled: bool
[docs] equity: float
[docs] last_equity: float
[docs] long_market_value: float
[docs] short_market_value: float
[docs] position_market_value: float
[docs] initial_margin: float
[docs] maintenance_margin: float
[docs] last_maintenance_margin: float
[docs] sma: float
[docs] daytrade_count: int
[docs] balance_asof: str
[docs] crypto_tier: int
[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)