Professional Documents
Culture Documents
A PROJECT REPORT ON
1
Modern Education Society’s College of Engineering,Pune-01
CERTIFICATE
Dr.(Mr.) G.Pole
Internal Guide
Dept. of Computer Engg.
2
Abstract
We examine algorithmic trades (AT) and their role in the price discovery process in
the S&P500 index and EUR/USD currency pair. AT liquidity demand represents 52%
of volume and AT supplies liquidity on 50% of volume. AT acts strategically by
monitoring the market for liquidity and deviations of price from fundamental value.
AT consume liquidity when it is cheap and supplies liquidity when it is expensive.
AT contribute more to the efficient price by placing more efficient quotes and AT
demands liquidity to move the prices towards the efficient price. In electronic
financial markets, algorithmic trading refers to the use of computer programs to
automate one or more stages of the trading process: pre-trade analysis (data
analysis), trading signal generation (buy and sell recommendations), and trade
execution. Trade execution is further divided into agency/broker execution (when a
system optimizes the execution of a trade on behalf of a client) and
principal/proprietary trading (where an institution trades on its own account). Each
stage of this trading process can be conducted by humans, by humans and
algorithms, or fully by algorithms.
In this research paper we will discuss about Algorithmic Trading and trading
strategies with Quantconnect platform, to create intelligent trading algorithms as
well as back testing them to see how they would perform on historical data. The set
of trading algorithms example includes strategies and how would it be helpful for
all the others and how we can utilize these strategies in real live trading to make
profit and most important to understand the market data.
Gaurav Narayane
Omkar Bhalerao
Prassana Bhadange
(B.E. Computer Engg.)
2 Literature Survey 5
2.1 Review of Conference/Journal Papers supporting Project
idea . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6
3
CONTENTS
4 System Design 20
4.1 System Architecture . . . . . . . . . . . . . . . . . . . 21
4.2 Data Flow Diagram . . . . . . . . . . . . . . . . . . . 21
4.3 UML Diagrams . . . . . . . . . . . . . . . . . . . . . . 23
4.3.1 Use Case Diagram . . . . . . . . . . . . . . . . 23
4.3.2 Class Diagram . . . . . . . . . . . . . . . . . . 24
4.3.3 Sequence Diagram . . . . . . . . . . . . . . . . 24
5 Project Plan 27
5.1 Project Estimates . . . . . . . . . . . . . . . . . . . . 28
5.1.1 Reconciled Estimates . . . . . . . . . . . . . . 28
5.2 Risk Management w.r.t NP Hard analysis . . . . . . 28
5.2.1 Risk Identification . . . . . . . . . . . . . . . . 29
5.2.2 Risk Analysis . . . . . . . . . . . . . . . . . . . 30
5.3 Project Schedule . . . . . . . . . . . . . . . . . . . . . 31
5.3.1 Estimation Diagram . . . . . . . . . . . . . . . 31
5.3.2 Project task set . . . . . . . . . . . . . . . . . 31
5.4 Team Organization . . . . . . . . . . . . . . . . . . . . 32
6 Project Implementation 33
6.1 Overview of Project Modules . . . . . . . . . . . . . 34
6.1.1 Dataset Filtration Module . . . . . . . . . . . 34
6.1.2 Neural Network Module . . . . . . . . . . . . 34
6.1.3 Frontend Module . . . . . . . . . . . . . . . . 35
6.1.4 Integration Module . . . . . . . . . . . . . . . 35
6.2 Tools and Technologies Used . . . . . . . . . . . . . . 36
6.3 Algorithm Details . . . . . . . . . . . . . . . . . . . . 37
6.3.1 InceptionV3 . . . . . . . . . . . . . . . . . . . 37
6.3.2 BLEU Score . . . . . . . . . . . . . . . . . . . 38
6.3.3 Deep Learning Model . . . . . . . . . . . . . . 39
6.3.4 Beam Search . . . . . . . . . . . . . . . . . . . 40
7 Software Testing 42
7.1 Types of Tests Performed . . . . . . . . . . . . . . . . 43
7.1.1 Unit Testing . . . . . . . . . . . . . . . . . . . 43
7.1.2 Integration Testing . . . . . . . . . . . . . . . 43
7.1.3 Stress Testing . . . . . . . . . . . . . . . . . . 43
7.1.4 GUI Testing . . . . . . . . . . . . . . . . . . . 44
7.1.5 Model Performance Testing . . . . . . . . . . 44
7.1.6 Regression Testing . . . . . . . . . . . . . . . 44
7.1.7 Compatibility Testing . . . . . . . . . . . . . . 44
8 Results 46
8.0.1 Training Epochs . . . . . . . . . . . . . . . . . 47
8.0.2 Loss vs Epoch Graph . . . . . . . . . . . . . . 47
8.0.3 Accuracy . . . . . . . . . . . . . . . . . . . . . 48
8.1 Screenshots . . . . . . . . . . . . . . . . . . . . . . . . 48
9 Other Specifications 50
9.1 Advantages . . . . . . . . . . . . . . . . . . . . . . . . 51
9.2 Limitations . . . . . . . . . . . . . . . . . . . . . . . . 51
10 Conclusions 52
10.1 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . 53
10.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . 53
10.3 Applications . . . . . . . . . . . . . . . . . . . . . . . . 54
11 References 55
C Plagiarism Report 67
6.1 Inception V3 . . . . . . . . . . . . . . . . . . . . . . . 38
6.2 Bleu Score Formula . . . . . . . . . . . . . . . . . . . 39
6.3 Model Architecture . . . . . . . . . . . . . . . . . . . 40
8
LIST OF FIGURES
Introduction
1
CHAPTER 1. INTRODUCTION
Technology has revolutionized the way financial markets function and the way
financial assets are traded. Two significant interrelated technological changes are
investors using computers to automate their trading processes and markets
reorganizing themselves so virtually all markets are now electronic limit order books
(Jain (2005)). The speed and quality of access to such markets encourage the use of
algorithmic trading (AT; AT denotes algorithmic traders as well), commonly defined
as the use of computer algorithms to automatically make trading decisions, submit
orders, and manage those orders after submission. Because the trading process is
central to efficient risk-sharing and price efficiency it is important to understand how
AT is used and its role in the price formation process. We examine these issues for
S&P 500 stocks & Euro/USD pairs and also in the Indian stock market with data to
identify whether or not each trade’s buyer and seller generated their order with an
algorithm and also back test the stratergies
1.5 Motivation
Due to the increase of traders in the financial market algo trading is
becoming more and more popular. Algorithmic trading makes use of
complex formulas, combined with mathematical models and human
oversight, to make decisions to buy or sell financial securities on an exchange.
Algorithmic traders often make use of high-frequency trading technology,
which can enable a firm to make tens of thousands of trades per second.
Hence It is a challenging task to study the market data and
classify and organize it in a way that allows the (AT) to use and
execute trade .The question is how to create a high performing
system that is user friendly to every retail trader .
Literature Survey
5
CHAPTER 2. LITERATURE SURVEY
Software Requirement
Specification
9
CHAPTER 3. SOFTWARE REQUIREMENT SPECIFICATION
3.1 Introduction
The software assumes that the structure of received data through FIX protocol is
certain. Besides, the software should have capable of handling each received data
without missing. Poor performance of the dependency systems such as hardware or
software systems of computers could impact the performance of the proposed
algorithmic trading system. A non-exhaustive list of dependencies is shown below.
Risk management systems
Order management systems
Telecommunications networks and ISP’s
Accounting system
1. USER FUNCTIONS
1.1 LOGIN TO SYSTEM
When a user starts the application, he/she sees the login screen first. The user is
expected to enter a username and password. Login is completed if the username
and password are matched with the ones in the database.
Stimulus/Response Sequence
Functional Requirement
2. Priority - High
Stimulus/Response Sequence
Functional Requirement
3.2.3 Frontend
2. Priority - High
Stimulus/Response Sequence
1. Stimulus - API
Functional Requirement
1. Creating a User Interface to Interact with the API and the Model , with
Upload Image Functionality and Display Caption for the Uploaded
Image.
Algorithm operates independently from the platform and any other program, the
software has only a system interface with the operating system which is connected
invisibly by means of Python and Python Libraries.
3.3.1 User Interfaces
and give the desired caption output which will be passed back to the
frontend. The Frontend will now display the output received from the
backend in a visually formatted manner.
Algorithm and its all subsystems are desktop base applications; therefore, the
software is expected to operate in Windows 7 and upper versions (Windows
8 and 8.1) of Microsoft Windows operating system initially. After completing
the Microsoft Windows version, the software will be integrated into Linux
Ubuntu 12.04 LTS and upper versions of Ubuntu and Mac OS X 10.8 and
upper versions of Mac OS. The source code is aimed to have a single copy to
operate on all targeted operating systems and their versions. If this is not
possible, this aim will be to get closer by the least modifications on source
code versions running different operating systems. Python 3.6, TensorFlow
2.0, QuantConnect.
MESCOE, Department of Computer Engineering 2021-22 16
CHAPTER 3. SOFTWARE REQUIREMENT SPECIFICATION
3.1.4 Modifiability
Business logic for trading strategies must be modifiable. Maximizing the ease
with which new algorithmic trading strategies can be added to the system
represents a competitive advantage. The processors interpret whatever
strategy they are presented and analyze the data they received according to
that strategy.
below:-
System
Design
20
CHAPTER 4. SYSTEM DESIGN
Project Plan
27
CHAPTER 5. PROJECT PLAN
Time Estimates
2 hrs/day for approx. 3 months
about the tools which we are using to develop the software. Each
team member is equally involved in the development of project
in each stage. The number of peoples required for developing are
sufficient. The requirement gathered is constant or stable which
minimizes the risk of developing an inaccurate system.
The risks for the Project can be analyzed within the constraints of
time and quality. Software Risk analysis a very important aspect
of risk management. In this phase the risk is identified and then
categorized. After the categorization of risk, the level, likelihood
(percentage) and impact of the risk is analyzed. Likelihood is de-
fined in percentage after exa mining what are the chances of risk to
occur due to various technical conditions.
• Task 4: Implementation
Project Implementation
33
CHAPTER 6. PROJECT IMPLEMENTATION
6.1.2 QuantConnect
1) Result Processing
Handle all messages from the algorithmic trading engine. Decide what should be sent,
and where the messages should go. The result processing system can send messages to
a local GUI, or the web interface.
2) Datafeed Sourcing
Connect and download the data required for the algorithmic trading engine. For
backtesting this sources files from the disk, for live trading, it connects to a stream and
generates the data objects.
3)Transaction Processing
Process new order requests; either using the fill models provided by the algorithm or
with an actual brokerage. Send the processed orders back to the algorithm's portfolio to
be filled.
The live result page shows your algorithm live trading performance. Reviewing result
page lets us know how our algorithm has performed and can investigate to improve its
performamce
The live results page automatically displays when you deploy a live algorithm. The
page presents the algorithm's equity curve, holdings, trades, logs, server statistics, and
much more information.
Equity The total portfolio value if all of the holdings were sold
at current market rates.
Fees The total quantity of fees paid for all the transactions.
Net Profit The dollar-value return across the entire trading period.
#region imports
from AlgorithmImports import *
#endregion
from System.Drawing import Color
class ForexBollingerBandBot(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2015, 1, 1)
self.SetEndDate(2022, 1, 1)
self.SetCash(100000)
self.pair = self.AddForex("EURUSD", Resolution.Daily,
Market.Oanda).Symbol
self.bb = self.BB(self.pair, 20, 2)
price = data[self.pair].Price
MESCOE, Department of Computer Engineering 2021-22 41
CHAPTER 6. PROJECT IMPLEMENTATION
if not self.Portfolio.Invested:
if self.bb.LowerBand.Current.Value > price:
self.SetHoldings(self.pair, 1)
self.Plot("Trade Plot", "Buy", price)
elif self.bb.UpperBand.Current.Value < price:
self.SetHoldings(self.pair, -1)
self.Plot("Trade Plot", "Sell", price)
else:
if self.Portfolio[self.pair].IsLong:
if self.bb.MiddleBand.Current.Value < price:
self.Liquidate()
self.Plot("Trade Plot", "Liquidate", price)
elif self.bb.MiddleBand.Current.Value > price:
self.Liquidate()
self.Plot("Trade Plot", "Liquidate", price)
6.5.2 Backtesting
#region imports
from AlgorithmImports import *
#endregion
import numpy as np
class SimpleBreakoutExample(QCAlgorithm):
def Initialize(self):
# Set the cash for backtest
self.SetCash(100000)
# Add asset
self.symbol = self.AddEquity("SPY", Resolution.Daily).Symbol
self.TimeRules.AfterMarketOpen(self.symbol, 20), \
Action(self.EveryMarketOpen))
def EveryMarketOpen(self):
# Dynamically determine lookback length based on 30 day volatility change
rate
close = self.History(self.symbol, 31, Resolution.Daily)["close"]
todayvol = np.std(close[1:31])
yesterdayvol = np.std(close[0:30])
deltavol = (todayvol - yesterdayvol) / todayvol
self.lookback = round(self.lookback * (1 + deltavol))
# Check if the asset's price is higher than highestPrice & trailing stop price
not below initial stop price
if self.Securities[self.symbol].Close > self.highestPrice and \
self.initialStopRisk * self.breakoutlvl <
self.Securities[self.symbol].Close * self.trailingStopRisk:
# Save the new high to highestPrice
self.highestPrice = self.Securities[self.symbol].Close
# Update the stop price
updateFields = UpdateOrderFields()
updateFields.StopPrice = self.Securities[self.symbol].Close *
self.trailingStopRisk
self.stopMarketTicket.Update(updateFields)
Software Testing
42
CHAPTER 7. SOFTWARE TESTING
– Unit Testing
– Integration Testing
– Stress Testing
– GUI Testing
– Performance Testing
– Regression Testing
– Compatibility Testing
vice is determined.
Serial
Test Input Expected Output Pass/Fail
No.
Quantconnect interface will
Login into appear
1 Pass
quantconnet account
Results
46
CHAPTER 8. RESULTS
8.0.3 Accuracy
8.1 Screenshots
Other Specifications
50
CHAPTER 9. OTHER SPECIFICATIONS
9.1 Advantages
9.2 Limitations
Conclusions
52
CHAPTER 10. CONCLUSIONS
10.1 Conclusions
The faster one receives the data the faster one can make a decision. The volume of
data available from all markets is continuously increasing hence it is important to
analyze the data. For example, major exchanges were not able to handle and the
information flow with the rise in transactions carried out by automated systems on
the electronic market over the past few years. Automation is everywhere, from
booking travel tickets to self-driven vehicles, drones delivering the food and the
financial sector is not an exception here. Development of Technology provides an
edge people becoming more and more educated, more and more automation &
tools
will continue to come as better solutions for better pricing not just for large
companies, but also for retail investors. Algorithmic Trading is a method of buying
and selling back securities on a predetermined collection of rules. For backtesting,
the said rules are subject to historical data. Algo trading is associated with many
names such as automated trading, Black box trading. The approach is based on
analyzing different market conditions from which it can generate profits. Then
applying these particular strategies corresponding to a particular situation,
automate, and manage the trade. The overall benefit is that you do not need to keep
an eye on the market. Thus creating the profits out of rising or fall in the market
while reducing the volatility of the overall portfolio at the same time. The program
makes all-important work such as searching, timing, and trading for the user
mechanically. It also removes the biasness, as no humans are involved and faster
than manual trading.
10.3 Applications
References
55
CHAPTER 11. REFERENCES
[1] IEEE. IEEE STD 830-1998 IEEE Recommended Practice for Software
Requirements Specifications. IEEE Computer Society, 1998
[2] Hull, J. (2009). Options, futures, and other derivatives; seventh edition (7th
edition). Upper Saddle River, N.J.: Prentice Hall
[3] Using Genetic Algorithms To Forecast Financial Markets. (n.d.). Retrieved
November 30, 2014, from http://www.investopedia.com/articles/financial-
theory/11/using-genetic-algorithms-forecast-financial-markets.asp
[4] Binary option. (2014, November 29). Retrieved November 30, 2014, from
http://en.wikipedia.org/wiki/Binary_option
[5] FIX Trading Community. (n.d.). Retrieved November 30, 2014, from
http://www.fixtradingcommunity.org/
[6] Bond option. (2014, November 29). Retrieved November 30, 2014, from
http://en.wikipedia.org/wiki/Bond_option
[8] Agile and Scalable. (n.d.). Retrieved November 30, 2014, from
http://www.mongodb.org/
[9] FIX Protokolü Sıkça Sorulan Sorular. (2014, November 30). Retrieved
[14] FIX Protokolü Sıkça Sorulan Sorular. (2014, November 30). Retrieved
November
[15] https://www.kundankishore.in/blog/what-is-the-future-
of-algorithmic-trading
[21] https://en.wikipedia.org/w/index.php?
search=&title=Special%3ASearch&go=Go
[22] https://therobusttrader.com/pros-and-cons-of-algo-trading/
Problem Statement
Feasibility Assessment
61