SlideShare a Scribd company logo
1 of 12
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
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.
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.
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.
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.
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
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.
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
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
Thank You

More Related Content

Similar to Programming for Financial Strategies

Simplify Feature Engineering in Your Data Warehouse
Simplify Feature Engineering in Your Data WarehouseSimplify Feature Engineering in Your Data Warehouse
Simplify Feature Engineering in Your Data WarehouseFeatureByte
 
Relevance trilogy may dream be with you! (dec17)
Relevance trilogy  may dream be with you! (dec17)Relevance trilogy  may dream be with you! (dec17)
Relevance trilogy may dream be with you! (dec17)Woonsan Ko
 
Yufeng Guo | Coding the 7 steps of machine learning | Codemotion Madrid 2018
Yufeng Guo |  Coding the 7 steps of machine learning | Codemotion Madrid 2018 Yufeng Guo |  Coding the 7 steps of machine learning | Codemotion Madrid 2018
Yufeng Guo | Coding the 7 steps of machine learning | Codemotion Madrid 2018 Codemotion
 
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...IRJET Journal
 
Aprendizaje reforzado con swift
Aprendizaje reforzado con swiftAprendizaje reforzado con swift
Aprendizaje reforzado con swiftNSCoder Mexico
 
Introduction to R ajay Ohri
Introduction to R ajay OhriIntroduction to R ajay Ohri
Introduction to R ajay OhriAjay Ohri
 
Data visualization in python/Django
Data visualization in python/DjangoData visualization in python/Django
Data visualization in python/Djangokenluck2001
 
Data Science in the Elastic Stack
Data Science in the Elastic StackData Science in the Elastic Stack
Data Science in the Elastic StackRochelle Sonnenberg
 
"Lessons learned using Apache Spark for self-service data prep in SaaS world"
"Lessons learned using Apache Spark for self-service data prep in SaaS world""Lessons learned using Apache Spark for self-service data prep in SaaS world"
"Lessons learned using Apache Spark for self-service data prep in SaaS world"Pavel Hardak
 
Lessons Learned Using Apache Spark for Self-Service Data Prep in SaaS World
Lessons Learned Using Apache Spark for Self-Service Data Prep in SaaS WorldLessons Learned Using Apache Spark for Self-Service Data Prep in SaaS World
Lessons Learned Using Apache Spark for Self-Service Data Prep in SaaS WorldDatabricks
 
Introduction to R
Introduction to RIntroduction to R
Introduction to RAjay Ohri
 
Opportunity Analysis with Kratu
Opportunity Analysis with KratuOpportunity Analysis with Kratu
Opportunity Analysis with Kratumarcwan
 
Building Deep Reinforcement Learning Applications on Apache Spark with Analyt...
Building Deep Reinforcement Learning Applications on Apache Spark with Analyt...Building Deep Reinforcement Learning Applications on Apache Spark with Analyt...
Building Deep Reinforcement Learning Applications on Apache Spark with Analyt...Databricks
 
Towards a Unified Data Analytics Optimizer with Yanlei Diao
Towards a Unified Data Analytics Optimizer with Yanlei DiaoTowards a Unified Data Analytics Optimizer with Yanlei Diao
Towards a Unified Data Analytics Optimizer with Yanlei DiaoDatabricks
 
Analytics Zoo: Building Analytics and AI Pipeline for Apache Spark and BigDL ...
Analytics Zoo: Building Analytics and AI Pipeline for Apache Spark and BigDL ...Analytics Zoo: Building Analytics and AI Pipeline for Apache Spark and BigDL ...
Analytics Zoo: Building Analytics and AI Pipeline for Apache Spark and BigDL ...Databricks
 
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...Chetan Khatri
 
Building a custom machine learning model on android
Building a custom machine learning model on androidBuilding a custom machine learning model on android
Building a custom machine learning model on androidIsabel Palomar
 

Similar to Programming for Financial Strategies (20)

Simplify Feature Engineering in Your Data Warehouse
Simplify Feature Engineering in Your Data WarehouseSimplify Feature Engineering in Your Data Warehouse
Simplify Feature Engineering in Your Data Warehouse
 
Relevance trilogy may dream be with you! (dec17)
Relevance trilogy  may dream be with you! (dec17)Relevance trilogy  may dream be with you! (dec17)
Relevance trilogy may dream be with you! (dec17)
 
Cómo usar google analytics
Cómo usar google analyticsCómo usar google analytics
Cómo usar google analytics
 
Yufeng Guo | Coding the 7 steps of machine learning | Codemotion Madrid 2018
Yufeng Guo |  Coding the 7 steps of machine learning | Codemotion Madrid 2018 Yufeng Guo |  Coding the 7 steps of machine learning | Codemotion Madrid 2018
Yufeng Guo | Coding the 7 steps of machine learning | Codemotion Madrid 2018
 
Asgh
AsghAsgh
Asgh
 
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...
 
Aprendizaje reforzado con swift
Aprendizaje reforzado con swiftAprendizaje reforzado con swift
Aprendizaje reforzado con swift
 
Introduction to R ajay Ohri
Introduction to R ajay OhriIntroduction to R ajay Ohri
Introduction to R ajay Ohri
 
Data visualization in python/Django
Data visualization in python/DjangoData visualization in python/Django
Data visualization in python/Django
 
Data Science in the Elastic Stack
Data Science in the Elastic StackData Science in the Elastic Stack
Data Science in the Elastic Stack
 
"Lessons learned using Apache Spark for self-service data prep in SaaS world"
"Lessons learned using Apache Spark for self-service data prep in SaaS world""Lessons learned using Apache Spark for self-service data prep in SaaS world"
"Lessons learned using Apache Spark for self-service data prep in SaaS world"
 
Lessons Learned Using Apache Spark for Self-Service Data Prep in SaaS World
Lessons Learned Using Apache Spark for Self-Service Data Prep in SaaS WorldLessons Learned Using Apache Spark for Self-Service Data Prep in SaaS World
Lessons Learned Using Apache Spark for Self-Service Data Prep in SaaS World
 
Introduction to R
Introduction to RIntroduction to R
Introduction to R
 
Opportunity Analysis with Kratu
Opportunity Analysis with KratuOpportunity Analysis with Kratu
Opportunity Analysis with Kratu
 
Building Deep Reinforcement Learning Applications on Apache Spark with Analyt...
Building Deep Reinforcement Learning Applications on Apache Spark with Analyt...Building Deep Reinforcement Learning Applications on Apache Spark with Analyt...
Building Deep Reinforcement Learning Applications on Apache Spark with Analyt...
 
Towards a Unified Data Analytics Optimizer with Yanlei Diao
Towards a Unified Data Analytics Optimizer with Yanlei DiaoTowards a Unified Data Analytics Optimizer with Yanlei Diao
Towards a Unified Data Analytics Optimizer with Yanlei Diao
 
Analytics Zoo: Building Analytics and AI Pipeline for Apache Spark and BigDL ...
Analytics Zoo: Building Analytics and AI Pipeline for Apache Spark and BigDL ...Analytics Zoo: Building Analytics and AI Pipeline for Apache Spark and BigDL ...
Analytics Zoo: Building Analytics and AI Pipeline for Apache Spark and BigDL ...
 
Sumit-ResumeWithPic
Sumit-ResumeWithPicSumit-ResumeWithPic
Sumit-ResumeWithPic
 
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
 
Building a custom machine learning model on android
Building a custom machine learning model on androidBuilding a custom machine learning model on android
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