Skip to main content

Python 3.x module to render financial results in tensorboard

Project description

8 MILE

Build Documentation

Python 3.x module to treat financial data. Many features including :

  • download financial data from various sources
  • preprocess data
  • export data
  • plot data in tensorboard

Installation 🔥

Pre-requisites:

  • python3
  • pip3

Install the talib library:

wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
tar -xzf ta-lib-0.4.0-src.tar.gz
cd ta-lib/ && ./configure --prefix=/usr && make && make install

Install the package with pip3

pip3 install hmile

Usage 🚀

Simple example do download yahoo data and apply all ta features to it.

PAIR = "BTCUSD"
START = "2021-12-01"
END = "2022-05-24"
INTERVAL = "hour"

PATH = 'output/csvdataexporter'


yf_dp = YahooDataProvider(PAIR, START, END, interval=INTERVAL)
data = TaFeaturesTransformer(yf_dp).transform()
print(data.tail(10))

Using tensorboard plotting with RabbitRenderer

from datetime import datetime
import pandas as pd
from Hmilerender.RabbitRenderer import RabbitRenderer

def fill_renderer(data, renderer):
 # we fill the renderer with data rows
   for index, row in data.iterrows():
      date = datetime.strptime(row["Date"], "%Y-%m-%d")
      renderer.append("open", row["open"], date)
      renderer.append("close", row["close"], date)
      renderer.append("high", row["high"], date)
      renderer.append("low", row["low"], date)
      renderer.append("volume", row["volume"], date)
      renderer.append("exit", row["exit"], date)
      renderer.append("long", row["long"], date)
      renderer.append("short", row["short"], date)
      renderer.append("money", row["money"], date)

# we create a renderer object
renderer = RabbitRenderer('logs/')
# we read data
data = pd.read_csv('data/data.csv')
# we fill renderer
fill_renderer(data, renderer)
# we launch renderer
renderer.render()
# then we increment tensorboard step
renderer.next_step()
# we refill the renderer
fill_renderer(data, renderer)
# we launch renderer
renderer.render()

Build doc 🛠️

You can rebuild the doc with the following commands:

make html
rm -r docs
mv _build/html docs
rm -rf _build

Documentation 📚

Find doc here

Launch tests 🧪

Please ensure you have installed docker and docker-compose.

First build the docker image:

docker compose build

Then start the containers :

docker compose up -d

Then run the tests :

docker compose run --rm tester python3 /app/test/test_dataexporter.py
docker compose run --rm tester python3 /app/test/test_dataprovider.py
docker compose run --rm tester python3 /app/test/test_datatransformer.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hmile-0.2.3.tar.gz (10.9 kB view hashes)

Uploaded Source

Built Distribution

hmile-0.2.3-py3-none-any.whl (12.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page