alpaca-py-nopandas 0.1.0__py3-none-any.whl → 0.1.1__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_py_nopandas-0.1.1.dist-info/METADATA +39 -0
- {alpaca_py_nopandas-0.1.0.dist-info → alpaca_py_nopandas-0.1.1.dist-info}/RECORD +4 -4
- alpaca_py_nopandas-0.1.0.dist-info/METADATA +0 -299
- {alpaca_py_nopandas-0.1.0.dist-info → alpaca_py_nopandas-0.1.1.dist-info}/LICENSE +0 -0
- {alpaca_py_nopandas-0.1.0.dist-info → alpaca_py_nopandas-0.1.1.dist-info}/WHEEL +0 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
Metadata-Version: 2.3
|
2
|
+
Name: alpaca-py-nopandas
|
3
|
+
Version: 0.1.1
|
4
|
+
Summary: A forked Python SDK for Alpaca APIs (with Pandas removed)
|
5
|
+
License: Apache-2.0
|
6
|
+
Author: Will Tesler
|
7
|
+
Author-email: willtesler@gmail.com
|
8
|
+
Requires-Python: >=3.8.0,<4.0.0
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
11
|
+
Classifier: Programming Language :: Python :: 3.8
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
17
|
+
Requires-Dist: msgpack (>=1.0.3,<2.0.0)
|
18
|
+
Requires-Dist: pydantic (>=2.0.3,<3.0.0)
|
19
|
+
Requires-Dist: pytz (>=2025.2,<2026.0)
|
20
|
+
Requires-Dist: requests (>=2.30.0,<3.0.0)
|
21
|
+
Requires-Dist: sseclient-py (>=1.7.2,<2.0.0)
|
22
|
+
Requires-Dist: websockets (>=10.4)
|
23
|
+
Project-URL: Documentation, https://alpaca.markets/docs/python-sdk/
|
24
|
+
Project-URL: Repository, https://github.com/wtesler/alpaca-py-nopandas
|
25
|
+
Description-Content-Type: text/markdown
|
26
|
+
|
27
|
+
[](https://pypi.org/project/alpaca-py-nopandas)
|
28
|
+
[](https://github.com/alpacahq/alpaca-py/blob/master/LICENSE.md)
|
29
|
+
[](https://pypi.org/project/alpaca-py-nopandas/)
|
30
|
+
|
31
|
+
Forked version of alpaca-py project with Pandas dependency removed.
|
32
|
+
|
33
|
+
See https://github.com/alpacahq/alpaca-py
|
34
|
+
|
35
|
+
# Build and Deploy
|
36
|
+
|
37
|
+
`poetry build`
|
38
|
+
|
39
|
+
`uvx twine upload dist/*`
|
@@ -56,7 +56,7 @@ alpaca/trading/enums.py,sha256=qqEyeGOQG5YyzuBYyjniSegOzlG6KmR6IWE4vwsmbkY,12512
|
|
56
56
|
alpaca/trading/models.py,sha256=DAx8DMsIKwX2kJRDsmNMYZ-r8Ud3QK6mwCaB3LIgtFw,31632
|
57
57
|
alpaca/trading/requests.py,sha256=rHgqWhZ-rRd7Fqab25SOrTAspS5TmXNapWtBvSvKWCI,28443
|
58
58
|
alpaca/trading/stream.py,sha256=nnr8BREjahnzd5YsXbt4hQlX8fW4_ost7dSYlP_Dma8,7568
|
59
|
-
alpaca_py_nopandas-0.1.
|
60
|
-
alpaca_py_nopandas-0.1.
|
61
|
-
alpaca_py_nopandas-0.1.
|
62
|
-
alpaca_py_nopandas-0.1.
|
59
|
+
alpaca_py_nopandas-0.1.1.dist-info/LICENSE,sha256=vITaaCdExt0AjPmtMwbK8YRE1hOoDBvMPeDdRglHh-8,10873
|
60
|
+
alpaca_py_nopandas-0.1.1.dist-info/METADATA,sha256=cWutjjBwDXc0-Ao1EwGsz_UOCwQPOeqF7mhVKMZPSWc,1647
|
61
|
+
alpaca_py_nopandas-0.1.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
62
|
+
alpaca_py_nopandas-0.1.1.dist-info/RECORD,,
|
@@ -1,299 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.3
|
2
|
-
Name: alpaca-py-nopandas
|
3
|
-
Version: 0.1.0
|
4
|
-
Summary: A forked Python SDK for Alpaca APIs (with Pandas removed)
|
5
|
-
License: Apache-2.0
|
6
|
-
Author: Will Tesler
|
7
|
-
Author-email: willtesler@gmail.com
|
8
|
-
Requires-Python: >=3.8.0,<4.0.0
|
9
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
10
|
-
Classifier: Programming Language :: Python :: 3
|
11
|
-
Classifier: Programming Language :: Python :: 3.8
|
12
|
-
Classifier: Programming Language :: Python :: 3.9
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
14
|
-
Classifier: Programming Language :: Python :: 3.11
|
15
|
-
Classifier: Programming Language :: Python :: 3.12
|
16
|
-
Classifier: Programming Language :: Python :: 3.13
|
17
|
-
Requires-Dist: msgpack (>=1.0.3,<2.0.0)
|
18
|
-
Requires-Dist: pydantic (>=2.0.3,<3.0.0)
|
19
|
-
Requires-Dist: requests (>=2.30.0,<3.0.0)
|
20
|
-
Requires-Dist: sseclient-py (>=1.7.2,<2.0.0)
|
21
|
-
Requires-Dist: websockets (>=10.4)
|
22
|
-
Project-URL: Documentation, https://alpaca.markets/docs/python-sdk/
|
23
|
-
Project-URL: Repository, https://github.com/wtesler/alpaca-py-nopandas
|
24
|
-
Description-Content-Type: text/markdown
|
25
|
-
|
26
|
-
[](https://alpaca.markets/docs/python-sdk)
|
27
|
-
|
28
|
-
[](https://pepy.tech/project/alpaca-py)
|
29
|
-
[](https://pypi.org/project/alpaca-py)
|
30
|
-
[](https://github.com/alpacahq/alpaca-py/blob/master/LICENSE.md)
|
31
|
-
[](https://pypi.org/project/alpaca-py/)
|
32
|
-
|
33
|
-
## Table of Contents
|
34
|
-
|
35
|
-
- [About](#about)
|
36
|
-
- [Documentation](#documentation)
|
37
|
-
- [Installation](#installation)
|
38
|
-
- [Update](#update)
|
39
|
-
- [What's New?](#whats-new)
|
40
|
-
1. [Broker API](#broker-api-new)
|
41
|
-
2. [OOP Design](#oop-design)
|
42
|
-
3. [Data Validation](#data-validation)
|
43
|
-
4. [Many Clients](#many-clients)
|
44
|
-
- [API Keys](#api-keys)
|
45
|
-
1. [Trading and Market Data API Keys](#trading-api-keys)
|
46
|
-
2. [Broker API Keys](#trading-api-keys)
|
47
|
-
- [Usage](#usage)
|
48
|
-
1. [Broker API Example](#broker-api-example)
|
49
|
-
2. [Trading API Example](#trading-api-example)
|
50
|
-
3. [Market Data API Example](#data-api-example)
|
51
|
-
- [Contributing](https://github.com/alpacahq/alpaca-py/blob/master/CONTRIBUTING.md)
|
52
|
-
- [License](https://github.com/alpacahq/alpaca-py/blob/master/LICENSE)
|
53
|
-
|
54
|
-
## About <a name="about"></a>
|
55
|
-
|
56
|
-
Alpaca-py provides an interface for interacting with the API products Alpaca offers. These API products are provided as various REST, WebSocket and SSE endpoints that allow you to do everything from streaming market data to creating your own investment apps.
|
57
|
-
|
58
|
-
Learn more about the API products Alpaca offers at https://alpaca.markets.
|
59
|
-
|
60
|
-
## Documentation <a name="documentation"></a>
|
61
|
-
|
62
|
-
Alpaca-py has a supplementary documentation site which contains references for all clients, methods and models found in this codebase. The documentation
|
63
|
-
also contains examples to get started with alpaca-py.
|
64
|
-
|
65
|
-
You can find the documentation site here: https://alpaca.markets/sdks/python/getting_started.html
|
66
|
-
|
67
|
-
You can also find the API Reference of Alpaca APIs: https://docs.alpaca.markets/reference
|
68
|
-
|
69
|
-
## Installation <a name="installation"></a>
|
70
|
-
|
71
|
-
Alpaca-py is supported on Python 3.8+. You can install Alpaca-py using pip.
|
72
|
-
|
73
|
-
Run the following command in your terminal.
|
74
|
-
|
75
|
-
```shell
|
76
|
-
pip install alpaca-py
|
77
|
-
```
|
78
|
-
|
79
|
-
## Update <a name="update"></a>
|
80
|
-
|
81
|
-
If you already have Alpaca-py installed, and would like to use the latest version available...
|
82
|
-
|
83
|
-
Run the following command in your terminal:
|
84
|
-
|
85
|
-
```shell
|
86
|
-
pip install alpaca-py --upgrade
|
87
|
-
```
|
88
|
-
|
89
|
-
## What’s New? <a name="whats-new"></a>
|
90
|
-
|
91
|
-
If you’ve used the previous python SDK alpaca-trade-api, there are a few key differences to be aware of.
|
92
|
-
|
93
|
-
### Broker API <a name="broker-api-new"></a>
|
94
|
-
|
95
|
-
Alpaca-py lets you use Broker API to start building your investment apps! Learn more at the [Broker](https://docs.alpaca.markets/docs/about-broker-api) page.
|
96
|
-
|
97
|
-
### OOP Design <a name="oop-design"></a>
|
98
|
-
|
99
|
-
Alpaca-py uses a more OOP approach to submitting requests compared to the previous SDK. To submit a request, you will most likely need to create a request object containing the desired request data. Generally, there is a unique request model for each method.
|
100
|
-
|
101
|
-
Some examples of request models corresponding to methods:
|
102
|
-
|
103
|
-
- `GetOrdersRequest` for `TradingClient.get_orders()`
|
104
|
-
- `CryptoLatestOrderbookRequest` for `CryptoHistoricalDataClient.get_crypto_latest_orderbook()`
|
105
|
-
|
106
|
-
**Request Models Usage Example**
|
107
|
-
|
108
|
-
To get historical bar data for crypto, you will need to provide a `CryptoBarsRequest` object.
|
109
|
-
|
110
|
-
```python
|
111
|
-
from alpaca.data.historical import CryptoHistoricalDataClient
|
112
|
-
from alpaca.data.requests import CryptoBarsRequest
|
113
|
-
from alpaca.data.timeframe import TimeFrame
|
114
|
-
from datetime import datetime
|
115
|
-
|
116
|
-
# no keys required for crypto data
|
117
|
-
client = CryptoHistoricalDataClient()
|
118
|
-
|
119
|
-
request_params = CryptoBarsRequest(
|
120
|
-
symbol_or_symbols=["BTC/USD", "ETH/USD"],
|
121
|
-
timeframe=TimeFrame.Day,
|
122
|
-
start=datetime(2022, 7, 1)
|
123
|
-
)
|
124
|
-
|
125
|
-
bars = client.get_crypto_bars(request_params)
|
126
|
-
```
|
127
|
-
|
128
|
-
### Data Validation <a name="data-validation"></a>
|
129
|
-
|
130
|
-
Alpaca-py uses _pydantic_ to validate data models at run-time. This means if you are receiving request data via JSON from a client. You can handle parsing and validation through Alpaca’s request models. All request models can be instantiated by passing in data in dictionary format.
|
131
|
-
|
132
|
-
Here is a rough example of what is possible.
|
133
|
-
|
134
|
-
```python
|
135
|
-
|
136
|
-
@app.route('/post_json', methods=['POST'])
|
137
|
-
def do_trade():
|
138
|
-
# ...
|
139
|
-
|
140
|
-
order_data_json = request.get_json()
|
141
|
-
|
142
|
-
# validate data
|
143
|
-
MarketOrderRequest(**order_data_json)
|
144
|
-
|
145
|
-
# ...
|
146
|
-
```
|
147
|
-
|
148
|
-
### Many Clients <a name="many-clients"></a>
|
149
|
-
|
150
|
-
Alpaca-py has a lot of client classes. There is a client for each API and even asset class specific clients (`StockHistoricalDataClient`, `CryptoDataStream`, `OptionHistoricalDataClient`). This requires you to pick and choose clients based on your needs.
|
151
|
-
|
152
|
-
**Broker API:** `BrokerClient`
|
153
|
-
|
154
|
-
**Trading API:** `TradingClient`
|
155
|
-
|
156
|
-
**Market Data API:** `StockHistoricalDataClient`, `CryptoHistoricalDataClient`, `NewsClient`, `OptionHistoricalDataClient`, `CryptoDataStream`, `StockDataStream`, `NewsDataStream`, `OptionDataStream`
|
157
|
-
|
158
|
-
## API Keys <a name="api-keys"></a>
|
159
|
-
|
160
|
-
### Trading and Market Data API <a name="trading-api-keys"></a>
|
161
|
-
|
162
|
-
In order to use Alpaca’s services you’ll need to sign up for an Alpaca account and retrieve your API keys. Signing up is completely free and takes only a few minutes. Sandbox environments are available to test out the API. To use the sandbox environment, you will need to provide sandbox/paper keys. API keys are passed into Alpaca-py through either `TradingClient`, `StockHistoricalDataClient`, `CryptoHistoricalDataClient`, `NewsClient`, `OptionHistoricalDataClient`, `StockDataStream`, `CryptoDataStream`,`NewsDataStream`, or `OptionDataStream`.
|
163
|
-
|
164
|
-
### Broker API <a name="broker-api-keys"></a>
|
165
|
-
|
166
|
-
To use the Broker API, you will need to sign up for a broker account and retrieve your Broker API keys. The API keys can be found on the dashboard once you’ve logged in. Alpaca also provides a sandbox environment to test out Broker API. To use the sandbox mode, provide your sandbox keys. Once you have your keys, you can pass them into `BrokerClient` to get started.
|
167
|
-
|
168
|
-
## Usage <a name="usage"></a>
|
169
|
-
|
170
|
-
Alpaca’s APIs allow you to do everything from building algorithmic trading strategies to building a full brokerage experience for your own end users. Here are some things you can do with Alpaca-py.
|
171
|
-
|
172
|
-
To view full descriptions and examples view the [documentation page](https://alpaca.markets/sdks/python/).
|
173
|
-
|
174
|
-
**Market Data API**: Access live and historical market data for 5000+ stocks, 20+ crypto, and options.
|
175
|
-
|
176
|
-
**Trading API**: Trade stock and crypto with lightning fast execution speeds.
|
177
|
-
|
178
|
-
**Broker API & Connect**: Build investment apps - from robo-advisors to brokerages.
|
179
|
-
|
180
|
-
### Broker API Example <a name="broker-api-example"></a>
|
181
|
-
|
182
|
-
**Listing All Accounts**
|
183
|
-
|
184
|
-
The `BrokerClient.list_accounts` method allows you to list all the brokerage accounts under your management. The method takes an optional parameter `search_parameters` which requires a `ListAccountsRequest` object. This parameter allows you to filter the list of accounts returned.
|
185
|
-
|
186
|
-
```python
|
187
|
-
from alpaca.broker.client import BrokerClient
|
188
|
-
from alpaca.broker.requests import ListAccountsRequest
|
189
|
-
from alpaca.broker.enums import AccountEntities
|
190
|
-
|
191
|
-
broker_client = BrokerClient('api-key', 'secret-key')
|
192
|
-
|
193
|
-
# search for accounts created after January 30th 2022.
|
194
|
-
# Response should contain Contact and Identity fields for each account.
|
195
|
-
filter = ListAccountsRequest(
|
196
|
-
created_after=datetime.datetime.strptime("2022-01-30", "%Y-%m-%d"),
|
197
|
-
entities=[AccountEntities.CONTACT, AccountEntities.IDENTITY]
|
198
|
-
)
|
199
|
-
|
200
|
-
accounts = broker_client.list_accounts(search_parameters=filter)
|
201
|
-
```
|
202
|
-
|
203
|
-
### Trading API Example <a name="trading-api-example"></a>
|
204
|
-
|
205
|
-
**Submitting an Order**
|
206
|
-
|
207
|
-
To create an order on Alpaca-py you must use an `OrderRequest` object. There are different `OrderRequest` objects based on the type of order you want to make. For market orders, there is `MarketOrderRequest`, limit orders have `LimitOrderRequest`, stop orders `StopOrderRequest`, and trailing stop orders have `TrailingStopOrderRequest`. Each order type have their own required parameters for a successful order.
|
208
|
-
|
209
|
-
```python
|
210
|
-
from alpaca.trading.client import TradingClient
|
211
|
-
from alpaca.trading.requests import MarketOrderRequest
|
212
|
-
from alpaca.trading.enums import OrderSide, TimeInForce
|
213
|
-
|
214
|
-
trading_client = TradingClient('api-key', 'secret-key')
|
215
|
-
|
216
|
-
|
217
|
-
# preparing order data
|
218
|
-
market_order_data = MarketOrderRequest(
|
219
|
-
symbol="BTC/USD",
|
220
|
-
qty=0.0001,
|
221
|
-
side=OrderSide.BUY,
|
222
|
-
time_in_force=TimeInForce.DAY
|
223
|
-
)
|
224
|
-
|
225
|
-
# Market order
|
226
|
-
market_order = trading_client.submit_order(
|
227
|
-
order_data=market_order_data
|
228
|
-
)
|
229
|
-
```
|
230
|
-
|
231
|
-
### Market Data API Example <a name="data-api-example"></a>
|
232
|
-
|
233
|
-
**Querying Historical Bar Data**
|
234
|
-
|
235
|
-
You can request bar data via the HistoricalDataClients. In this example, we query daily bar data for “BTC/USD” and “ETH/USD” since July 1st 2022. You can convert the response to a multi-index pandas dataframe using the `.df` property. There are `StockHistoricalDataClient` and `OptionHistoricalDataClient` that you also could use to fetch equity/options historical data.
|
236
|
-
|
237
|
-
```python
|
238
|
-
from alpaca.data.historical import CryptoHistoricalDataClient
|
239
|
-
from alpaca.data.requests import CryptoBarsRequest
|
240
|
-
from alpaca.data.timeframe import TimeFrame
|
241
|
-
from datetime import datetime
|
242
|
-
|
243
|
-
# no keys required for crypto data
|
244
|
-
client = CryptoHistoricalDataClient()
|
245
|
-
|
246
|
-
request_params = CryptoBarsRequest(
|
247
|
-
symbol_or_symbols=["BTC/USD", "ETH/USD"],
|
248
|
-
timeframe=TimeFrame.Day,
|
249
|
-
start=datetime.strptime("2022-07-01", '%Y-%m-%d')
|
250
|
-
)
|
251
|
-
|
252
|
-
bars = client.get_crypto_bars(request_params)
|
253
|
-
|
254
|
-
# convert to dataframe
|
255
|
-
bars.df
|
256
|
-
|
257
|
-
```
|
258
|
-
|
259
|
-
**Querying News Data** <a name="news-client-example"></a>
|
260
|
-
|
261
|
-
You can query news data via the NewsClient. In this example, we query news data for “TSLA” since July 1st 2022. You can convert the response to a pandas dataframe using the `.df` property.
|
262
|
-
|
263
|
-
```python
|
264
|
-
from alpaca.data.historical.news import NewsClient
|
265
|
-
from alpaca.data.requests import NewsRequest
|
266
|
-
from datetime import datetime
|
267
|
-
|
268
|
-
# no keys required for news data
|
269
|
-
client = NewsClient()
|
270
|
-
|
271
|
-
request_params = NewsRequest(
|
272
|
-
symbols="TSLA",
|
273
|
-
start=datetime.strptime("2022-07-01", '%Y-%m-%d')
|
274
|
-
)
|
275
|
-
|
276
|
-
news = client.get_news(request_params)
|
277
|
-
|
278
|
-
# convert to dataframe
|
279
|
-
news.df
|
280
|
-
|
281
|
-
```
|
282
|
-
|
283
|
-
### Options Trading <a name="options-trading"></a>
|
284
|
-
|
285
|
-
We're excited to support options trading! Use this section to read up on Alpaca's options trading capabilities.
|
286
|
-
For more details, please refer to [our documentation page for options trading](https://docs.alpaca.markets/docs/options-trading)
|
287
|
-
|
288
|
-
There is an example jupyter notebook to explain methods of alpaca-py for options trading.
|
289
|
-
|
290
|
-
* [jupyter notebook: options trading basic example with alpaca-py](https://github.com/alpacahq/alpaca-py/blob/master/examples/options/options-trading-basic.ipynb)
|
291
|
-
|
292
|
-
### Jupyter Notebook Library <a name="colab-library"></a>
|
293
|
-
|
294
|
-
Explore examples for stocks, options, and crypto using alpaca-py. Notebooks for each asset class are provided in their respective directories!
|
295
|
-
|
296
|
-
* [Stocks](https://github.com/alpacahq/alpaca-py/blob/master/examples/stocks/README.md)
|
297
|
-
* [Crypto](https://github.com/alpacahq/alpaca-py/blob/master/examples/crypto/README.md)
|
298
|
-
* [Options](https://github.com/alpacahq/alpaca-py/blob/master/examples/options/README.md)
|
299
|
-
* [Multi-Leg Options](https://github.com/alpacahq/alpaca-py/blob/master/examples/options/README.md)
|
File without changes
|
File without changes
|