2022-10-30 19:11:07 +00:00
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
2022-10-31 08:58:08 +00:00
|
|
|
|
2022-10-30 19:11:07 +00:00
|
|
|
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
|
|
|
|
|
2022-10-31 08:58:08 +00:00
|
|
|
|
2022-10-30 19:11:07 +00:00
|
|
|
# get_all_assets
|
|
|
|
class GetAllAssets(BaseModel):
|
|
|
|
itemlist: list[Asset]
|
|
|
|
|
2022-10-31 08:58:08 +00:00
|
|
|
|
2022-11-04 07:20:14 +00:00
|
|
|
GetAllAssetsSchema = {
|
|
|
|
"itemlist": (
|
|
|
|
"itemlist",
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"id": "id",
|
2022-11-06 07:20:32 +00:00
|
|
|
"class": "class_",
|
2022-11-04 07:20:14 +00:00
|
|
|
"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",
|
|
|
|
}
|
|
|
|
],
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-30 19:11:07 +00:00
|
|
|
# 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
|
|
|
|
|
2022-10-31 08:58:08 +00:00
|
|
|
|
2022-10-30 19:11:07 +00:00
|
|
|
# get_all_positions
|
|
|
|
class GetAllPositions(BaseModel):
|
|
|
|
itemlist: list[Position]
|
|
|
|
|
2022-10-31 08:58:08 +00:00
|
|
|
|
2022-11-04 07:20:55 +00:00
|
|
|
GetAllPositionsSchema = {
|
2022-11-02 18:25:34 +00:00
|
|
|
"itemlist": (
|
|
|
|
"itemlist",
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"symbol": "symbol",
|
|
|
|
"unrealized_pl": "unrealized_pl",
|
2022-11-02 19:04:05 +00:00
|
|
|
"price": "current_price",
|
2022-11-02 19:09:50 +00:00
|
|
|
"units": "qty",
|
|
|
|
"side": "side",
|
|
|
|
"value": "market_value",
|
2022-11-02 18:25:34 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-11-04 07:20:55 +00:00
|
|
|
|
2022-10-30 19:11:07 +00:00
|
|
|
# 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
|
2022-11-02 18:25:34 +00:00
|
|
|
|
|
|
|
|
2022-11-04 07:20:14 +00:00
|
|
|
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",
|
|
|
|
}
|