alpaca-py-nopandas 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- alpaca/__init__.py +2 -0
- alpaca/broker/__init__.py +8 -0
- alpaca/broker/client.py +2360 -0
- alpaca/broker/enums.py +528 -0
- alpaca/broker/models/__init__.py +7 -0
- alpaca/broker/models/accounts.py +347 -0
- alpaca/broker/models/cip.py +265 -0
- alpaca/broker/models/documents.py +159 -0
- alpaca/broker/models/funding.py +114 -0
- alpaca/broker/models/journals.py +71 -0
- alpaca/broker/models/rebalancing.py +80 -0
- alpaca/broker/models/trading.py +13 -0
- alpaca/broker/requests.py +1135 -0
- alpaca/common/__init__.py +6 -0
- alpaca/common/constants.py +13 -0
- alpaca/common/enums.py +64 -0
- alpaca/common/exceptions.py +47 -0
- alpaca/common/models.py +21 -0
- alpaca/common/requests.py +82 -0
- alpaca/common/rest.py +438 -0
- alpaca/common/types.py +7 -0
- alpaca/common/utils.py +89 -0
- alpaca/data/__init__.py +5 -0
- alpaca/data/enums.py +184 -0
- alpaca/data/historical/__init__.py +13 -0
- alpaca/data/historical/corporate_actions.py +76 -0
- alpaca/data/historical/crypto.py +299 -0
- alpaca/data/historical/news.py +63 -0
- alpaca/data/historical/option.py +230 -0
- alpaca/data/historical/screener.py +72 -0
- alpaca/data/historical/stock.py +226 -0
- alpaca/data/historical/utils.py +30 -0
- alpaca/data/live/__init__.py +11 -0
- alpaca/data/live/crypto.py +168 -0
- alpaca/data/live/news.py +62 -0
- alpaca/data/live/option.py +88 -0
- alpaca/data/live/stock.py +199 -0
- alpaca/data/live/websocket.py +390 -0
- alpaca/data/mappings.py +84 -0
- alpaca/data/models/__init__.py +7 -0
- alpaca/data/models/bars.py +83 -0
- alpaca/data/models/base.py +45 -0
- alpaca/data/models/corporate_actions.py +309 -0
- alpaca/data/models/news.py +90 -0
- alpaca/data/models/orderbooks.py +59 -0
- alpaca/data/models/quotes.py +78 -0
- alpaca/data/models/screener.py +68 -0
- alpaca/data/models/snapshots.py +132 -0
- alpaca/data/models/trades.py +204 -0
- alpaca/data/requests.py +580 -0
- alpaca/data/timeframe.py +148 -0
- alpaca/py.typed +0 -0
- alpaca/trading/__init__.py +5 -0
- alpaca/trading/client.py +784 -0
- alpaca/trading/enums.py +412 -0
- alpaca/trading/models.py +697 -0
- alpaca/trading/requests.py +604 -0
- alpaca/trading/stream.py +225 -0
- alpaca_py_nopandas-0.1.0.dist-info/LICENSE +201 -0
- alpaca_py_nopandas-0.1.0.dist-info/METADATA +299 -0
- alpaca_py_nopandas-0.1.0.dist-info/RECORD +62 -0
- alpaca_py_nopandas-0.1.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,168 @@
|
|
1
|
+
from typing import Awaitable, Callable, Dict, Optional, Union
|
2
|
+
|
3
|
+
from alpaca.common.enums import BaseURL
|
4
|
+
from alpaca.data.enums import CryptoFeed
|
5
|
+
from alpaca.data.live.websocket import DataStream
|
6
|
+
from alpaca.data.models.bars import Bar
|
7
|
+
from alpaca.data.models.orderbooks import Orderbook
|
8
|
+
from alpaca.data.models.quotes import Quote
|
9
|
+
from alpaca.data.models.trades import Trade
|
10
|
+
|
11
|
+
|
12
|
+
class CryptoDataStream(DataStream):
|
13
|
+
"""
|
14
|
+
A WebSocket client for streaming live crypto data.
|
15
|
+
"""
|
16
|
+
|
17
|
+
def __init__(
|
18
|
+
self,
|
19
|
+
api_key: str,
|
20
|
+
secret_key: str,
|
21
|
+
raw_data: bool = False,
|
22
|
+
feed: CryptoFeed = CryptoFeed.US,
|
23
|
+
url_override: Optional[str] = None,
|
24
|
+
websocket_params: Optional[Dict] = None,
|
25
|
+
) -> None:
|
26
|
+
"""
|
27
|
+
Instantiates a WebSocket client for accessing live cryptocurrency data.
|
28
|
+
|
29
|
+
Args:
|
30
|
+
api_key (str): Alpaca API key.
|
31
|
+
secret_key (str): Alpaca API secret key.
|
32
|
+
raw_data (bool, optional): Whether to return wrapped data or raw API data. Defaults to False.
|
33
|
+
feed (CryptoFeed, optional): Which crypto feed to use. Defaults to US.
|
34
|
+
websocket_params (Optional[Dict], optional): Any parameters for configuring websocket connection. Defaults to None.
|
35
|
+
url_override (Optional[str]): If specified allows you to override the base url the client
|
36
|
+
points to for proxy/testing. Defaults to None.
|
37
|
+
"""
|
38
|
+
super().__init__(
|
39
|
+
endpoint=(
|
40
|
+
url_override
|
41
|
+
if url_override is not None
|
42
|
+
else BaseURL.MARKET_DATA_STREAM.value + "/v1beta3/crypto/" + feed
|
43
|
+
),
|
44
|
+
api_key=api_key,
|
45
|
+
secret_key=secret_key,
|
46
|
+
raw_data=raw_data,
|
47
|
+
websocket_params=websocket_params,
|
48
|
+
)
|
49
|
+
|
50
|
+
def subscribe_trades(
|
51
|
+
self, handler: Callable[[Union[Trade, Dict]], Awaitable[None]], *symbols: str
|
52
|
+
) -> None:
|
53
|
+
"""Subscribe to trades.
|
54
|
+
|
55
|
+
Args:
|
56
|
+
handler (Callable[[Union[Trade, Dict]], Awaitable[None]): The coroutine callback
|
57
|
+
function to handle the incoming data.
|
58
|
+
*symbols: List of ticker symbols to subscribe to. "*" for everything.
|
59
|
+
"""
|
60
|
+
self._subscribe(handler, symbols, self._handlers["trades"])
|
61
|
+
|
62
|
+
def subscribe_quotes(
|
63
|
+
self, handler: Callable[[Union[Quote, Dict]], Awaitable[None]], *symbols: str
|
64
|
+
) -> None:
|
65
|
+
"""Subscribe to quotes
|
66
|
+
|
67
|
+
Args:
|
68
|
+
handler (Callable[[Union[Quote, Dict]], Awaitable[None]]): The coroutine callback
|
69
|
+
function to handle the incoming data.
|
70
|
+
*symbols: List of ticker symbols to subscribe to. "*" for everything.
|
71
|
+
"""
|
72
|
+
self._subscribe(handler, symbols, self._handlers["quotes"])
|
73
|
+
|
74
|
+
def subscribe_bars(
|
75
|
+
self, handler: Callable[[Union[Bar, Dict]], Awaitable[None]], *symbols: str
|
76
|
+
) -> None:
|
77
|
+
"""Subscribe to minute bars
|
78
|
+
|
79
|
+
Args:
|
80
|
+
handler (Callable[[Union[Quote, Dict]], Awaitable[None]]): The coroutine callback
|
81
|
+
function to handle the incoming data.
|
82
|
+
*symbols: List of ticker symbols to subscribe to. "*" for everything.
|
83
|
+
"""
|
84
|
+
self._subscribe(handler, symbols, self._handlers["bars"])
|
85
|
+
|
86
|
+
def subscribe_updated_bars(
|
87
|
+
self, handler: Callable[[Union[Bar, Dict]], Awaitable[None]], *symbols: str
|
88
|
+
) -> None:
|
89
|
+
"""Subscribe to updated minute bars
|
90
|
+
|
91
|
+
Args:
|
92
|
+
handler (Callable[[Union[Bar, Dict]], Awaitable[None]]): The coroutine callback
|
93
|
+
function to handle the incoming data.
|
94
|
+
*symbols: List of ticker symbols to subscribe to. "*" for everything.
|
95
|
+
"""
|
96
|
+
self._subscribe(handler, symbols, self._handlers["updatedBars"])
|
97
|
+
|
98
|
+
def subscribe_daily_bars(
|
99
|
+
self, handler: Callable[[Union[Bar, Dict]], Awaitable[None]], *symbols: str
|
100
|
+
) -> None:
|
101
|
+
"""Subscribe to daily bars
|
102
|
+
|
103
|
+
Args:
|
104
|
+
handler (Callable[[Union[Bar, Dict]], Awaitable[None]]): The coroutine callback
|
105
|
+
function to handle the incoming data.
|
106
|
+
*symbols: List of ticker symbols to subscribe to. "*" for everything.
|
107
|
+
"""
|
108
|
+
self._subscribe(handler, symbols, self._handlers["dailyBars"])
|
109
|
+
|
110
|
+
def subscribe_orderbooks(
|
111
|
+
self, handler: Callable[[Union[Orderbook, Dict]], Awaitable[None]], *symbols
|
112
|
+
) -> None:
|
113
|
+
"""Subscribe to orderbooks
|
114
|
+
|
115
|
+
Args:
|
116
|
+
handler (Callable[[Union[Bar, Dict]], Awaitable[None]]): The coroutine callback
|
117
|
+
function to handle the incoming data.
|
118
|
+
*symbols: List of ticker symbols to subscribe to. "*" for everything.
|
119
|
+
"""
|
120
|
+
self._subscribe(handler, symbols, self._handlers["orderbooks"])
|
121
|
+
|
122
|
+
def unsubscribe_trades(self, *symbols: str) -> None:
|
123
|
+
"""Unsubscribe from trades
|
124
|
+
|
125
|
+
Args:
|
126
|
+
*symbols (str): List of ticker symbols to unsubscribe from. "*" for everything.
|
127
|
+
"""
|
128
|
+
self._unsubscribe("trades", symbols)
|
129
|
+
|
130
|
+
def unsubscribe_quotes(self, *symbols: str) -> None:
|
131
|
+
"""Unsubscribe from quotes
|
132
|
+
|
133
|
+
Args:
|
134
|
+
*symbols (str): List of ticker symbols to unsubscribe from. "*" for everything.
|
135
|
+
"""
|
136
|
+
self._unsubscribe("quotes", symbols)
|
137
|
+
|
138
|
+
def unsubscribe_bars(self, *symbols: str) -> None:
|
139
|
+
"""Unsubscribe from minute bars
|
140
|
+
|
141
|
+
Args:
|
142
|
+
*symbols (str): List of ticker symbols to unsubscribe from. "*" for everything.
|
143
|
+
"""
|
144
|
+
self._unsubscribe("bars", symbols)
|
145
|
+
|
146
|
+
def unsubscribe_updated_bars(self, *symbols: str) -> None:
|
147
|
+
"""Unsubscribe from updated bars
|
148
|
+
|
149
|
+
Args:
|
150
|
+
*symbols (str): List of ticker symbols to unsubscribe from. "*" for everything.
|
151
|
+
"""
|
152
|
+
self._unsubscribe("updatedBars", symbols)
|
153
|
+
|
154
|
+
def unsubscribe_daily_bars(self, *symbols: str) -> None:
|
155
|
+
"""Unsubscribe from daily bars
|
156
|
+
|
157
|
+
Args:
|
158
|
+
*symbols (str): List of ticker symbols to unsubscribe from. "*" for everything.
|
159
|
+
"""
|
160
|
+
self._unsubscribe("dailyBars", symbols)
|
161
|
+
|
162
|
+
def unsubscribe_orderbooks(self, *symbols: str) -> None:
|
163
|
+
"""Unsubscribe from orderbooks
|
164
|
+
|
165
|
+
Args:
|
166
|
+
*symbols (str): List of ticker symbols to unsubscribe from. "*" for everything.
|
167
|
+
"""
|
168
|
+
self._unsubscribe("orderbooks", symbols)
|
alpaca/data/live/news.py
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
from typing import Awaitable, Callable, Dict, Optional, Union
|
2
|
+
|
3
|
+
from alpaca.common.enums import BaseURL
|
4
|
+
from alpaca.data.live.websocket import DataStream
|
5
|
+
from alpaca.data.models.news import News
|
6
|
+
|
7
|
+
|
8
|
+
class NewsDataStream(DataStream):
|
9
|
+
"""
|
10
|
+
A WebSocket client for streaming news.
|
11
|
+
"""
|
12
|
+
|
13
|
+
def __init__(
|
14
|
+
self,
|
15
|
+
api_key: str,
|
16
|
+
secret_key: str,
|
17
|
+
raw_data: bool = False,
|
18
|
+
websocket_params: Optional[Dict] = None,
|
19
|
+
url_override: Optional[str] = None,
|
20
|
+
) -> None:
|
21
|
+
"""
|
22
|
+
Instantiates a WebSocket client for accessing live news.
|
23
|
+
Args:
|
24
|
+
api_key (str): Alpaca API key.
|
25
|
+
secret_key (str): Alpaca API secret key.
|
26
|
+
raw_data (bool): Whether to return wrapped data or raw API data. Defaults to False.
|
27
|
+
websocket_params (Optional[Dict], optional): Any parameters for configuring websocket
|
28
|
+
connection. Defaults to None.
|
29
|
+
url_override (Optional[str]): If specified allows you to override the base url the client
|
30
|
+
points to for proxy/testing. Defaults to None.
|
31
|
+
"""
|
32
|
+
super().__init__(
|
33
|
+
endpoint=(
|
34
|
+
url_override
|
35
|
+
if url_override is not None
|
36
|
+
else BaseURL.MARKET_DATA_STREAM.value + "/v1beta1/news"
|
37
|
+
),
|
38
|
+
api_key=api_key,
|
39
|
+
secret_key=secret_key,
|
40
|
+
raw_data=raw_data,
|
41
|
+
websocket_params=websocket_params,
|
42
|
+
)
|
43
|
+
|
44
|
+
def subscribe_news(
|
45
|
+
self, handler: Callable[[Union[News, Dict]], Awaitable[None]], *symbols: str
|
46
|
+
) -> None:
|
47
|
+
"""Subscribe to news
|
48
|
+
|
49
|
+
Args:
|
50
|
+
handler (Callable[[Union[News, Dict]], Awaitable[None]]): The coroutine callback
|
51
|
+
function to handle the incoming data.
|
52
|
+
*symbols: List of ticker symbols to subscribe to. "*" for everything.
|
53
|
+
"""
|
54
|
+
self._subscribe(handler, symbols, self._handlers["news"])
|
55
|
+
|
56
|
+
def unsubscribe_news(self, *symbols: str) -> None:
|
57
|
+
"""Unsubscribe from news
|
58
|
+
|
59
|
+
Args:
|
60
|
+
*symbols (str): List of ticker symbols to unsubscribe from. "*" for everything.
|
61
|
+
"""
|
62
|
+
self._unsubscribe("news", symbols)
|
@@ -0,0 +1,88 @@
|
|
1
|
+
from typing import Awaitable, Callable, Dict, Optional, Union
|
2
|
+
|
3
|
+
from alpaca.common.enums import BaseURL
|
4
|
+
from alpaca.data.enums import OptionsFeed
|
5
|
+
from alpaca.data.live.websocket import DataStream
|
6
|
+
from alpaca.data.models.quotes import Quote
|
7
|
+
from alpaca.data.models.trades import Trade
|
8
|
+
|
9
|
+
|
10
|
+
class OptionDataStream(DataStream):
|
11
|
+
"""
|
12
|
+
A WebSocket client for streaming live option data.
|
13
|
+
"""
|
14
|
+
|
15
|
+
def __init__(
|
16
|
+
self,
|
17
|
+
api_key: str,
|
18
|
+
secret_key: str,
|
19
|
+
raw_data: bool = False,
|
20
|
+
feed: OptionsFeed = OptionsFeed.INDICATIVE,
|
21
|
+
websocket_params: Optional[Dict] = None,
|
22
|
+
url_override: Optional[str] = None,
|
23
|
+
) -> None:
|
24
|
+
"""
|
25
|
+
Instantiates a WebSocket client for accessing live option data.
|
26
|
+
|
27
|
+
Args:
|
28
|
+
api_key (str): Alpaca API key.
|
29
|
+
secret_key (str): Alpaca API secret key.
|
30
|
+
raw_data (bool): Whether to return wrapped data or raw API data. Defaults to False.
|
31
|
+
feed (OptionsFeed): The source feed of the data. `opra` or `indicative`.
|
32
|
+
Defaults to `indicative`. `opra` requires a subscription.
|
33
|
+
websocket_params (Optional[Dict], optional): Any parameters for configuring websocket
|
34
|
+
connection. Defaults to None.
|
35
|
+
url_override (Optional[str]): If specified allows you to override the base url the client
|
36
|
+
points to for proxy/testing. Defaults to None.
|
37
|
+
"""
|
38
|
+
super().__init__(
|
39
|
+
endpoint=(
|
40
|
+
url_override
|
41
|
+
if url_override is not None
|
42
|
+
else BaseURL.MARKET_DATA_STREAM.value + "/v1beta1/" + feed.value
|
43
|
+
),
|
44
|
+
api_key=api_key,
|
45
|
+
secret_key=secret_key,
|
46
|
+
raw_data=raw_data,
|
47
|
+
websocket_params=websocket_params,
|
48
|
+
)
|
49
|
+
|
50
|
+
def subscribe_trades(
|
51
|
+
self, handler: Callable[[Union[Trade, Dict]], Awaitable[None]], *symbols: str
|
52
|
+
) -> None:
|
53
|
+
"""Subscribe to trades.
|
54
|
+
|
55
|
+
Args:
|
56
|
+
handler (Callable[[Union[Trade, Dict]], Awaitable[None]]): The coroutine callback
|
57
|
+
function to handle the incoming data.
|
58
|
+
*symbols: List of ticker symbols to subscribe to. "*" for everything.
|
59
|
+
"""
|
60
|
+
self._subscribe(handler, symbols, self._handlers["trades"])
|
61
|
+
|
62
|
+
def subscribe_quotes(
|
63
|
+
self, handler: Callable[[Union[Quote, Dict]], Awaitable[None]], *symbols: str
|
64
|
+
) -> None:
|
65
|
+
"""Subscribe to quotes
|
66
|
+
|
67
|
+
Args:
|
68
|
+
handler (Callable[[Union[Quote, Dict]], Awaitable[None]]): The coroutine callback
|
69
|
+
function to handle the incoming data.
|
70
|
+
*symbols: List of ticker symbols to subscribe to. "*" for everything.
|
71
|
+
"""
|
72
|
+
self._subscribe(handler, symbols, self._handlers["quotes"])
|
73
|
+
|
74
|
+
def unsubscribe_trades(self, *symbols: str) -> None:
|
75
|
+
"""Unsubscribe from trades
|
76
|
+
|
77
|
+
Args:
|
78
|
+
*symbols (str): List of ticker symbols to unsubscribe from. "*" for everything.
|
79
|
+
"""
|
80
|
+
self._unsubscribe("trades", symbols)
|
81
|
+
|
82
|
+
def unsubscribe_quotes(self, *symbols: str) -> None:
|
83
|
+
"""Unsubscribe from quotes
|
84
|
+
|
85
|
+
Args:
|
86
|
+
*symbols (str): List of ticker symbols to unsubscribe from. "*" for everything.
|
87
|
+
"""
|
88
|
+
self._unsubscribe("quotes", symbols)
|
@@ -0,0 +1,199 @@
|
|
1
|
+
import asyncio
|
2
|
+
from typing import Awaitable, Callable, Dict, Optional, Union
|
3
|
+
|
4
|
+
from alpaca.common.enums import BaseURL
|
5
|
+
from alpaca.data.enums import DataFeed
|
6
|
+
from alpaca.data.live.websocket import DataStream
|
7
|
+
from alpaca.data.models.bars import Bar
|
8
|
+
from alpaca.data.models.quotes import Quote
|
9
|
+
from alpaca.data.models.trades import Trade, TradeCancel, TradeCorrection, TradingStatus
|
10
|
+
|
11
|
+
|
12
|
+
class StockDataStream(DataStream):
|
13
|
+
"""
|
14
|
+
A WebSocket client for streaming live stock data.
|
15
|
+
"""
|
16
|
+
|
17
|
+
def __init__(
|
18
|
+
self,
|
19
|
+
api_key: str,
|
20
|
+
secret_key: str,
|
21
|
+
raw_data: bool = False,
|
22
|
+
feed: DataFeed = DataFeed.IEX,
|
23
|
+
websocket_params: Optional[Dict] = None,
|
24
|
+
url_override: Optional[str] = None,
|
25
|
+
) -> None:
|
26
|
+
"""
|
27
|
+
Instantiates a WebSocket client for accessing live stock data.
|
28
|
+
|
29
|
+
Args:
|
30
|
+
api_key (str): Alpaca API key.
|
31
|
+
secret_key (str): Alpaca API secret key.
|
32
|
+
raw_data (bool, optional): Whether to return wrapped data or raw API data. Defaults to False.
|
33
|
+
feed (DataFeed, optional): Which market data feed to use; IEX or SIP.
|
34
|
+
Defaults to IEX. SIP requires a subscription.
|
35
|
+
websocket_params (Optional[Dict], optional): Any parameters for configuring websocket connection. Defaults to None.
|
36
|
+
url_override (Optional[str]): If specified allows you to override the base url the client
|
37
|
+
points to for proxy/testing. Defaults to None.
|
38
|
+
|
39
|
+
Raises:
|
40
|
+
ValueError: Only IEX or SIP market data feeds are supported
|
41
|
+
"""
|
42
|
+
if feed not in (DataFeed.IEX, DataFeed.SIP):
|
43
|
+
raise ValueError("only IEX and SIP feeds ar supported")
|
44
|
+
|
45
|
+
super().__init__(
|
46
|
+
endpoint=(
|
47
|
+
url_override
|
48
|
+
if url_override is not None
|
49
|
+
else BaseURL.MARKET_DATA_STREAM.value + "/v2/" + feed.value
|
50
|
+
),
|
51
|
+
api_key=api_key,
|
52
|
+
secret_key=secret_key,
|
53
|
+
raw_data=raw_data,
|
54
|
+
websocket_params=websocket_params,
|
55
|
+
)
|
56
|
+
|
57
|
+
def subscribe_trades(
|
58
|
+
self, handler: Callable[[Union[Trade, Dict]], Awaitable[None]], *symbols: str
|
59
|
+
) -> None:
|
60
|
+
"""Subscribe to trades.
|
61
|
+
|
62
|
+
Args:
|
63
|
+
handler (Callable[[Union[Trade, Dict]], Awaitable[None]]): The coroutine callback
|
64
|
+
function to handle the incoming data.
|
65
|
+
*symbols: List of ticker symbols to subscribe to. "*" for everything.
|
66
|
+
"""
|
67
|
+
self._subscribe(handler, symbols, self._handlers["trades"])
|
68
|
+
|
69
|
+
def subscribe_quotes(
|
70
|
+
self, handler: Callable[[Union[Quote, Dict]], Awaitable[None]], *symbols: str
|
71
|
+
) -> None:
|
72
|
+
"""Subscribe to quotes
|
73
|
+
|
74
|
+
Args:
|
75
|
+
handler (Callable[[Union[Trade, Dict]], Awaitable[None]]): The coroutine callback
|
76
|
+
function to handle the incoming data.
|
77
|
+
*symbols: List of ticker symbols to subscribe to. "*" for everything.
|
78
|
+
"""
|
79
|
+
self._subscribe(handler, symbols, self._handlers["quotes"])
|
80
|
+
|
81
|
+
def subscribe_bars(
|
82
|
+
self, handler: Callable[[Union[Bar, Dict]], Awaitable[None]], *symbols: str
|
83
|
+
) -> None:
|
84
|
+
"""Subscribe to minute bars
|
85
|
+
|
86
|
+
Args:
|
87
|
+
handler (Callable[[Union[Trade, Dict]], Awaitable[None]]): The coroutine callback
|
88
|
+
function to handle the incoming data.
|
89
|
+
*symbols: List of ticker symbols to subscribe to. "*" for everything.
|
90
|
+
"""
|
91
|
+
self._subscribe(handler, symbols, self._handlers["bars"])
|
92
|
+
|
93
|
+
def subscribe_updated_bars(
|
94
|
+
self, handler: Callable[[Union[Bar, Dict]], Awaitable[None]], *symbols: str
|
95
|
+
) -> None:
|
96
|
+
"""Subscribe to updated minute bars
|
97
|
+
|
98
|
+
Args:
|
99
|
+
handler (Callable[[Union[Bar, Dict]], Awaitable[None]]): The coroutine callback
|
100
|
+
function to handle the incoming data.
|
101
|
+
*symbols: List of ticker symbols to subscribe to. "*" for everything.
|
102
|
+
"""
|
103
|
+
self._subscribe(handler, symbols, self._handlers["updatedBars"])
|
104
|
+
|
105
|
+
def subscribe_daily_bars(
|
106
|
+
self, handler: Callable[[Union[Bar, Dict]], Awaitable[None]], *symbols: str
|
107
|
+
) -> None:
|
108
|
+
"""Subscribe to daily bars
|
109
|
+
|
110
|
+
Args:
|
111
|
+
handler (Callable[[Union[Bar, Dict]], Awaitable[None]]): The coroutine callback
|
112
|
+
function to handle the incoming data.
|
113
|
+
*symbols: List of ticker symbols to subscribe to. "*" for everything.
|
114
|
+
"""
|
115
|
+
self._subscribe(handler, symbols, self._handlers["dailyBars"])
|
116
|
+
|
117
|
+
def subscribe_trading_statuses(
|
118
|
+
self, handler: Callable[[Union[TradingStatus, Dict]], Awaitable[None]], *symbols
|
119
|
+
) -> None:
|
120
|
+
"""Subscribe to trading statuses (halts, resumes)
|
121
|
+
|
122
|
+
Args:
|
123
|
+
handler (Callable[[Union[TradingStatus, Dict]], Awaitable[None]]): The coroutine callback
|
124
|
+
function to handle the incoming data.
|
125
|
+
*symbols: List of ticker symbols to subscribe to. "*" for everything.
|
126
|
+
"""
|
127
|
+
self._subscribe(handler, symbols, self._handlers["statuses"])
|
128
|
+
|
129
|
+
def register_trade_corrections(
|
130
|
+
self, handler: Callable[[Union[TradeCorrection, Dict]], Awaitable[None]]
|
131
|
+
) -> None:
|
132
|
+
"""Register a trade correction handler. You can only subscribe to trade corrections by
|
133
|
+
subscribing to the underlying trades.
|
134
|
+
|
135
|
+
Args:
|
136
|
+
handler (Callable[[Union[TradeCorrection, Dict]]): The coroutine callback
|
137
|
+
function to handle the incoming data.
|
138
|
+
"""
|
139
|
+
self._handlers["corrections"] = {"*": handler}
|
140
|
+
|
141
|
+
def register_trade_cancels(
|
142
|
+
self, handler: Callable[[Union[TradeCancel, Dict]], Awaitable[None]]
|
143
|
+
) -> None:
|
144
|
+
"""Register a trade cancel handler. You can only subscribe to trade cancels by
|
145
|
+
subscribing to the underlying trades.
|
146
|
+
|
147
|
+
Args:
|
148
|
+
handler (Callable[[Union[TradeCancel, Dict]], Awaitable[None]]): The coroutine callback
|
149
|
+
function to handle the incoming data.
|
150
|
+
"""
|
151
|
+
self._handlers["cancelErrors"] = {"*": handler}
|
152
|
+
|
153
|
+
def unsubscribe_trades(self, *symbols: str) -> None:
|
154
|
+
"""Unsubscribe from trades
|
155
|
+
|
156
|
+
Args:
|
157
|
+
*symbols (str): List of ticker symbols to unsubscribe from. "*" for everything.
|
158
|
+
"""
|
159
|
+
self._unsubscribe("trades", symbols)
|
160
|
+
|
161
|
+
def unsubscribe_quotes(self, *symbols: str) -> None:
|
162
|
+
"""Unsubscribe from quotes
|
163
|
+
|
164
|
+
Args:
|
165
|
+
*symbols (str): List of ticker symbols to unsubscribe from. "*" for everything.
|
166
|
+
"""
|
167
|
+
self._unsubscribe("quotes", symbols)
|
168
|
+
|
169
|
+
def unsubscribe_bars(self, *symbols: str) -> None:
|
170
|
+
"""Unsubscribe from minute bars
|
171
|
+
|
172
|
+
Args:
|
173
|
+
*symbols (str): List of ticker symbols to unsubscribe from. "*" for everything.
|
174
|
+
"""
|
175
|
+
self._unsubscribe("bars", symbols)
|
176
|
+
|
177
|
+
def unsubscribe_updated_bars(self, *symbols: str) -> None:
|
178
|
+
"""Unsubscribe from updated bars
|
179
|
+
|
180
|
+
Args:
|
181
|
+
*symbols (str): List of ticker symbols to unsubscribe from. "*" for everything.
|
182
|
+
"""
|
183
|
+
self._unsubscribe("updatedBars", symbols)
|
184
|
+
|
185
|
+
def unsubscribe_daily_bars(self, *symbols: str) -> None:
|
186
|
+
"""Unsubscribe from daily bars
|
187
|
+
|
188
|
+
Args:
|
189
|
+
*symbols (str): List of ticker symbols to unsubscribe from. "*" for everything.
|
190
|
+
"""
|
191
|
+
self._unsubscribe("dailyBars", symbols)
|
192
|
+
|
193
|
+
def unsubscribe_trading_statuses(self, *symbols: str) -> None:
|
194
|
+
"""Unsubscribe from trading statuses
|
195
|
+
|
196
|
+
Args:
|
197
|
+
*symbols (str): List of ticker symbols to unsubscribe from. "*" for everything.
|
198
|
+
"""
|
199
|
+
self._unsubscribe("statuses", symbols)
|