Skip to content

Instantly share code, notes, and snippets.

View neerav1985's full-sized avatar

Neerav Shah neerav1985

  • Jersey City, NJ
View GitHub Profile
@neerav1985
neerav1985 / nifty_spx_correlation.r
Created April 23, 2014 02:06
Nifty S&P 500 Correlation
library(plyr)
library(lubridate)
library(reshape)
library(zoo)
library(forecast)
#Input data
startdate <- mdy("01-01-2013")
enddate <- mdy("04-13-2014")
freq <- "d" #daily
@neerav1985
neerav1985 / principal_component_analysis.py
Created April 13, 2014 12:57
Principal Component Analysis in Python
>>>from numpy import *
>>> # Define a matrix X that has 3 column vectors as the observations variables
>>> X = array([[1, 2, 3], [2, 4, 5], [1, 2, 5], [10,2,3], [25,23,1]])
>>> X
array([[ 1, 2, 3],
[ 2, 4, 5],
[ 1, 2, 5],
[10, 2, 3],
[25, 23, 1]])
>>> # Calculate covariance matrix
@neerav1985
neerav1985 / bcp_out_all_tables.py
Created January 21, 2014 18:24
Script to bcp out all the tables/or individual table from a sybase server using python multiprocessing module
#
# $Id: bcp_out_all_tables.py 22322 2013-04-01 18:05:06Z neerav1985 $
#
import sys
import argparse
import textwrap
import workerpool
import commands
import logging
@neerav1985
neerav1985 / nifty_option_spot.py
Created January 20, 2014 02:14
Get spot price and options data from NSE India(www.nseindia.com) website
'''
Created on Oct 26, 2013
@author: pokerface
This code gets the spot price and options data from NSE India(www.nseindia.com) website
'''
import urllib2
@neerav1985
neerav1985 / twitter_wordcloud.r
Last active January 3, 2016 07:39
Get twerts using twitteR library in R and create wordcloud
#install.packages(c("twitteR","ROAuth","tm","wordcloud","RXKCD"))
library(twitteR)
library(ROAuth)
library(plyr)
library(RXKCD)
library(tm)
library(wordcloud)
library(RColorBrewer)
@neerav1985
neerav1985 / Calculate_Implied_Vol.py
Last active December 6, 2022 15:11
Calculate Implied Volatility of an option price given its market price
from numpy import *
from scipy.stats import norm
from scipy.optimize import root, fsolve, newton
import logging
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=logging.DEBUG)
def BlackScholesCall(S, K, T, sigma, r = 0., q = 0.):
#logging.debug("S=" + str(S) + ",K=" + str(K) + ",T=" + str(T) + ",sigma=" + str(sigma) + ",r=" + str(r) + ",q=" + str(q) )
@neerav1985
neerav1985 / pandas_beginner.py
Created December 13, 2013 16:34
Python: Fetch data from an Oracle and Pandas for data analysis
import cx_Oracle
import logging
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=logging.DEBUG)
if __name__ == "__main__":
conn = cx_Oracle.connect(user,password,server)
cursor = conn.cursor()