An open API service indexing awesome lists of open source software.

https://github.com/samirelanduk/django-candlestick

Price data in Django
https://github.com/samirelanduk/django-candlestick

forex stock-market stock-prices

Last synced: 8 months ago
JSON representation

Price data in Django

Awesome Lists containing this project

README

          

# 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
```