Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffallan committed Sep 29, 2018
0 parents commit 213acd4
Show file tree
Hide file tree
Showing 33 changed files with 772 additions and 0 deletions.
119 changes: 119 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
## Model .gitignore File for Python Projects###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
*.pyc
# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/
docs/_static/
docs/_templates

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/


# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

#pydev
.project
.project/
.pydevproject
.pydevproject/

#pycharm
.idea/

#other
db.sqlite3
.vscode/
*.code-workspace
20 changes: 20 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
requests = "==2.19.1"
certifi = "==2018.4.16"
chardet = "==3.0.4"
idna = "==2.7"
python-decouple = "==3.1"
"urllib3" = "==1.23"
djangorestframework = "==3.8.2"
pytz = "==2018.5"
Django = "==2.1.1"

[dev-packages]

[requires]
python_version = "3.6"
92 changes: 92 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Introduction

This project aggregates historic stock data, relevant information, and news concerning specific publicly traded companies selected by the user.

The goal of this project is to provide the user with an automatically updating API containing only the data they care about.

# Quick Start

## The API
* Clone this repo in the directory you want to place it in.
* Create a new virtual environment and activate it.
* Run `pip install -r requirements.txt`.
* Rename the `model.env` file to `.env`
* Retrieve a free API key from https://www.alphavantage.co
* Place your API key after `API_KEY=` in your `.env` file DO NOT PLACE IT IN QUOTES.
* Alter the setting for `URL_BASE=` to `http://localhost:8000` in your `.env` file DO NOT PLACE IT IN QUOTES.
* Start the Django development server `python manage.py runserver`.
* Navigate to `http://localhost:8000/api/stocks_followed/` and add the ticker symbol of a stock you want data on.
* Manually (for now) run the update scripts, which are located in `popoulate.py` and enjoy.

# A Short Example

Lets say you want all the stock data on Google (GOOG). After adding GOOG to `http://localhost:8000/api/stocks_followed/` do the following with your virtual environment activated.

## Adding All Data

``` python
>>> from populate import StockPopulate
>>> stock = StockPopulate('GOOG')

# Create a variable for your stock data
>>> data = stock.get_all_data()
# Normalizes, and creates an iterable of the data, to post to our API
>>> stream = stock.normalize_all_data(data)
# Post the data to our API
>>>stock.post_all_data(stream)

# Or if you prefer a one liner
stock.post_all_data(stock.normalize_all_data(stock.get_all_data()))
```

## Updating Data With Specific Date

```python
>>> from populate import StockPopulate
>>> from datetime import date

>>> stock = StockPopulate('GOOG')
# TODO check to see if the market was active that day.
# Pass the date argument as a string
date = str(date.today())
# or
date = '2018-09-28'
data = stock.get_daily_data(date)
# post the data
stock.populate_updated_data(data)
```
4 changes: 4 additions & 0 deletions model.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# https://simpleisbetterthancomplex.com/2015/11/26/package-of-the-week-python-decouple.html

API_KEY=Alpha Vantage API key here
URL_BASE=Base URL here
Loading

0 comments on commit 213acd4

Please sign in to comment.