Implement more validation and conversion

This commit is contained in:
2022-11-04 07:20:14 +00:00
parent d34ac39d68
commit 60979652d9
8 changed files with 294 additions and 158 deletions

View File

@@ -24,6 +24,32 @@ 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
@@ -72,31 +98,6 @@ 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",
@@ -152,4 +153,39 @@ class GetAccount(BaseModel):
balance_asof: str
GetAccountSchema = {"": ""}
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",
}