Code Monkey home page Code Monkey logo

flattrade-symbolsearch's Introduction

Flattrade-SymbolSearch

Downloading and searching symbols in Flattrade symbolmaster

==> This code needs python 3.11 and latest pandas (above 2.0) to run correctly.

==> BFO Exchange is still not implemented.

==> It is still in development phase and may produce various errors.

==> Sometimes it is stucked when fetching symbolmaster(from web). I couldn't figure out the reason till now.

==> get_exchange will not work correctly if "NSE" and "NFO" both exchange are initialised at same instance. Some common symbols creates that issue.

    ***So two separate instances needed to run thing correctly as for now.***
from symbolsearch import SearchScrip
sc = SearchScrip()
Now its needed to initialize symbols of the required exchanges. 

It will not not download the symbolmaster for a exchange within the same day twice unless

it is specified by using hard_refresh=True
exch_list = ['NSE', 'NFO']
sc.initialize_symbols(exch_list=exch_list)

get_expiry(exch, instrument, symbol, expiry) By default, it returns current expiry of banknifty options

sc.get_expiry()
datetime.date(2023, 7, 13)
sc.get_expiry(exch='NFO', instrument='FUTIDX', symbol='FINNIFTY',expiry='current')
datetime.date(2023, 7, 25)

search_scrip(exch, **kwargs)

The function will return in 3 different ways depending on the inputs

1. if **kwargs params are symbol, instrument, optiontype, expiry, strikeprice then it 
will return corresponding tradingsymbol and token

2. if **kwargs params are same as point 1 but lacks any of the input then it will 
return a dict of  tradingsymbols and tokens

3. if **kwargs input is tradingsymbol then it will return the corresponding token
sc.search_scrip(exch='NFO', symbol='BANKNIFTY', instrument='OPTIDX', 
                optiontype='CE', expiry="13-7-2023", strikeprice=44000)
array(['BANKNIFTY13JUL23C44000', 41702], dtype=object)
sc.search_scrip(exch='NFO', symbol='BANKNIFTY', instrument='OPTIDX', 
                expiry="13-7-2023", strikeprice=44000)
{'BANKNIFTY13JUL23P44000': 41703, 'BANKNIFTY13JUL23C44000': 41702}
sc.search_scrip(exch='NFO', tradingsymbol='BANKNIFTY13JUL23C44000')
41702

get_tradingsymbol(exch, **kwargs)

Returns tradingsymbol

**kwargs params are symbol, instrument, optiontype, strikeprice, expiry for 'NFO', 
'MCX' & 'CDS'

**kwargs params are symbol, instrument for 'NSE'
sc.get_tradingsymbol(exch='NFO', symbol='BANKNIFTY', instrument='OPTIDX', 
                optiontype='CE', expiry="13-7-2023", strikeprice=44000)
'BANKNIFTY13JUL23C44000'
sc.get_tradingsymbol(exch='NSE', symbol='HDFC', instrument='EQ')
'HDFC-EQ'

get_lotsize(exch, **kwargs)

Returns lotsize of the given symbol.

1. **kwargs -> tradingsymbol

2. **kwargs -> symbol, expiry

3. **kwargs -> symbol (lacks accuracy as it will return the lotsize 
        regardless of expiry.)
sc.get_lotsize(exch='NFO', symbol='BANKNIFTY')
25
sc.get_lotsize(exch='NFO', symbol='BANKNIFTY', expiry='27-7-2023')
15
get_exchange(tradingsymbol)

Returns the corresponding exchange name for the given tradingsymbol.
sc.get_exchange(tradingsymbol="BANKNIFTY27JUL23C52000")
'NFO'
get_strikediff(exch,symbol)

Returns Option strikeprice difference for the given symbol. 'NFO' is the default exchange. 
sc.get_strikediff(symbol="HDFCBANK")
10.0
sc.get_strikediff(exch='MCX', symbol='CRUDEOIL')
50.0

flattrade-symbolsearch's People

Contributors

tapanhaz 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.