Metadata-Version: 2.1
Name: bc-utils
Version: 0.1.1
Summary: Python utility automation scripts for Barchart.com
Home-page: https://github.com/bug-or-feature/bc-utils
License: BSD-3-Clause
Keywords: trading
Author: Andy Geach
Author-email: andy@bugorfeature.net
Requires-Python: >=3.8,<4.0
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Cython
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Software Development :: Libraries
Requires-Dist: bs4 (>=0.0.1,<0.0.2)
Requires-Dist: flake8 (>=4.0,<5.0)
Requires-Dist: pandas (>1,<=1.0.5)
Requires-Dist: requests (>=2.26,<3.0)
Project-URL: Issues, https://github.com/bug-or-feature/bc-utils/issues
Project-URL: Repository, https://github.com/bug-or-feature/bc-utils
Description-Content-Type: text/markdown

# bc-utils

[Barchart.com](https://www.barchart.com) allows registered users to download historic futures contract prices in CSV 
format. Individual contracts must be downloaded separately, which is laborious and slow. This script automates the process.

## Quickstart

```
from bcutils.bc_utils import get_barchart_downloads, create_bc_session

CONTRACTS={
    "AUD":{"code":"A6","cycle":"HMUZ","tick_date":"2009-11-24"},
    "GOLD": {"code": "GC", "cycle": "GJMQVZ", "tick_date": "2008-05-04"}
}

session = create_bc_session(config=dict(
    barchart_username="user@domain.com",
    barchart_password = "s3cr3t_321")
)

get_barchart_downloads(
    session,
    contract_map=CONTRACTS,
    save_directory='/home/user/contract_data',
    start_year=2020,
    end_year=2021
)
```

The code above would: 
* for the CME Australian Dollar future, get hourly OHLCV data for the Mar, Jun, Sep and Dec 2020 contracts
* download in CSV format
* save with filenames AUD_20200300.csv, AUD_20200600.csv, AUD_20200900.csv, AUD_20201200.csv into the specified directory
* for COMEX Gold, get Feb, Apr, Jun, Aug, Oct, and Dec data, with filenames like GOLD_20200200.csv etc

Features:
* Designed to be run once a day by a scheduler
* the script handles skips contracts already downloaded
* by default gets 120 days of data per contract, override possible per instrument
* dry run mode to check setup
* there is logic to switch to daily data when hourly is not available
* you must be a registered user. Paid subscribers get 100 downloads a day, otherwise 5


