HappyHunt / ATAI-Stock-Game

0 stars 0 forks source link

Plot chart and indicator #7

Open HappyHunt opened 1 year ago

HappyHunt commented 1 year ago

Poradnik co do wykresów.

https://towardsdatascience.com/the-simplest-way-to-create-an-interactive-candlestick-chart-in-python-ee9c1cde50d8

Warto tego użyć.

https://github.com/matplotlib/mplfinance https://github.com/santosjorge/cufflinks Lub do ustalenia czy sami piszemy wszystko

HappyHunt commented 1 year ago

https://pl.tradingview.com/chart/E32ucf5J/?symbol=BINANCE%3ABTCUSDT

https://data.binance.vision/?prefix=data/futures/um/daily/klines/BTCUSDT/1m/

Baro-coder commented 1 year ago

Implementation - first step:

There is implemented function to create chart according to data stored in csv file.

import sys
import plotly.graph_objects as grObj
import pandas as pd
from datetime import datetime

DATA_FILEPATH = './client/charter/data/BTCUSDT-1m-2023-03-13.csv'

def main():
    try:
        df = pd.read_csv(DATA_FILEPATH)
        print(f'{DATA_FILEPATH} : File opened successfully.')
    except FileNotFoundError as e:
        print(f'{DATA_FILEPATH} : File not Found!')
        sys.exit(1)

    print('Processing...', end=' ')
    dfc = df['open_time'].copy()
    for i in range(df['open_time'].size):
        dfc[i] = datetime.fromtimestamp(float(df['open_time'][i])/1000)

    fig = grObj.Figure(data=[grObj.Candlestick(x=dfc,
                             open=df['open'],
                             high=df['high'],
                             low=df['low'],
                             close=df['close'])])
    print('Done.')

    fig.show()

    sys.exit(0)

if __name__ == '__main__':
    main()

Chart is hosted and displayed in browser session at localhost

Image

Future development

Data to draw must be provided from our server API, not from previosly downloaded csv file

HappyHunt commented 1 year ago

Dorobie pobieranie z bazy bo bede używał do testowania wskaźników