10
10
from urllib3 import HTTPResponse
11
11
12
12
13
+ def get_locale (market_type : Union [SnapshotMarketType , str ]):
14
+ if market_type == SnapshotMarketType .STOCKS .value :
15
+ return "us"
16
+
17
+ return "global"
18
+
19
+
13
20
class SnapshotClient (BaseClient ):
14
21
def get_snapshot_all (
15
22
self ,
16
- market_type : Optional [ Union [str , SnapshotMarketType ] ],
23
+ market_type : Union [str , SnapshotMarketType ],
17
24
tickers : Optional [Union [str , List [str ]]] = None ,
18
25
params : Optional [Dict [str , Any ]] = None ,
19
26
raw : bool = False ,
@@ -29,7 +36,8 @@ def get_snapshot_all(
29
36
:param include_otc: Include OTC securities in the response. Default is false (don't include OTC securities).
30
37
:return: List of Snapshots
31
38
"""
32
- url = f"/v2/snapshot/locale/us/markets/{ market_type } /tickers"
39
+ locale = get_locale (market_type )
40
+ url = f"/v2/snapshot/locale/{ locale } /markets/{ market_type } /tickers"
33
41
if type (tickers ) is list :
34
42
tickers = "," .join (tickers )
35
43
return self ._get (
@@ -42,7 +50,7 @@ def get_snapshot_all(
42
50
43
51
def get_snapshot_direction (
44
52
self ,
45
- market_type : Optional [ Union [str , SnapshotMarketType ] ],
53
+ market_type : Union [str , SnapshotMarketType ],
46
54
direction : Union [str , Direction ],
47
55
params : Optional [Dict [str , Any ]] = None ,
48
56
include_otc : Optional [bool ] = False ,
@@ -60,7 +68,8 @@ def get_snapshot_direction(
60
68
:param include_otc: Include OTC securities in the response. Default is false (don't include OTC securities).
61
69
:return: List of Snapshots
62
70
"""
63
- url = f"/v2/snapshot/locale/us/markets/{ market_type } /{ direction } "
71
+ locale = get_locale (market_type )
72
+ url = f"/v2/snapshot/locale/{ locale } /markets/{ market_type } /{ direction } "
64
73
return self ._get (
65
74
path = url ,
66
75
params = self ._get_params (self .get_snapshot_direction , locals ()),
@@ -71,7 +80,7 @@ def get_snapshot_direction(
71
80
72
81
def get_snapshot_ticker (
73
82
self ,
74
- market_type : Optional [ Union [str , SnapshotMarketType ] ],
83
+ market_type : Union [str , SnapshotMarketType ],
75
84
ticker : str ,
76
85
params : Optional [Dict [str , Any ]] = None ,
77
86
raw : bool = False ,
@@ -85,7 +94,8 @@ def get_snapshot_ticker(
85
94
:param ticker: The ticker symbol.
86
95
:return: List of Snapshots
87
96
"""
88
- url = f"/v2/snapshot/locale/us/markets/{ market_type } /tickers/{ ticker } "
97
+ locale = get_locale (market_type )
98
+ url = f"/v2/snapshot/locale/{ locale } /markets/{ market_type } /tickers/{ ticker } "
89
99
return self ._get (
90
100
path = url ,
91
101
params = self ._get_params (self .get_snapshot_ticker , locals ()),
0 commit comments