Skip to content

Console candlestick plot #8

Open
@c0indev3l

Description

@c0indev3l

Hello,

I'm looking for a python script to draw candlestick plot inside a text user interface (ncurses or urwid).

Could you help me to do that ?

For now I've done a script which download from Yahoo Finance
GOOG OHLCV data (and put data into a SQLite cache)

You need pandas, requests and requests-cache

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import requests

import requests_cache

expire_after = None #15*60 # expire_after=delay_second or None
requests_cache.install_cache('req_cache', backend='sqlite', expire_after=expire_after)

from StringIO import StringIO

import pandas as pd

def get_ohlcv_data(size, offset=0):
    url = "http://ichart.finance.yahoo.com/table.csv?s=GOOG"
    req = requests.get(url)
    #print(req.content)
    io = StringIO(req.content)
    df = pd.read_csv(io, sep=',', parse_dates=['Date'])
    df = df.rename(columns={
        'Date': 'date',
        'Open': 'open',
        'High': 'high',
        'Low': 'low',
        'Close': 'close',
        'Volume': 'volume',
        'Adj Close': 'adj close',
    })
    df = df.set_index('date')
    df = df[offset:size+offset][::-1]
    return(df)

def main():
    df = get_ohlcv_data(50, 0)
    print(df)
    print(df.dtypes)

    inc = df['close'] > df['open']
    dec = df['close'] < df['open']

if __name__ == "__main__":
    main()

An other sofware provide something similar
http://prof7bit.github.io/goxtool/

but I really want to isolate plot to be standalone.

It will be nice if bashplotlib could provide such feature.

Kind regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions