2121class SnapshotResult :
2222 def __init__ (self , pb_snapshot ):
2323 self .basic = BasicResult (pb_snapshot .basic )
24+ self .last_trade_time = int (pb_snapshot .trade_time ) if pb_snapshot .trade_time else None
25+ self .price = Decimal (pb_snapshot .price ) if pb_snapshot .price else None
2426 self .open = Decimal (pb_snapshot .open ) if pb_snapshot .open else None
2527 self .high = Decimal (pb_snapshot .high ) if pb_snapshot .high else None
2628 self .low = Decimal (pb_snapshot .low ) if pb_snapshot .low else None
27- self .price = Decimal (pb_snapshot .price ) if pb_snapshot .price else None
28- self .pre_close = Decimal (
29- pb_snapshot .pre_close ) if pb_snapshot .pre_close else None
30- self .volume = Decimal (
31- pb_snapshot .volume ) if pb_snapshot .volume else None
32- self .change = Decimal (
33- pb_snapshot .change ) if pb_snapshot .change else None
34- self .change_ratio = Decimal (
35- pb_snapshot .change_ratio ) if pb_snapshot .change_ratio else None
29+ self .pre_close = Decimal (pb_snapshot .pre_close ) if pb_snapshot .pre_close else None
30+ self .close = Decimal (pb_snapshot .open ) if pb_snapshot .open else None
31+ self .volume = Decimal (pb_snapshot .volume ) if pb_snapshot .volume else None
32+ self .change = Decimal (pb_snapshot .change ) if pb_snapshot .change else None
33+ self .change_ratio = Decimal (pb_snapshot .change_ratio ) if pb_snapshot .change_ratio else None
34+ self .ext_trade_time = int (pb_snapshot .ext_trade_time ) if pb_snapshot .ext_trade_time else None
35+ self .ext_price = Decimal (pb_snapshot .ext_price ) if pb_snapshot .ext_price else None
36+ self .ext_high = Decimal (pb_snapshot .ext_high ) if pb_snapshot .ext_high else None
37+ self .ext_low = Decimal (pb_snapshot .ext_low ) if pb_snapshot .ext_low else None
38+ self .ext_volume = Decimal (pb_snapshot .ext_volume ) if pb_snapshot .ext_volume else None
39+ self .ext_change = Decimal (pb_snapshot .ext_change ) if pb_snapshot .ext_change else None
40+ self .ext_change_ratio = Decimal (pb_snapshot .ext_change_ratio ) if pb_snapshot .ext_change_ratio else None
41+ self .ovn_trade_time = int (pb_snapshot .ovn_trade_time ) if pb_snapshot .ovn_trade_time else None
42+ self .ovn_price = Decimal (pb_snapshot .ovn_price ) if pb_snapshot .ovn_price else None
43+ self .ovn_high = Decimal (pb_snapshot .ovn_high ) if pb_snapshot .ovn_high else None
44+ self .ovn_low = Decimal (pb_snapshot .ovn_low ) if pb_snapshot .ovn_low else None
45+ self .ovn_volume = Decimal (pb_snapshot .ovn_volume ) if pb_snapshot .ovn_volume else None
46+ self .ovn_change = Decimal (pb_snapshot .ovn_change ) if pb_snapshot .ovn_change else None
47+ self .ovn_change_ratio = Decimal (pb_snapshot .ovn_change_ratio ) if pb_snapshot .ovn_change_ratio else None
3648
3749 def get_basic (self ):
3850 return self .basic
3951
52+ def get_last_trade_time (self ):
53+ return self .last_trade_time
54+
55+ def get_price (self ):
56+ return self .price
57+
4058 def get_open (self ):
4159 return self .open
4260
@@ -46,12 +64,12 @@ def get_high(self):
4664 def get_low (self ):
4765 return self .low
4866
49- def get_price (self ):
50- return self .price
51-
5267 def get_pre_close (self ):
5368 return self .pre_close
5469
70+ def get_close (self ):
71+ return self .close
72+
5573 def get_volume (self ):
5674 return self .volume
5775
@@ -61,9 +79,55 @@ def get_change(self):
6179 def get_change_ratio (self ):
6280 return self .change_ratio
6381
82+ def get_ext_trade_time (self ):
83+ return self .ext_trade_time
84+
85+ def get_ext_price (self ):
86+ return self .ext_price
87+
88+ def get_ext_high (self ):
89+ return self .ext_high
90+
91+ def get_ext_low (self ):
92+ return self .ext_low
93+
94+ def get_ext_volume (self ):
95+ return self .ext_volume
96+
97+ def get_ext_change (self ):
98+ return self .ext_change
99+
100+ def get_ext_change_ratio (self ):
101+ return self .ext_change_ratio
102+
103+ def get_ovn_trade_time (self ):
104+ return self .ovn_trade_time
105+
106+ def get_ovn_price (self ):
107+ return self .ovn_price
108+
109+ def get_ovn_high (self ):
110+ return self .ovn_high
111+
112+ def get_ovn_low (self ):
113+ return self .ovn_low
114+
115+ def get_ovn_volume (self ):
116+ return self .ovn_volume
117+
118+ def get_ovn_change (self ):
119+ return self .ovn_change
120+
121+ def get_ovn_change_ratio (self ):
122+ return self .ovn_change_ratio
123+
64124 def __repr__ (self ):
65- return "%s, open:%s, high:%s, low:%s, price:%s, pre_close:%s, volume:%s, change:%s, change_ratio:%s" \
66- % (self .basic , self .open , self .high , self .low , self .price , self .pre_close , self .volume , self .change , self .change_ratio )
125+ attrs = ['last_trade_time' , 'price' , 'open' , 'high' , 'low' , 'pre_close' , 'close' , 'volume' , 'change' , 'change_ratio' ]
126+ ext_attrs = [f"ext_{ name } " for name in ['trade_time' , 'price' , 'high' , 'low' , 'volume' , 'change' , 'change_ratio' ]]
127+ ovn_attrs = [f"ovn_{ name } " for name in ['trade_time' , 'price' , 'high' , 'low' , 'volume' , 'change' , 'change_ratio' ]]
128+ all_attrs = attrs + ext_attrs + ovn_attrs
129+ attr_str = ', ' .join (f"{ name } :{ getattr (self , name )} " for name in all_attrs )
130+ return f"{ self .basic } , { attr_str } "
67131
68132 def __str__ (self ):
69133 return self .__repr__ ()
0 commit comments