indiTraders - Forum for the Active Indian Trader  

Go Back   indiTraders - Forum for the Active Indian Trader > Tools > Software > Other Platforms

Reply
 
Bookmark and Share LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 25-04-2016, 12:15 PM
nTP's Avatar
nTP nTP is online now
Flash Crash
 
Join Date: Dec 2013
Location: kolkata
Posts: 2,079
Thanks: 7,888
Thanked 2,296 Times in 1,372 Posts
nTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud of
Default PY: $wPCR

Hi


wPCR in PyThon


Code:
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=[]


#nf_calls[['VolumeCalls']]=np.nan
#nf_puts[['VolumeCalls']]=np.nan
i=min_avalable_strikes=4850
max_avalable_strike=9400
nf_opt_CE=nf_opt_PE=pd.DataFrame()

while i in range(min_avalable_strikes,max_avalable_strike):
    temp_CE = get_history(symbol="NIFTY",
                         start=date(2016,2,1), 
                         end=date(2016,4,24),
                         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)
    '''
    
    temp_PE = get_history(symbol="NIFTY",
                         start=date(2016,2,1), 
                         end=date(2016,4,22),
                         index=True,
                         option_type="PE",
                         strike_price=i,
                         expiry_date=date(2016,4,28))
    #nf_opt_PE.rename(columns = {'Number of Contracts':'Volume'}, inplace = True)
    #nf_opt_CE.rename(columns = {'Number of Contracts':'Volume'}, inplace = True)

    #temp_CE=temp_CE.drop(temp_CE[temp_CE['Number of Contracts']>0.0].index)
    #temp_PE=temp_PE.drop(temp_CE[temp_CE['Number of Contracts']>0.0].index)
    nf_opt_CE=pd.concat([nf_opt_CE,temp_CE]).drop_duplicates()
    nf_opt_PE=pd.concat([nf_opt_PE,temp_PE]).drop_duplicates()
    nf_opt_CE.index=pd.to_datetime(nf_opt_CE.index)
    nf_opt_PE.index=pd.to_datetime(nf_opt_PE.index)
    i=i+50
    #print(i)

#print(nf_opt_PE.head())
nf_opt_PE.drop_duplicates(inplace=True)
nf_opt_CE.drop_duplicates(inplace=True)
#print(nf_opt_PE.head(100))

nf_opt_PE.rename(columns = {'Number of Contracts':'Volume'}, inplace = True)
nf_opt_CE.rename(columns = {'Number of Contracts':'Volume'}, inplace = True)

nf_opt_PE.drop(['Symbol','Expiry','Open','High' ,'Low','Last','Settle Price','Turnover','Open Interest'  ,'Change in OI','Underlying'],axis=1,inplace=True)

nf_opt_CE.drop(['Symbol','Expiry','Open','High' ,'Low','Last','Settle Price','Turnover','Open Interest','Change in OI','Underlying'],axis=1,inplace=True)

nf_opt_PE = nf_opt_PE[nf_opt_PE.Volume > 0]
nf_opt_CE = nf_opt_CE[nf_opt_CE.Volume > 0]
#print(nf_opt_PE.tail())

##priceCrossVolume###
nf_opt_PE['PESum']=nf_opt_PE.groupby(level=0)['Premium Turnover'].sum()
nf_opt_CE['CESum']=nf_opt_CE.groupby(level=0)['Premium Turnover'].sum()

#nf_puts= nf_opt_CE['Number of Contracts']*nf_opt_CE['Close']
#print(nf_calls.head())


nf_opt_PE.drop(['Volume','Close'],axis=1,inplace=True)
nf_opt_CE.drop(['Volume','Close'],axis=1,inplace=True)
#print(nf_opt_PE.index.Date)
#nf_opt_PE['Summation']=

wPCR= (nf_opt_PE['PESum']/nf_opt_CE['CESum'])
#wPCR.rename(columns = {'0':'wPCR'}, inplace = True)
wPCR.plot()
plt.show()

print(wPCR.head(500))
#print(nf_opt_PE.tail(500))
__________________
thx
nTuple

Disclaimer: I am not a Research Analyst and not registered with any regulating authority. All posts are for educational purpose only.

Consider us a dumb -dumble guy in this analysis, any type of real time example will be quick-learn approach.

Last edited by nTP; 25-04-2016 at 12:18 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to nTP For This Useful Post:
  #2 (permalink)  
Old 26-04-2016, 01:19 PM
nTP's Avatar
nTP nTP is online now
Flash Crash
 
Join Date: Dec 2013
Location: kolkata
Posts: 2,079
Thanks: 7,888
Thanked 2,296 Times in 1,372 Posts
nTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud of
Default

PCR Dollar weighted – McMillan refine with value. Instead of PCR volume, this approach creates the ratio of value rather than volume. the calculation goes like this – you calculate each strike price value multiplied with volume traded in that strike price individually and then add all call value and put value and take the ratio of it.
Dollar Value = option price * option Volume
Ratio = Sum of dollar value of Puts/ sum of dollar value of calls;

Some mentioned this indicator failed to create topping at the Oct 1987, as compared to traditional PCR volume. Anyway its difficult to convince all what method is right, everyone has their own opinion. At the end of we need to see which is better to our market and how it is able to give maximum favourable signals. With my research goes on all these, I found PCR Dollar weighted was mostly giving favourable signals in Indian markets.

ref: http://www.marketcalls.in/trading-le...t-trading.html

ref2 : http://investment-and-finance.net/de...all-ratio.html
Attached Images
File Type: png figure_1-1.png (53.8 KB, 4 views)
__________________
thx
nTuple

Disclaimer: I am not a Research Analyst and not registered with any regulating authority. All posts are for educational purpose only.

Consider us a dumb -dumble guy in this analysis, any type of real time example will be quick-learn approach.

Last edited by nTP; 27-04-2016 at 01:48 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to nTP For This Useful Post:
Reply

indiTraders - Forum for the Active Indian Trader > Tools > Software > Other Platforms


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT +5.5. The time now is 12:07 PM.


vBulletin Copyright by vBulletin

Content Relevant URLs by vBSEO 3.3.2