@@ -155,123 +155,117 @@ def test_get_snapshot_direction(self):
155155
156156 def test_get_snapshot_ticker (self ):
157157 snapshots = self .c .get_snapshot_ticker ("AAPL" )
158- expected = [
159- Snapshot (
160- day = {
161- "c" : 160.315 ,
162- "h" : 166.2 ,
163- "l" : 159.8 ,
164- "o" : 161.84 ,
165- "v" : 68840127 ,
166- "vw" : 162.7124 ,
167- },
168- last_quote = {
169- "P" : 159.99 ,
170- "S" : 5 ,
171- "p" : 159.98 ,
172- "s" : 3 ,
173- "t" : 1651251948407646487 ,
174- },
175- last_trade = {
176- "c" : None ,
177- "i" : "121351" ,
178- "p" : 159.99 ,
179- "s" : 200 ,
180- "t" : 1651251948294080343 ,
181- "x" : 12 ,
182- },
183- min = {
184- "av" : 68834255 ,
185- "c" : 160.3 ,
186- "h" : 160.71 ,
187- "l" : 160.3 ,
188- "o" : 160.71 ,
189- "v" : 197226 ,
190- "vw" : 160.5259 ,
191- },
192- prev_day = {
193- "c" : 163.64 ,
194- "h" : 164.515 ,
195- "l" : 158.93 ,
196- "o" : 159.25 ,
197- "v" : 130149192 ,
198- "vw" : 161.8622 ,
199- },
200- ticker = "AAPL" ,
201- todays_change = - 3.65 ,
202- todays_change_percent = None ,
203- updated = 1651251948294080343 ,
204- )
205- ]
158+ expected = Snapshot (
159+ day = {
160+ "c" : 160.315 ,
161+ "h" : 166.2 ,
162+ "l" : 159.8 ,
163+ "o" : 161.84 ,
164+ "v" : 68840127 ,
165+ "vw" : 162.7124 ,
166+ },
167+ last_quote = {
168+ "P" : 159.99 ,
169+ "S" : 5 ,
170+ "p" : 159.98 ,
171+ "s" : 3 ,
172+ "t" : 1651251948407646487 ,
173+ },
174+ last_trade = {
175+ "c" : None ,
176+ "i" : "121351" ,
177+ "p" : 159.99 ,
178+ "s" : 200 ,
179+ "t" : 1651251948294080343 ,
180+ "x" : 12 ,
181+ },
182+ min = {
183+ "av" : 68834255 ,
184+ "c" : 160.3 ,
185+ "h" : 160.71 ,
186+ "l" : 160.3 ,
187+ "o" : 160.71 ,
188+ "v" : 197226 ,
189+ "vw" : 160.5259 ,
190+ },
191+ prev_day = {
192+ "c" : 163.64 ,
193+ "h" : 164.515 ,
194+ "l" : 158.93 ,
195+ "o" : 159.25 ,
196+ "v" : 130149192 ,
197+ "vw" : 161.8622 ,
198+ },
199+ ticker = "AAPL" ,
200+ todays_change = - 3.65 ,
201+ todays_change_percent = None ,
202+ updated = 1651251948294080343 ,
203+ )
206204 self .assertEqual (snapshots , expected )
207205
208206 def test_get_snapshot_option (self ):
209207 snapshots = self .c .get_snapshot_option ("AAPL" , "O:AAPL230616C00150000" )
210- expected = [
211- OptionContractSnapshot (
212- break_even_price = 179.075 ,
213- day = {
214- "change" : - 2.3999999999999986 ,
215- "change_percent" : - 7.643312101910824 ,
216- "close" : 29 ,
217- "high" : 32.25 ,
218- "last_updated" : 1651204800000000000 ,
219- "low" : 29 ,
220- "open" : 29.99 ,
221- "previous_close" : 31.4 ,
222- "volume" : 8 ,
223- "vwap" : 30.7738 ,
224- },
225- details = {
226- "contract_type" : "call" ,
227- "exercise_style" : "american" ,
228- "expiration_date" : "2023-06-16" ,
229- "shares_per_contract" : 100 ,
230- "strike_price" : 150 ,
231- "ticker" : "O:AAPL230616C00150000" ,
232- },
233- greeks = {
234- "delta" : 0.6436614934293701 ,
235- "gamma" : 0.0061735291012820675 ,
236- "theta" : - 0.028227189324641973 ,
237- "vega" : 0.6381159723175714 ,
238- },
239- implied_volatility = 0.3570277203465058 ,
240- last_quote = {
241- "ask" : 29.25 ,
242- "ask_size" : 209 ,
243- "bid" : 28.9 ,
244- "bid_size" : 294 ,
245- "last_updated" : 1651254260800059648 ,
246- "midpoint" : 29.075 ,
247- "timeframe" : "REAL-TIME" ,
248- },
249- open_interest = 8133 ,
250- underlying_asset = {
251- "change_to_break_even" : 19.11439999999999 ,
252- "last_updated" : 1651254263172073152 ,
253- "price" : 159.9606 ,
254- "ticker" : "AAPL" ,
255- "timeframe" : "REAL-TIME" ,
256- },
257- )
258- ]
208+ expected = OptionContractSnapshot (
209+ break_even_price = 179.075 ,
210+ day = {
211+ "change" : - 2.3999999999999986 ,
212+ "change_percent" : - 7.643312101910824 ,
213+ "close" : 29 ,
214+ "high" : 32.25 ,
215+ "last_updated" : 1651204800000000000 ,
216+ "low" : 29 ,
217+ "open" : 29.99 ,
218+ "previous_close" : 31.4 ,
219+ "volume" : 8 ,
220+ "vwap" : 30.7738 ,
221+ },
222+ details = {
223+ "contract_type" : "call" ,
224+ "exercise_style" : "american" ,
225+ "expiration_date" : "2023-06-16" ,
226+ "shares_per_contract" : 100 ,
227+ "strike_price" : 150 ,
228+ "ticker" : "O:AAPL230616C00150000" ,
229+ },
230+ greeks = {
231+ "delta" : 0.6436614934293701 ,
232+ "gamma" : 0.0061735291012820675 ,
233+ "theta" : - 0.028227189324641973 ,
234+ "vega" : 0.6381159723175714 ,
235+ },
236+ implied_volatility = 0.3570277203465058 ,
237+ last_quote = {
238+ "ask" : 29.25 ,
239+ "ask_size" : 209 ,
240+ "bid" : 28.9 ,
241+ "bid_size" : 294 ,
242+ "last_updated" : 1651254260800059648 ,
243+ "midpoint" : 29.075 ,
244+ "timeframe" : "REAL-TIME" ,
245+ },
246+ open_interest = 8133 ,
247+ underlying_asset = {
248+ "change_to_break_even" : 19.11439999999999 ,
249+ "last_updated" : 1651254263172073152 ,
250+ "price" : 159.9606 ,
251+ "ticker" : "AAPL" ,
252+ "timeframe" : "REAL-TIME" ,
253+ },
254+ )
259255 self .assertEqual (snapshots , expected )
260256
261257 def test_get_snapshot_crypto_book (self ):
262258 snapshots = self .c .get_snapshot_crypto_book ("X:BTCUSD" )
263- expected = [
264- SnapshotTickerFullBook (
265- ticker = "X:BTCUSD" ,
266- bids = [
267- {"p" : 16303.17 , "x" : {"1" : 2 }},
268- {"p" : 16302.94 , "x" : {"1" : 0.02859424 , "6" : 0.023455 }},
269- ],
270- asks = [{"p" : 11454 , "x" : {"2" : 1 }}, {"p" : 11455 , "x" : {"2" : 1 }}],
271- bid_count = 694.951789670001 ,
272- ask_count = 593.1412981600005 ,
273- spread = - 4849.17 ,
274- updated = 1605295074162 ,
275- )
276- ]
259+ expected = SnapshotTickerFullBook (
260+ ticker = "X:BTCUSD" ,
261+ bids = [
262+ {"p" : 16303.17 , "x" : {"1" : 2 }},
263+ {"p" : 16302.94 , "x" : {"1" : 0.02859424 , "6" : 0.023455 }},
264+ ],
265+ asks = [{"p" : 11454 , "x" : {"2" : 1 }}, {"p" : 11455 , "x" : {"2" : 1 }}],
266+ bid_count = 694.951789670001 ,
267+ ask_count = 593.1412981600005 ,
268+ spread = - 4849.17 ,
269+ updated = 1605295074162 ,
270+ )
277271 self .assertEqual (snapshots , expected )
0 commit comments