Giter VIP home page Giter VIP logo

tickerstore's Introduction

Super simple to use

TickerStore is an easy to use python library used to get historical data of financial instruments from NSE.

Install

$ pip install tickerstore

Basic Usage

Using TickerStore you can specify the source from where the data needs to be fetched. At present, there are 2 sources of data Upstox and NSE. EOD (End of Day) data can be used simple by using the following piece of code.

from tickerstore.store import TickerStore
from datetime import date

fetcher = TickerStore()
fetcher.historical_data("SBIN", date(2018,1,1), date(2018,1,30), TickerStore.INTERVAL_DAY_1)

How it works?

TickerStore tries to make historical stock market data more easy to use in your python projects. TickerStore has multiple sources from where the data is fetched. At present we have 2 sources, NSE and Upstox. Data from these 2 sources are fetched in a predefined order.

The default order is:

  1. Upstox
  2. NSE

If one fails, the next one is tried in order. You can change the order using a set_fetch_order() method. To view the present fetch order use the get_fetch_order() method.

Using with .env file (python-dotenv)

Create a .env file in the present working directory and enter your Upstox API key and API secret and leave all other fields as it is.

UPSTOX_API_KEY=<YOUR_UPSTOX_API_KEY>
UPSTOX_API_SECRET=<YOUR_UPSTOX_API_SECRET>
UPSTOX_REDIRECT_URI=http://127.0.0.1:5000/callback
TEMP_SERVER_SHUTDOWN_URL=http://127.0.0.1:5000/shutdown
TEMP_SERVER_AUTH_PAGE=http://127.0.0.1:5000/

On python end, use the find_dotenv function from the python-dotenv package and pass it to the TickerStore. The information from the dotenv file will be available as environment variables.

from tickerstore.store import TickerStore
from dotenv import find_dotenv
from datetime import date

fetcher = TickerStore(dotenv_path=find_dotenv())
fetcher.historical_data("SBIN", date(2018,1,1), date(2018,1,30), TickerStore.INTERVAL_DAY_1)

Using with Upstox

Using only with Upstox:

from tickerstore.store import TickerStore
from datetime import date

fetcher = TickerStore(
    upstox_api_key="<YOUR_UPSTOX_API_KEY>",
    upstox_api_secret="<YOUR_UPSTOX_API_SECRET>",
    upstox_redirect_uri="http://localhost:5000/callback",
    temp_server_auth_page="http://localhost:8000/"
    )

fetcher.historical_data("SBIN", date(2018,1,1), date(2018,1,30), TickerStore.INTERVAL_DAY_1)

Change fetch order

Order in which the data is fetched from different sources can be changed.

from tickerstore.store import TickerStore
from dotenv import find_dotenv
from datetime import date

fetcher = TickerStore(dotenv_path=find_dotenv())
fetcher.set_fetch_order([TickerStore.NSE, TickerStore.UPSTOX])

fetcher.historical_data("SBIN", date(2018,1,1), date(2018,1,30), TickerStore.INTERVAL_DAY_1)

TickerStore now first fetches data from NSE and then from UPSTOX. You can even specify a single source and data will only be fetched from there.

API

Coming soon :)

tickerstore's People

Contributors

meticulouscraftman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.