Wrap API calls in helper and validate response
This commit is contained in:
0
core/lib/schemas/__init__.py
Normal file
0
core/lib/schemas/__init__.py
Normal file
105
core/lib/schemas/alpaca_s.py
Normal file
105
core/lib/schemas/alpaca_s.py
Normal file
@@ -0,0 +1,105 @@
|
||||
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]
|
||||
|
||||
# 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
|
||||
21
core/lib/schemas/drakdoo_s.py
Normal file
21
core/lib/schemas/drakdoo_s.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class DrakdooMarket(BaseModel):
|
||||
exchange: str
|
||||
item: str
|
||||
currency: str
|
||||
contract: str
|
||||
|
||||
|
||||
class DrakdooTimestamp(BaseModel):
|
||||
sent: int
|
||||
trade: int
|
||||
|
||||
|
||||
class DrakdooCallback(BaseModel):
|
||||
title: str
|
||||
message: str
|
||||
period: str
|
||||
market: DrakdooMarket
|
||||
timestamp: DrakdooTimestamp
|
||||
1
core/lib/schemas/oanda_s.py
Normal file
1
core/lib/schemas/oanda_s.py
Normal file
@@ -0,0 +1 @@
|
||||
from pydantic import BaseModel
|
||||
Reference in New Issue
Block a user