Skip to content

Commit

Permalink
💼 feat(data): unemployment rate 💼 (#91)
Browse files Browse the repository at this point in the history
* progress

* changes

* remove unnecessary code

* endpoint update

* remove get_endpoint

* add unrate

* add to workflows

* flake

* forgot to add workflow

* fix test
  • Loading branch information
suchak1 authored Feb 8, 2021
1 parent 5ae60b7 commit 93b0d06
Show file tree
Hide file tree
Showing 10 changed files with 277 additions and 67 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
RH_2FA: ${{ secrets.RH_2FA }}
IEXCLOUD: ${{ secrets.IEXCLOUD_SANDBOX }}
STOCKTWITS: ${{ secrets.STOCKTWITS }}
BLS: ${{ secrets.BLS }}
APCA_API_KEY_ID: ${{ secrets.APCA_API_KEY_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ env:
S3_BUCKET: ${{ secrets.S3_DEV_BUCKET }}
APCA_API_KEY_ID: ${{ secrets.APCA_API_KEY_ID }}
POLYGON: ${{ secrets.POLYGON }}
BLS: ${{ secrets.BLS }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
Expand Down Expand Up @@ -80,5 +81,8 @@ jobs:
- name: Update intraday
run: python scripts/update_intraday.py

- name: Update unemployment
run: python scripts/update_unrate.py

- name: Upload repo to S3
run: python scripts/update_repo.py
46 changes: 46 additions & 0 deletions .github/workflows/unemployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This workflow will automatically update data files
# For more information see: https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule

name: Unemployment

on:
schedule:
- cron: "0 8 15 * *"
# 3:00am EST

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Cache pip dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Update unemployment
env:
BLS: ${{ secrets.BLS }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
S3_BUCKET: ${{ secrets.S3_BUCKET }}
run: python scripts/update_unrate.py
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,27 @@ Using Robinhood 2FA, we can simply provide our MFA one-time password in the `.en

### Data

- [ ] Price and Volume
- [x] Price and Volume
- [x] [![Symbols](https://github.com/suchak1/hyperdrive/workflows/Symbols/badge.svg)](https://github.com/suchak1/hyperdrive/actions?query=workflow%3ASymbols)
- [x] [![OHLC](https://github.com/suchak1/hyperdrive/workflows/OHLC/badge.svg)](https://github.com/suchak1/hyperdrive/actions?query=workflow%3AOHLC)
- [x] [![Intraday](https://github.com/suchak1/hyperdrive/workflows/Intraday/badge.svg)](https://github.com/suchak1/hyperdrive/actions?query=workflow%3AIntraday)
- [x] Actions
- [x] [![Dividends](https://github.com/suchak1/hyperdrive/workflows/Dividends/badge.svg)](https://github.com/suchak1/hyperdrive/actions?query=workflow%3ADividends)
- [x] [![Splits](https://github.com/suchak1/hyperdrive/workflows/Splits/badge.svg)](https://github.com/suchak1/hyperdrive/actions?query=workflow%3ASplits)
- [ ] Mergers
- [ ] Buybacks
- [ ] Sentiment
- [ ] News Sentiment
- [x] [![Social Sentiment](<https://github.com/suchak1/hyperdrive/workflows/Social%20Sentiment%20(1)/badge.svg>)](https://github.com/suchak1/hyperdrive/actions?query=workflow%3A%22Social+Sentiment+%281%29%22)
- [ ] [Institutional Sentiment](http://www.aaii.com/files/surveys/sentiment.xls)
- [ ] [Investor Sentiment](http://www.aaii.com/files/surveys/sentiment.xls)
- [ ] Analyst Recommendations
- [ ] Company / Micro
- [ ] Profile (Sector, # of Employees)
- [ ] Earnings
- [ ] Cash Flow
- [ ] CEO Compensation
- [ ] Government / Macro

- [ ] Unemployment Rate
- [ ] Real GDP
- [ ] US Recession Probabilities

- [ ] Government / Macro <!-- this stuff prob won't be v useful -->
- [x] Unemployment Rate <!-- BLS -->
- [ ] Real GDP <!-- BEA -->
- [ ] US Recession Probabilities <!-- FRED -->
- [ ] Market
- [ ] General Volatility (VIX)
- [ ] Sector Performance
Expand Down
6 changes: 6 additions & 0 deletions scripts/update_unrate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sys
sys.path.append('src')
from DataSource import LaborStats # noqa

bls = LaborStats()
bls.save_unemployment_rate(timeframe='2y')
29 changes: 25 additions & 4 deletions scripts/upload_data.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
import sys
sys.path.append('src')
from Storage import Store # noqa autopep8
from DataSource import Polygon # noqa autopep8


store = Store()
poly = Polygon()


# to_download = ['DOW', 'DUK', 'FOX',
# 'GD', 'GE', 'GILD', 'GLD', 'GM']
to_download = ['HD', 'INSG']

# symbols = ['VTRS', 'IAC', 'CTVA', 'CARR', 'OTIS', 'HWM', 'GOOG']
# s3://hyperdrive.pro/data/intraday/polygon/
symbols = ['IBM', 'ICLN', 'INO', 'INTC',
'IPO', 'IQ', 'ISRG']
# F, G, H, I
if __name__ == '__main__':
# for symbol in symbols:
# store.upload_dir(path=f'data/intraday/polygon/{symbol}')
store.upload_dir(path='data/intraday/polygon')
for symbol in symbols:
store.upload_dir(path=f'data/intraday/polygon/{symbol}')
poly.save_intraday(
symbol=symbol,
timeframe='30d',
retries=1
)
for symbol in to_download:
poly.save_intraday(
symbol=symbol,
timeframe='6250d',
retries=1
)
9 changes: 9 additions & 0 deletions src/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def get_env_bool(var_name):
DELTA = 'Delta'
TWIT_RATE = 175

# Unemployment
UN_RATE = 'UnRate'

# Misc
POLY_CRYPTO_SYMBOLS = [
'X%3ABTCUSD', 'X%3AETHUSD',
Expand Down Expand Up @@ -153,6 +156,12 @@ def get_intraday_path(self, symbol, date, provider='iexcloud'):
f'{date}.csv'
)

def get_unemployment_path(self):
return os.path.join(
DATA_DIR,
'unemployment.csv'
)

def get_all_paths(self, path, truncate=False):
# given a path, get all sub paths
paths = []
Expand Down
Loading

0 comments on commit 93b0d06

Please sign in to comment.