Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console candlestick plot #8

Open
c0indev3l opened this issue Mar 3, 2014 · 2 comments
Open

Console candlestick plot #8

c0indev3l opened this issue Mar 3, 2014 · 2 comments

Comments

@c0indev3l
Copy link

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

@glamp
Copy link
Owner

glamp commented Apr 15, 2014

haha cool i'll take a look

@c0indev3l
Copy link
Author

ideally it will be nice if it could be integrate as a widget into urwid using inheritance of widget http://urwid.org/reference/widget.html see speedometer example http://excess.org/speedometer/
so we could have events...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants