156 lines
3.5 KiB
Python
156 lines
3.5 KiB
Python
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]
|
|
|
|
|
|
# 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]
|
|
|
|
|
|
{
|
|
"itemlist": [
|
|
{
|
|
"asset_id": "64bbff51-59d6-4b3c-9351-13ad85e3c752",
|
|
"symbol": "BTCUSD",
|
|
"exchange": "FTXU",
|
|
"asset_class": "crypto",
|
|
"asset_marginable": False,
|
|
"qty": "0.009975",
|
|
"avg_entry_price": "20714",
|
|
"side": "long",
|
|
"market_value": "204.297975",
|
|
"cost_basis": "206.62215",
|
|
"unrealized_pl": "-2.324175",
|
|
"unrealized_plpc": "-0.0112484310128416",
|
|
"unrealized_intraday_pl": "-0.269325",
|
|
"unrealized_intraday_plpc": "-0.001316559391457",
|
|
"current_price": "20481",
|
|
"lastday_price": "20508",
|
|
"change_today": "-0.001316559391457",
|
|
"qty_available": "0.009975",
|
|
}
|
|
]
|
|
}
|
|
|
|
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 = {"": ""}
|