Skip to content

Provide example with Pandas / Pandas DataReader #16

Description

@femtotrader

Following #9 (comment)

Pandas is a great Python library for data analysis
See https://en.wikipedia.org/wiki/Pandas_(software) for more information

Pandas DataReader, a sibling project of Pandas, provides several remote data sources
https://pydata.github.io/pandas-datareader/remote_data.html

Maybe TermGraph could provide 2 examples with Pandas / Pandas DataReader.

One with static data (like https://github.com/sgeisler/termgraph/blob/master/examples/data.csv)
#9 (comment)
An other example with Python Pandas read_csv function

import pandas as pd

df = pd.read_csv("data.csv", sep=";")
example_data = df.apply(lambda row: Candle(row["open"], row["high"], row["low"], row["close"]), axis=1)

One with remote data source and a cache mechanism (to avoid too much requests)

import pandas_datareader.data as web
import datetime
import requests_cache
expire_after = datetime.timedelta(days=3)
session = requests_cache.CachedSession(cache_name='cache', backend='sqlite', expire_after=expire_after)

df = web.DataReader('^DJI', 'stooq', session=session)
example_data = df.apply(lambda row: Candle(row["Open"], row["High"], row["Low"], row["Close"]), axis=1)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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