PCR (Doller weighted Put Call Ratio)calculation issues : I am trying to generate a Put / Call Ratio calculation program for my own purpose.Here is the code: problem is I am stuck in some places.
1.I need to generate a summation of all strikes volume * all strikes prices
2. and final one is generating the ratio.

So far I tried a lot and ended up having buggy program.However I am providing the code for now for further so that I can complete the rest of the part get the OutPut properly.(nse DO not provide PCR as CBO does provide a solution)

    from nsepy import get_history
    from datetime import date
    import pandas as pd
    import requests
    from io import BytesIO 
    import certifi
    from scipy import stats
    from dateutil.relativedelta import relativedelta
    import numpy as np
    #import matplotlib.pyplot as plt
    import datetime
    import numpy as np
    import matplotlib.colors as colors
    import matplotlib.finance as finance
    import matplotlib.dates as mdates
    import matplotlib.ticker as mticker
    import matplotlib.mlab as mlab
    import matplotlib.pyplot as plt
    import matplotlib.font_manager as font_manager
    import talib as ta
    from talib import MA_Type
    import statsmodels as sm
    
    
    
    nf_calls=[]
    nf_puts=[]
    wPCR=[]
    
    #nf_calls[['VolumeCalls']]=np.nan
    #nf_puts[['VolumeCalls']]=np.nan
    i=min_avalable_strikes=4850
    max_avalable_strike=9400
    while i in range(min_avalable_strikes,max_avalable_strike):
        nf_opt_CE = get_history(symbol="NIFTY",
                             start=date(2016,4,1), 
                             end=date(2016,4,22),
                             index=True,
                             option_type="CE",
                             strike_price=i,
                             expiry_date=date(2016,4,28))
        
        #print(nf_opt_CE.head())
        #if nf_opt_CE['Number of Contracts'].values >0 :
        '''if nf_opt_CE.empty :
            nf_opt_CE.append(0)
        '''
        
        nf_opt_PE = get_history(symbol="NIFTY",
                             start=date(2016,1,1), 
                             end=date(2016,4,18),
                             index=True,
                             option_type="PE",
                             strike_price=i,
                             expiry_date=date(2016,4,28))
        print(nf_opt_PE.head())
        #print(nf_opt_PE.head())
        #print(i)
        #if nf_opt_PE['Number of Contracts'].values>0 :
        '''if nf_opt_CE.empty :
           nf_opt_PE.append(0)
        '''
       
        i=i+50
    
        
    #print(wPCR)
    
    '''def PCRForSym():
        return NULL
    '''
    
    
    
    
    nf_opt_PE['NewCols']=nf_opt_PE['Number of Contracts']* nf_opt_PE['Close']
    
    nf_opt_CE['NewCols']= nf_opt_CE['Number of Contracts']*nf_opt_CE['Close']
    
    
    
    #wPCR=nf_puts
    
    print(nf_opt_PE.head())

