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

1from typing import List, Optional 

2from datetime import datetime 

3from pydantic import BaseModel, RootModel, Field, NaiveDatetime 

4 

5# Exchange 

6 

7 

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 

15 

16 

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] 

29 

30 

31class ExchangeTickerList(RootModel): 

32 root: List[ExchangeTicker] 

33 

34 def __iter__(self): 

35 return iter(self.root) 

36 

37 

38class ExchangeTickerFull(ExchangeTicker): 

39 BuyingOrders: Optional[List[ExchangeOrder]] 

40 SellingOrders: Optional[List[ExchangeOrder]] 

41 

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 

61 

62 

63class ExchangeTickerFullList(RootModel): 

64 root: List[ExchangeTickerFull] 

65 

66 def __iter__(self): 

67 return iter(self.root) 

68 

69 

70# Order 

71 

72 

73class OrderDefinition(BaseModel): 

74 Count: int 

75 Cost: float 

76 

77 

78class Order(BaseModel): 

79 Ticker: str = Field(max_length=7) 

80 Buys: Optional[List[OrderDefinition]] 

81 Sells: Optional[List[OrderDefinition]] 

82 

83 

84class OrderList(RootModel): 

85 root: List[Order] 

86 

87 def __iter__(self): 

88 return iter(self.root)