79 lines
2.5 KiB
Markdown
79 lines
2.5 KiB
Markdown
# OHLC
|
|
|
|
This module provides Open, High, Low, Close (OHLC) data (and volume) for trading applications.
|
|
|
|
The data currently comes from [IQFeed](https://www.iqfeed.net/), so you will need an account with API access from them.
|
|
|
|
## Dependencies
|
|
|
|
* [IQFeed](https://moshferatu.dev/moshferatu/iqfeed/src/branch/main)
|
|
|
|
## Usage
|
|
|
|
All data is returned as a ```pandas``` DataFrame.
|
|
|
|
Both the start and end dates default to the current day.
|
|
|
|
### Daily Data
|
|
|
|
```python
|
|
from ohlc import ohlc
|
|
|
|
from datetime import datetime
|
|
|
|
daily_data = ohlc('SPY', start_date = datetime(2024, 1, 1))
|
|
```
|
|
|
|
Example data:
|
|
|
|
```
|
|
Date Open High Low Close Volume
|
|
0 2024-01-02 472.16 473.670 470.49 472.65 123007793
|
|
1 2024-01-03 470.43 471.190 468.17 468.79 103585866
|
|
2 2024-01-04 468.30 470.960 467.05 467.28 84232169
|
|
3 2024-01-05 467.49 470.440 466.43 467.92 86118913
|
|
4 2024-01-08 468.43 474.750 468.30 474.60 74879074
|
|
.. ... ... ... ... ... ...
|
|
221 2024-11-15 589.72 590.200 583.86 585.75 75988766
|
|
222 2024-11-18 586.22 589.490 585.34 588.15 37084081
|
|
223 2024-11-19 584.71 591.045 584.03 590.30 49412046
|
|
224 2024-11-20 590.38 590.790 584.63 590.50 50032576
|
|
225 2024-11-21 593.40 595.120 587.45 593.67 46750285
|
|
```
|
|
|
|
### Intraday / Minute Data
|
|
|
|
```python
|
|
from ohlc import ohlc
|
|
|
|
from datetime import datetime
|
|
|
|
intraday_data = ohlc('SPY', minutes = 5, start_date = datetime(2024, 1, 1), end_date = datetime(2024, 1, 31))
|
|
```
|
|
|
|
If neither the start nor end date is provided, data for the current day is returned:
|
|
|
|
```python
|
|
from ohlc import ohlc
|
|
|
|
todays_data = ohlc('SPY', minutes = 5)
|
|
```
|
|
|
|
Example data:
|
|
|
|
```
|
|
Date Time Open High Low Close Volume
|
|
0 2024-11-22 09:35:00 593.660 594.5100 593.5700 594.5100 1084785
|
|
1 2024-11-22 09:40:00 594.480 594.7182 593.9800 594.7000 691893
|
|
2 2024-11-22 09:45:00 594.710 595.7800 594.6800 595.5800 809901
|
|
3 2024-11-22 09:50:00 595.610 596.1310 595.2300 595.6400 588006
|
|
4 2024-11-22 09:55:00 595.630 595.6900 594.6900 595.3342 521905
|
|
.. ... ... ... ... ... ... ...
|
|
65 2024-11-22 15:00:00 595.520 595.6300 595.3800 595.3999 140253
|
|
66 2024-11-22 15:05:00 595.390 595.3900 594.2300 594.5744 369153
|
|
67 2024-11-22 15:10:00 594.570 595.0100 594.5200 594.6147 174254
|
|
68 2024-11-22 15:15:00 594.620 594.6700 594.1700 594.2500 257970
|
|
69 2024-11-22 15:20:00 594.255 594.6900 594.1801 594.6150 184050
|
|
```
|
|
|
|
--- |