Metadata-Version: 2.1
Name: django-candlestick
Version: 0.2.0
Summary: A django library for tracking and storing the prices of assets over time.
Home-page: https://github.com/samirelanduk/django-candlestick
Author: Sam Ireland
Author-email: mail@samireland.com
License: GPLv3+
Keywords: django stocks
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 3.1
Classifier: Framework :: Django :: 3.2
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Topic :: Office/Business :: Financial :: Investment
Classifier: Framework :: Django
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Python: !=2.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: django-timezone-field
Requires-Dist: yfinance

# django-candlestick

![](https://github.com/samirelanduk/django-candlestick/actions/workflows/main.yml/badge.svg)
![](https://img.shields.io/github/last-commit/samirelanduk/django-candlestick/master.svg)
[![](https://img.shields.io/pypi/pyversions/django-candlestick.svg?color=3776AB&logo=python&logoColor=white)](https://www.python.org/)
[![](https://img.shields.io/pypi/djversions/django-candlestick?color=0C4B33&logo=django&logoColor=white&label=django)](https://www.djangoproject.com/)
[![](https://img.shields.io/pypi/l/django-candlestick.svg?color=blue)](https://github.com/samirelanduk/django-candlestick/blob/master/LICENSE)

django-candlestick is a django library for storing price data for stocks, assets,
currencies, and other tradeable instruments.

## Setup

Install:

```bash
$ pip install django-candlestick
```

Add to installed apps:

```python
INSTALLED_APPS = [
    ...
    "candlestick"
    ...
]
```

Migrate:

```bash
$ python manage.py migrate
```

You now have a database of tradeable instruments and their prices.

## Use

### Manual

```python
from candlestick.models import Instrument, Bar

apple = Instrument.objects.create(
    symbol="AAPL", name="Apple, Inc.", currency="USD", timezone="US/Eastern"
)
bar = Bar.objects.create(
    open="320.13", low="319.88", high="321.4", close="320.17", volume=3115337,
    timestamp=1579887000, resolution="H", instrument=apple
)
print(bar.datetime) # 2020-01-24 12:30:00-05:00
```

### From YAHOO

```python
apple.fetch(resolution="M") # Gets all bars for the month resolution
apple.update(resolution="H") # Gets new bars for the H resolution
```

### At command line

To fetch bars for an instrument:

```bash
$ python manage.py fetch AAPL D
```

To update bars for an instrument:

```bash
$ python manage.py update AAPL D
```

To update bars for multiple instruments:

```bash
$ python manage.py update AAPL,AMZN D
```

To update bars for all instruments:

```bash
$ python manage.py update all D
```

