pramakrishn / express-option-chain

This library utilizes Kite Connect APIs to fetch the option chain of all the derivatives traded in the Indian stock market.
MIT License
47 stars 16 forks source link

Feature to subscribe to multiple expiries #1

Open pramakrishn opened 1 year ago

pramakrishn commented 1 year ago

The existing functionality allows users to subscribe to a single expiry when utilizing the option chain feature. The capability to subscribe to multiple expiry dates concurrently is missing. This will broaden the versatility of the option chain and significantly benefit users managing diverse portfolios.

while subscribing users should be able to provide input like

data = {
'23-07-2023': ['NFO:BANKNIFTY', 'NFO:NIFTY'],
'25-08-2023': ['NFO:HDFCBANK', 'NFO:BANKNIFTY', 'NFO:NIFTY']
}
Gil3232 commented 1 year ago

Code describing the advanced usage: how to save the file in csv stream = OptionStream(symbols, secrets, expiry='23-02-2023', criteria=criteria, redis_config=RedisConfig(db=1) ) stream.start() after starting the stream. Can you please help me.

pramakrishn commented 1 year ago

@Gil3232 After starting the stream, you can use this code to create a csv I have added few columns, based on your requirement you can modify it


option_chain_fetcher = OptionChainFetcher()

option_chain = option_chain_fetcher.get_option_chain('NFO:BANKNIFTY')
import csv

filename = 'banknifty.csv'

# Write to the CSV file
with open(filename, 'w', newline='') as f:
    writer = csv.writer(f)

    headers = [
        'exchange', 'symbol', 'strike_price', 'ce_premium',
        'ce_bid_price', 'ce_ask_price', 'pe_premium',
        'pe_bid_price', 'pe_ask_price'
    ]
    writer.writerow(headers)

    expiry = option_chain['expiry']
    for expiry_date, options in expiry.items():
        for option in options:
            row = dict.fromkeys(headers, '')
            row['exchange'] = option_chain['exchange']
            row['symbol'] = option_chain['trading_symbol']
            row['strike_price'] = option['strike_price']

            for ce_pe in ('ce', 'pe'):
                if ce_pe in option:
                    row[f'{ce_pe}_premium'] = option[ce_pe]['premium']
                    row[f'{ce_pe}_bid_price'] = option[ce_pe]['bid_price']
                    row[f'{ce_pe}_ask_price'] = option[ce_pe]['ask_price']

            writer.writerow(row.values())
Gil3232 commented 1 year ago

Thank you so much.

On Sun, Jul 16, 2023 at 2:52 AM Prajwal Ramakrishna < @.***> wrote:

@Gil3232 https://github.com/Gil3232 After starting the stream, you can use this code to create a csv I have added few columns, based on your requirement you can modify it

option_chain_fetcher = OptionChainFetcher() option_chain = option_chain_fetcher.get_option_chain('NFO:BANKNIFTY')import csv

filename = 'banknifty.csv'

Write to the CSV filewith open(filename, 'w', newline='') as f:

writer = csv.writer(f)

headers = [
    'exchange', 'symbol', 'strike_price', 'ce_premium',
    'ce_bid_price', 'ce_ask_price', 'pe_premium',
    'pe_bid_price', 'pe_ask_price'
]
writer.writerow(headers)

expiry = option_chain['expiry']
for expiry_date, options in expiry.items():
    for option in options:
        row = dict.fromkeys(headers, '')
        row['exchange'] = option_chain['exchange']
        row['symbol'] = option_chain['trading_symbol']
        row['strike_price'] = option['strike_price']

        for ce_pe in ('ce', 'pe'):
            if ce_pe in option:
                row[f'{ce_pe}_premium'] = option[ce_pe]['premium']
                row[f'{ce_pe}_bid_price'] = option[ce_pe]['bid_price']
                row[f'{ce_pe}_ask_price'] = option[ce_pe]['ask_price']

        writer.writerow(row.values())

— Reply to this email directly, view it on GitHub https://github.com/pramakrishn/express-option-chain/issues/1#issuecomment-1636888916, or unsubscribe https://github.com/notifications/unsubscribe-auth/BBHVTOIKTPM5Y5WBUIAUURLXQMC2RANCNFSM6AAAAAA2DCNUA4 . You are receiving this because you were mentioned.Message ID: @.***>

hbinmadi commented 1 year ago

hi can this be done with proper gui, i am sure you have one, for some one who wants to focus on trading rather than coding, i have script for nsepython lib, which works but not reliable as data from nse is not fetched easily on every call

hbinmadi commented 1 year ago

my plan is to hire some one to develop me a reliable gui, which gives me real time change in io in near atm + 1000 -1000 of bank nifty option and change in price eg: pcr/ money in near ATM options,

hbinmadi commented 1 year ago

The existing functionality allows users to subscribe to a single expiry when utilizing the option chain feature. The capability to subscribe to multiple expiry dates concurrently is missing. This will broaden the versatility of the option chain and significantly benefit users managing diverse portfolios.

while subscribing users should be able to provide input like


data = {

'23-07-2023': ['NFO:BANKNIFTY', 'NFO:NIFTY'],

'25-08-2023': ['NFO:HDFCBANK', 'NFO:BANKNIFTY', 'NFO:NIFTY']

}

Any news about this update

sujeetk789 commented 11 months ago

Hi, How to fetch all FNO derivatives as per the symbol mention in an excel sheet? Suppose I had mentioned a cell name in excel as: Symbol Reliance then Reliance derivative data will fetch and show the CE/Pe max oi, LTPm Chng LTP, Volume, Ch in Oi, Max Oi strikes CE/PE then if i type TATAPOWER then their derivative data as above will show.

pramakrishn commented 11 months ago

Hi @sujeetk789, this project supports retrieving the data through APIs. If you have knowledge of programming, you can use the above snippet of code to write the data to an excel sheet.

pramakrishn commented 11 months ago

@hbinmadi I am not certain about the date.