from pydantic import BaseModel, Field class Asset(BaseModel): id: str class_: str = Field(..., alias="class") exchange: str symbol: str name: str status: str tradable: bool marginable: bool maintenance_margin_requirement: int shortable: bool easy_to_borrow: bool fractionable: bool min_order_size: str min_trade_increment: str price_increment: str # get_all_assets class GetAllAssets(BaseModel): itemlist: list[Asset] GetAllAssetsSchema = { "itemlist": ( "itemlist", [ { "id": "id", "class": "class", "exchange": "exchange", "symbol": "symbol", "name": "name", "status": "status", "tradable": "tradable", "marginable": "marginable", "maintenance_margin_requirement": "maintenanceMarginRequirement", "shortable": "shortable", "easy_to_borrow": "easyToBorrow", "fractionable": "fractionable", "min_order_size": "minOrderSize", "min_trade_increment": "minTradeIncrement", "price_increment": "priceIncrement", } ], ) } # get_open_position class GetOpenPosition(BaseModel): asset_id: str symbol: str exchange: str asset_class: str = Field(..., alias="asset_class") asset_marginable: bool qty: str avg_entry_price: str side: str market_value: str cost_basis: str unrealized_pl: str unrealized_plpc: str unrealized_intraday_pl: str unrealized_intraday_plpc: str current_price: str lastday_price: str change_today: str qty_available: str class Position(BaseModel): asset_id: str symbol: str exchange: str asset_class: str asset_marginable: bool qty: str avg_entry_price: str side: str market_value: str cost_basis: str unrealized_pl: str unrealized_plpc: str unrealized_intraday_pl: str unrealized_intraday_plpc: str current_price: str lastday_price: str change_today: str qty_available: str # get_all_positions class GetAllPositions(BaseModel): itemlist: list[Position] GetAllPositionsSchema = { "itemlist": ( "itemlist", [ { "symbol": "symbol", "unrealized_pl": "unrealized_pl", "price": "current_price", "units": "qty", "side": "side", "value": "market_value", } ], ) } # get_account class GetAccount(BaseModel): id: str account_number: str status: str crypto_status: str currency: str buying_power: str regt_buying_power: str daytrading_buying_power: str effective_buying_power: str non_marginable_buying_power: str bod_dtbp: str cash: str accrued_fees: str pending_transfer_in: str portfolio_value: str pattern_day_trader: bool trading_blocked: bool transfers_blocked: bool account_blocked: bool created_at: str trade_suspended_by_user: bool multiplier: str shorting_enabled: bool equity: str last_equity: str long_market_value: str short_market_value: str position_market_value: str initial_margin: str maintenance_margin: str last_maintenance_margin: str sma: str daytrade_count: int balance_asof: str GetAccountSchema = { "id": "id", "account_number": "account_number", "status": "status", "crypto_status": "crypto_status", "currency": "currency", "buying_power": "buying_power", "regt_buying_power": "regt_buying_power", "daytrading_buying_power": "daytrading_buying_power", "effective_buying_power": "effective_buying_power", "non_marginable_buying_power": "non_marginable_buying_power", "bod_dtbp": "bod_dtbp", "cash": "cash", "accrued_fees": "accrued_fees", "pending_transfer_in": "pending_transfer_in", "portfolio_value": "portfolio_value", "pattern_day_trader": "pattern_day_trader", "trading_blocked": "trading_blocked", "transfers_blocked": "transfers_blocked", "account_blocked": "account_blocked", "created_at": "created_at", "trade_suspended_by_user": "trade_suspended_by_user", "multiplier": "multiplier", "shorting_enabled": "shorting_enabled", "equity": "equity", "last_equity": "last_equity", "long_market_value": "long_market_value", "short_market_value": "short_market_value", "position_market_value": "position_market_value", "initial_margin": "initial_margin", "maintenance_margin": "maintenance_margin", "last_maintenance_margin": "last_maintenance_margin", "sma": "sma", "daytrade_count": "daytrade_count", "balance_asof": "balance_asof", }