Building a custom machine learning model on android
Programming for Financial Strategies
1. Programming for Financial Strategies
Summer Internship at Lama Capital Management.
Under the guidance of Mr. Abhinav Kumar and Mr. Anirudh Chaudhary
Internship period: 11 May-18 July 2015
By:- Prabhakar Verma
2012EE10467
2. Overview
Introduction
Part A: Plots in Java Script
Part B: Scrapy in python
Part C: Strategy Programing in python
Optimization and maximization of profit
Data-frame from pandas library of python
Finally summed up.
3. Introduction
LCM is an investment management fund founded in 2013 by former Wall Street
professionals.
Primarily engaged in volatility and statistical strategies across a diversified range of
asset classes - equities, commodities, and foreign exchange.
Quantitative analysis and statistical modelling to find opportunities in liquid
exchange traded instruments.
4. Plots in Java Script
To plot Return vs Frequency curves in browser using Google API.
Calculations in python and plot using JavaScript.
Linkage between frontend and backend of the website, i.e. between JavaScript and python.
Once we get the values of two variables, plot it using google API.
google.load(); // load the visualization API and chart package.
google.setOnLoadCallback(); // to set a callback to run when visualization API is loaded.
google.visualization.ChartWrapper(); // defines chart type, creates data table.
myDashboard.bind(); // binds the slider and line chart.
myDashboard.draw(myData); //draw our chart.
5.
6. Scraping data from webpages
oA strategy has to follow certain steps:
Use historical data to find out some trends in the market and to make certain formulas. (By
intuition we know that the profits and the loss have equal probabilities of 50%. So a strategy aims to maximize the profits or win rate.)
Test the strategy on daily basis over last 15 days.
Go for live trading.
o On monthly basis: to make strategies. (From google Finance)
oOn daily basis: to test and train the strategies.(From NSE-INDIA)
o Minute by minute data(real time data): for the live trade.
7. Example of spider in python
class MySpider(BaseSpider):
name = “spider_name"
allowed_domains = ["www.example.com"]
start_urls = [url1,url2,url3……]
def parse(self, response):
item = SpiderItems() //defines items.
c_path = response.xpath("//div/table/tr")
item[“data1"] = c_path.xpath(“./td[0]/text()”)
item[“data2”] = c_path.xpath(“./td[1]/text()”)
item[“data3”] = c_path.xpath(“./td[2]/text()”)
return item
8. Strategies
Implemented a couple of strategies like ACD strategy, RSI strategy etc.
ACD Strategy: from the book “The Logical Trader: Applying a Method to the Madness” by Fisher, Mark B.
Different terms and what they mean:
Opening Range: max and min of closing price over 1st 20 minutes after 9:16 am.
ATR: Average True Rate : measure of volatility
Triggers A, B, C , D and profit booking.
Strategy:
Wait for 20 minutes after opening the market and watch the trend.
Min and max of closing price during this period will be opening range.
A = OR_up + 10-15% of ATR, B = OR, C = 1.5 times A.
9.
10. Optimization: Maximizing win-rate
Optimize over a range of values of A, C and profit booking.
Different stock has different set of A, C and profit booking.
For SUNPHARMA these are:
ATR = 25.1
A = 2.5 points above opening range
C = 3.75 points below opening range
B = generally lower of opening range
D = generally above of opening range
Profit booking = 8.33 points above A
11. Program in python
Historical Data to
calculate ATR
One minute data to
generate signals
Training and testing
Optimization
API to do Live
Trade
Buy/sell signals