This blog is all about informatory articles based on my experience on various areas, including information technology, communications research, stock trading, traveling and cooking.
Friday, 29 September 2017
A life changing message from Shahrukh Khan - the second richest actor in the world
"7 out of 10 things I do are highly uncreative"
"I take the money I make out of those 7 movies, and I would like to create a production house that will make the kind of movies that I would like to make"
"Don't stay poor and hungry, you owe it to your life, you owe it to your parents"
"When you get into a position of choice, don't misuse it"
Shahrukh Khan although hates the highly uncreative bits of work he does, he continues to do that to get into a position of choice, at which he can make the choices he would like to make. Being creative doesn't justify staying hungry and poor. First make sure that you meet your basic needs and once you do that, you get into a position of choice. When you get into a position of choice don't cheat with your choices.
Labels:
creativity,
gauri khan,
how to be happy,
law school,
movies,
red chillies entertainment,
shahrukh khan,
srk,
yale
Monday, 27 October 2014
Bing Search Using Python
Partial output of the above Python script is shown below:
Labels:
beautifulsoup,
bing search,
google,
html,
pages,
parse,
python,
search results,
yahoo
Sunday, 5 October 2014
Calculation of Beta of Stocks Using Python Libraries (Stock Risk Analysis)
As an example, let us consider Coca Cola (NYSE:KO). Historical Coca Cola stock data can be downloaded from Google Finance:
Historical NYSE:KO Data
Suppose we consider NYSE:SPY as the market indicator/index in calculating beta. Historical stock data of NYSE:SPY can be downloaded from Google Finance:
Historical NYSE:SPY Data
The following python script finds the beta value for market indicator and symbol historical data file names passed as command line parameters:
Historical NYSE:KO Data
Suppose we consider NYSE:SPY as the market indicator/index in calculating beta. Historical stock data of NYSE:SPY can be downloaded from Google Finance:
Historical NYSE:SPY Data
The following python script finds the beta value for market indicator and symbol historical data file names passed as command line parameters:
Labels:
alpha,
beta,
coca cola,
coke,
investment,
line fitting,
markets,
python,
regression analysis,
risk analysis,
s&p 500,
spy,
statistics,
stocks
Saturday, 30 August 2014
Stock Price/Volume Analysis Using Python and PyCluster
In this blog post we will be looking at how k-means (http://en.wikipedia.org/wiki/K-means_clustering) cluster analysis can be used to create clusters of (price, volume) data of stocks.
The following python script can be used to create clusters. The input is trading date, close price and volume obtained from a comma separated file. The number of clusters can be set at the time of execution of the script. Furthermore, in this specific example, we will be clustering the data into 2/3/4/5 clusters. Also, note that, if there are less than a specified percentage of points within a cluster, we believe these points maybe a result of some extraordinary events related to that particular stock (outlier). This percentage largely depends on the number of data points and the number of clusters.
The following figure shows the output of the above Python script with 2 clusters:
The following figure shows the output of the above Python script with 3 clusters:
The following figure shows the output of the above Python script with 4 clusters:
The following figure shows the output of the above Python script with 5 clusters:
The following figure shows the output of the above Python script with 2 clusters:
The following figure shows the output of the above Python script with 3 clusters:
The following figure shows the output of the above Python script with 4 clusters:
The following figure shows the output of the above Python script with 5 clusters:
Labels:
clustering,
data mining,
kmeans,
numpy,
PyCluster,
pyplot,
python,
statistics,
stock exchange,
unusual events,
z-score
Wednesday, 18 June 2014
Print HTTP Response Header: Python
When you make an HTTP request to retrieve a webpage you get an HTTP response back. This response includes the usual response body that we see in the web browsers and an HTTP header, which is usually not shown in the web browsers. But this HTTP header may give some useful insight about the web page, web server, cookies, etc.
The following simple python script prints the HTTP response header for the URL passed as a command line parameter:
Output of the above script, with http://python.org as the command line parameter, is shown below:
Output of the above script, with http://python.org as the command line parameter, is shown below:
Labels:
age,
http,
http response,
https,
python,
reponse header,
server information,
set cookies,
x-sameorigin,
x-xss
Monday, 5 May 2014
Compare HTML Pages: HTML Tags Counter
There are many instances in which we would want to compare HTML templates programmatically. One of the simplest methods or one of the factors that could be used to rule out the similarity of two HTML pages is to count the number of HTML tags in those pages and compare the same.
The following Python script helps to get the HTML tag count of an HTML webpage given a URL:
A sample output of the above script is given below:
The following Python script helps to get the HTML tag count of an HTML webpage given a URL:
A sample output of the above script is given below:
Labels:
compare html pages,
compare html templates,
counter,
dictionary,
div,
html,
map,
script,
table,
tag,
tags,
urllib,
website similarity
Sunday, 4 May 2014
An Extremely Simple and Effective Web Crawler in Python
Web crawlers also known as web spiders are used in retrieving web links/pages by following links starting from the seed/initial web page. Crawlers are widely used in building search engines. The retrieved links/pages have numerous applications.
The following Python script is an extremely simple and effective web crawler! It can be configured to use different seed URLs and also different depth.
A partial output of the above script with http://www.cnn.com as the seed URL is given below:
Primary functions/operations of web link crawlers are:
1. Retrieve seed web page
2. Extract all valid URLs/links
3. Visit every link extracted in step 2.
4. Stop if depth has reached maximum depth.
The following Python script is an extremely simple and effective web crawler! It can be configured to use different seed URLs and also different depth.
A partial output of the above script with http://www.cnn.com as the seed URL is given below:
Labels:
crawler,
easy,
efficient,
extract urls,
http,
https,
python,
regex,
seed url,
simple,
spider,
urllib,
web,
web crawler,
web parser,
web spider
Subscribe to:
Posts (Atom)



