Saturday, October 25, 2014

Beta, SCL with bulk NSE data

As a continuation of the previous post on calculating beta, we test the model with the closing share prices of 44 companies that are a part of the CNX Nifty index.

Instead of following the Yahoo Finance based data collection strategy shown in the sample program of the text book, we have written our own data extraction routine based on Quandl. Note that
niftStks04_* is a set of four lists that have names of NIFTY companies for which we have data from 2004
niftStks09 is a list of names of NIFTY companies for which we have data from 2009
niftStks13 is a list of names of NIFTY companies for whch we have data from 2013

For the purpose of our exercise we have used data from 2009 onwards so that we have excluded the last list.

As a sanity check, we have extracted the CNX Nifty data, twice, once along with the company share price data and once as a standalone data with the corresponding dates. By laying out this data side-by-side in the Close01 data.frame through a cbind, we can see the dates of the closing prices of the company data.

   setwd("C:/Users/admin/Desktop/Data Analytics/QuantitativeFinance/QFLabs")


Cstartdate = '2009-06-01'
Cenddate = '2014-06-01'
IIR00 <- Quandl('BCB/17901', trim_start = Cstartdate, trim_end = Cenddate)
IIR00$Value <- IIR00$Value/1200
NIFTY <- Quandl("NSE/CNX_NIFTY", trim_start = Cstartdate, trim_end = Cenddate, collapse="monthly")
NIFTY01 <- NIFTY[,c('Date','Close')]

nifStks13_1 <- c("COALINDIA","HEROMOTOCO","SSLT","INFY")


comps <- c("CNX_NIFTY",nifStks04_1,nifStks04_2,nifStks04_3,nifStks09_1)

Close <-, function(x) {
  NSEx <- paste("NSE", x, sep = "/")
  Quandl(NSEx, trim_start = Cstartdate, trim_end = Cenddate, collapse="monthly")$Close

Close01 <- cbind(NIFTY01,Close)

IIR01 <- IIR00$Value

logreturn1 <- function(x) log(head(x,-1)/tail(x,-1))
##riskpremium <- function(x) logreturn1(x) - head(IIR01,-1)
riskpremium <- function(x) logreturn1(x) - IIR00$Value

Returns <-,2,riskpremium))


r <-t(sapply(comps, function(comp)
  c(beta = lm(Returns[,comp] ~ riskpremium(NIFTY01$Close))$coefficients[[2]],
    mean = mean(Returns[,comp]))
r1 <-
plot(r1$beta, r1$mean)
abline(lm(r1$mean ~ r1$beta), col = 'red')

Once the program is run, the following graph is generated


  1. It is possible that you'll have the option to go with independent web designers or can employ all out help web designers to get your web presence, additionally called website.

  2. Titanium Wok, Chrome, 3 piece steel
    Titanium Wok, Chrome, 3 piece steel. T-12:24 PM titanium gold - snow peak titanium $4.95. T-12:24 PM $13.95. T-12:24 PM - $5.95. titanium necklace T-12:24 iron titanium token PM $13.95. T-12:25 PM - $4.95. T-12:25 PM - $5.95. titanium septum ring T-12:25 PM

  3. 아모잘탄패밀리 처럼 ‘패밀리’ 제품들의 성장에 힘입어 다른 제약사들도 이런 제품들을 구성해 두려는 움직임이 많다. 한미약품은 아모잘탄을 이을 또 다른 패밀리 퍼스트카지노 라인업으로 어떤 것을 준비하고 있는지. 코로나19로 고전했던 북경한미약품도 완연한 성장 기조를 보이고 있습니다. 올해는 북경한미약품만 three,000억 매출을 돌파할 수 있을 것으로 보고 있다.

  4. Players qualifying with a number of} stacks to Day 2 will solely play their largest stack. This award-winning collection may 포커 사이트 give you a style of the alternatives you can be missing! At Mohegan Sun each Team Member is a part of|is part of} our success story. Catch a glimpse of what occurs behind the scenes to make everyday basis} at Mohegan Sun one of the best expertise for everyone who walks in; whether or not it's by way of the front doors or the again.