Coverage for fio_wrapper/models/exchange_models.py: 100%
63 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-16 11:50 +0100
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-16 11:50 +0100
1from typing import List, Optional
2from datetime import datetime
3from pydantic import BaseModel, RootModel, Field, NaiveDatetime
5# Exchange
8class ExchangeOrder(BaseModel):
9 OrderId: str = Field(min_length=32)
10 CompanyId: str = Field(min_length=32)
11 CompanyName: Optional[str]
12 CompanyCode: Optional[str]
13 ItemCount: Optional[int] # Market Maker ItemCount = null
14 ItemCost: float
17class ExchangeTicker(BaseModel):
18 MaterialTicker: str = Field(max_length=3)
19 ExchangeCode: str = Field(min_length=3)
20 MMBuy: Optional[float]
21 MMSell: Optional[float]
22 PriceAverage: Optional[float]
23 Ask: Optional[float]
24 AskCount: Optional[int]
25 Bid: Optional[float]
26 BidCount: Optional[int]
27 Supply: Optional[int]
28 Demand: Optional[int]
31class ExchangeTickerList(RootModel):
32 root: List[ExchangeTicker]
34 def __iter__(self):
35 return iter(self.root)
38class ExchangeTickerFull(ExchangeTicker):
39 BuyingOrders: Optional[List[ExchangeOrder]]
40 SellingOrders: Optional[List[ExchangeOrder]]
42 ExchangeName: str
43 CXDataModelId: str = Field(min_length=32)
44 MaterialName: str
45 MaterialId: str = Field(min_length=32)
46 Currency: str = Field(min_length=2)
47 Price: Optional[float]
48 PriceTimeEpochMs: Optional[datetime]
49 High: Optional[float]
50 AllTimeHigh: Optional[float]
51 Low: Optional[float]
52 AllTimeLow: Optional[float]
53 Traded: Optional[int]
54 VolumeAmount: Optional[float]
55 NarrowPriceBandLow: Optional[float]
56 NarrowPriceBandHigh: Optional[float]
57 WidePriceBandLow: Optional[float]
58 WidePriceBandHigh: Optional[float]
59 UserNameSubmitted: str
60 Timestamp: NaiveDatetime
63class ExchangeTickerFullList(RootModel):
64 root: List[ExchangeTickerFull]
66 def __iter__(self):
67 return iter(self.root)
70# Order
73class OrderDefinition(BaseModel):
74 Count: int
75 Cost: float
78class Order(BaseModel):
79 Ticker: str = Field(max_length=7)
80 Buys: Optional[List[OrderDefinition]]
81 Sells: Optional[List[OrderDefinition]]
84class OrderList(RootModel):
85 root: List[Order]
87 def __iter__(self):
88 return iter(self.root)