Stock Trading Language [S.T.L.] Rui Hu Thomas Lippincott

Stock Trading Language
[S.T.L.]
Rui Hu
Thomas Lippincott
Rekha Duthulur
Matt (Yu-Ming) Chang
Nikhil Jhawar
Birth of S.T.L.






Wanted to develop a language for non-techies who do not know how to program.
English language considered to be the easiest way to introduce programming to one and all,
but…
English with its vast grammar and millions of different permutations and combination of words
in its domain would require a great deal of time and effort for any language to parse and make
sense of it.
Hence, we decided to restrict our easy-to-program language to a particular domain to be able to
capture the essence of our idea and still generate a language capable of dealing with nonprogrammers.
The domain was chosen to be as the one belonging to the financial industry, more specifically
Stock Trading
Intended users – day to day retail traders looking to bring some automation into their dealing
with the stock market.
Language Definition

STL is an interpreted computer language
designed to facilitate the rapid
prototyping
of
stock
trading
strategies. The language is mainly aimed
at individuals in the financial industry,
with little or no formal background in
computer science.
Language Highlights




Goal: The goal of the Stock Trading Language is to enable a stock trader to write code to trade
in the stock market to automate his buying/selling requirements.
Ease of use: The language is user friendly in the sense that traders can write simple buy/sell
codes using simple words which they use in their financial dialect.
Portability: The language is also very portable as the user written code is converted into java
code thus enabling it to be compatible with any machine running the Java Virtual Machine.
Automation: The language brings about automation for a trader who would have to otherwise
sit in front of the computer for the whole time of the trading session.
Implementation – Responsibilities





Tom – Lead Tester, GUI, JFL Interfacing
Nikhil – Project Management, Testing,
Documentation
Rekha – Interpreter, walker, AST
Rui – Lexer, Parser
Matt – Interpreter, walker, AST
Implementation - Architecture
The
G.U.I. - Input
Source
Code
Lexer
Parser
Exception
Walker
Symbol Table
Interpreter
Stock Source
The G.U.I. Output
Java Financial
Library 1.6.1
Implementation - Schedule
Date Completed
Task
31 January,2007
First Team Project Meeting
02 February,2007
Stock Trading Language Evolves
07 February,2007
White Paper completed
11 February,2007
Code conventions formed
14 February,2007
Lexer started
18 February,2007
Parser started
21 February,2007
Walker started
01 March,2007
Interpreter over Compiler chosen
05 March,2007
Language Reference Manual completed
20 March,2007
Graphical User Interface started, Lexer/Parser Completed.
25 March,2007
Testing of Java and STL code started
April 5,2007
Bugzilla (for error reporting) implemented
April 19,2007
Simple demo with TA
April 26,2007
Walker finalized
April 29,2007
Graphical User Interface completed
May 5,2007
Testing of STL functionality completed
May 6,2007
Final project completed
May 7,2007
Project presented
Chose interpreter
over compiler
Implemented grammar
early
Examples – Conditional buy
$i=money(10000);
$j=value("MSFT");
$max=400;
if($j<$max){
buy(50,"MSFT");
$k=stocks("MSFT");
print("You currently own ");
print($k);
print(" stocks of Microsoft");
print("\n");
}
else{
print("Stock too costly...");
}
$l=stocks("MSFT");
sell(20,"MSFT");
$j=stocks("MSFT");
print("After selling You currently own ");
print($j);
print(" stocks of Microsoft");
//Set the amount of money you have
//Assign currently traded value of Microsoft to a variable
//Set acceptable price limit on a stock
//If the price is favorable buy 50 stocks of Microsoft else error out
//assign the number of stocks of Microsoft currently owned to a variable
//sell 20 shares of Microsoft from your current portfolio
//reassign the no. of stocks of Microsoft currently owned to a variable
Examples - Delta
/* Program which allows traders to buy stocks based on their volatility */
$i=money(1000);//Set money for transactions
//Choose your portfolio
/*Go through the list and buy only stocks which have
variance that is acceptable*/
foreach %read(@portfolio){
@portfolio=["IBM","GOOG","YHOO","CECO","MSFT"];
print("Delta Values\n");
print("-------------------------\n");
if(delta(%read)<0.5){
buy(10,%read);
print(%read);
print(" bought\n");
}
//Prints out the delta values of each stock in your portfolio
foreach %iterate(@portfolio){
print(%iterate);
print(": ");
print(delta(%iterate));
print("\n");
}
$k = 0.5;//Set acceptable variance
print("Stocks bought...\n");
print("-----------------\n");
else{
//Else do not buy
print(%read);
print(" too volatile to buy\n");
}
}
Example - Recursion
function $gcd($x,$y){
if($y<=0){
return($x);
}
else{
while($x >= $y){
$x = $x - $y;
}
return($gcd($y,$x));
}
}
print($gcd(33,9));
print("\n");
The GUI
Clear input screen
Run all tests
Open code from a file
Money you
have
Portfolio
Manager
Lessons learnt - general





Starting early does not hurt
Set realistic goals in terms of envisioning the
project and allocating time for the various
components that go into building a project
Team mates should get to know each other well for
optimal results
Good communications an absolute MUST
Work together at least once every week if not more
Lessons learnt - technical





Divide project components properly based on
strength and weaknesses of team members
A fixed LRM and Grammar go and long way in
stabilizing the project development cycle
Realize, what will be more appropriate for the
project – an interpreter or a compiler
Perform tests on every module as it is developed
Scoping is difficult to implement, so allocate
enough time to get it working
DEMO TIME!