Algorithmic Trading G Hernndez Ing Sistemas y Computacin











![Robert Brown [botanist] (1773 -1858) 1827 Observed motion of pollen particles executing a continuous Robert Brown [botanist] (1773 -1858) 1827 Observed motion of pollen particles executing a continuous](https://slidetodoc.com/presentation_image/57abbf99c34bf4b260c0a734017a7079/image-12.jpg)



![Paul Samuelson [Math Econ] (1915 -2009). Paul Samuelson [Math Econ] (1915 -2009).](https://slidetodoc.com/presentation_image/57abbf99c34bf4b260c0a734017a7079/image-16.jpg)



























































































- Slides: 107
Algorithmic Trading G. Hernández Ing. Sistemas y Computación Oct 26 -27 2018
Outline 1. Financial Markets and Financial Mathematics Evolution 2. Financial Markets and Products 3. Fintech 4. The Crowdsourced Hedge Funds Revolution 5. Machine Learning 6. Machine Learning for Trading
1. Financial Markets and Financial Mathematics Evolution “Form trading floors populated by loud, intuitive and emotional humans to virtual venues populated by quiet, dispassionate, very fast and intelligent trading boots”
Thales of Miletus (624 - 547 BC) Book 1 (part XI) by Aristotle: “Pay a deposit to use the olive-presses in Chios and Miletus (option)”
Leonardo Pisano Bigollo (1170 e 1250) Liber Abaci (The Book of Calculations) Introduced Hindue- Arabic numbers to Europe “Goetzmann (2004) argues that he calculated the present value of alternative cash flows in addition to developing a general method for expressing investment returns”
Financial Markets: middle ages A 14 th century manuscript depicting bankers in an Italian counting house. Miniature, Genoa 1340. Wikiwand - History_of_banking
• Venice Real Merchants market started trading government debt issues in the middle of the 13 th century. • In 1531, the Belgian "bourse" of Antwerp started trading “stocks”, in 1900 Amsterdam. • In 1571, officially opened by Queen Elizabeth I, The Royal Exchange was modeled after the Antwerp Exchange. • In 1602 the Dutch East India Company (VOC) first “stocks (bonds)”.
Financial Markets and Communication Technologies: Pigeons In 1815, the combined forces of Britain and Prussia defeated Napoleon’s army at the Battle of Waterloo. It was, said the Duke of Wellington, a damn close run thing. But even before the dust had settled on the battlefield, a carrier pigeon belonging to the House of Rothschild was on its way across the Channel to London. Nathan Rothschild, informed ahead of other traders that the country was not to be over-run by the French, consequently made a killing by buying British government bonds. Little of this legend is true but there are elements that are accurate. https: //www. ft. com/content/255 b 75 e 0 -c 77 d-11 e 2 -be 27 -00144 feab 7 de? mhq 5 j=e 3
Probability and Financial Mathematics Girolamo Cardano (1501 -1576) ’Liber de Ludo Aleae’ (’Book on Games of Chance’) 1564 The ethics of gambling “First discussion of the idea of mathematical probability (fair dice, gambling). ”
Early development of probability theory driven by considering gambling problems
Robert Brown [botanist] (1773 -1858) 1827 Observed motion of pollen particles executing a continuous jittery motion.
Brownian Motion (BM). The earliest attempts to model BM mathematically can be traced to three sources, each of which knew nothing about the others:
Models of Brownian Motion
Norbert Wiener (1894 -1964) Rigorous mathematical construction of Brownian motion and its “derivative” d. W the Wiener process. Andrey Kolmogorov (1903 -1987) 1933 Identified probability with measure theory, introducing the notion of probability as a measure on a collection of events not necessarily based on the frequency of events. Kiyosi Itô (1915 -2008) 1940 Develops stochastic calculus
Paul Samuelson [Math Econ] (1915 -2009).
Robert Merton (1944 -) 1969 Introduces stochastic calculus in finance to explain the price of financial products Fischer Black (1938 – 1995) Myron Scholes (1941 -) 1973 Black–Scholes–Merton option model and the Black–Scholes formula.
Financial Markets 20 th Century A stock brokerage in the 1920 s. The differences between the 1920 s stock market and today's
The New York stock exchange trading floor in September 1963, before the introduction of electronic readouts and computer screens. Wikipedia – Open outcry
Exchanges – trading floors – pits open outcry http: //www. visualcapitalist. com/20 -largest-stock-exchanges-world/
Financial Markets and Communication Technologies: Telegraph, Telephone, Satellite Communications, Networks, Internet
Electronic trading Electronic Communication Network (ECN) 1971 electronic bulletin board 1987 October crash – Telephones did not answer - Small Order Execution System (SOES) an electronic method for dealers to enter their trades
Bloomberg 1981 100, 000 th installed in 1998 http: //www. businessinsider. com/how-billionaire-michael-bloomberg-made-and-spends-his-fortune-2015 -7
Technical indicators Price Volume News
Until 2009, many trades on the floor of the New York Stock Exchange used computer but still involved a face-to-face interaction. Wikipedia – Open outcry
Robots
Planning Algorithms / Motion Planning http: //www. coppeliarobotics. com/help. File s/en/motion. Planning. Module. htm http: //msl. cs. illinois. edu/~lavalle/books. html http: //users. cis. fiu. edu/~jabobadi http: //www. societyofrobots. com/robot_arm_tutorial. shtml
Planning Algorithms / Motion Planning http: //www. willowgarage. com/pages/research/motion-planning
Bots n A "software robot device" or software agent. ¨ Especially an intelligent agent https: //en. wikipedia. org/wiki/Bot n Informal a robot. A computer program that works automatically, especially one that searches for and finds information on the internet. http: //dictionary. cambridge. org/us/dictionary/english/bot n (Chiefly in science fiction) a robot. An autonomous program on a network (especially the Internet) which can interact with systems or users. https: //en. oxforddictionaries. com/definition/bot n Simple computer program used to perform highly repetitive operations, e. g. trawling websites to collect email addresses. http: //www. urbandictionary. com/define. php? term=bot
Types of Bots n n Web crawler or Web spider, a computer program that does automated tasks on the web. Internet bot, a computer program that does automated tasks in the internet Chatterbot or Chat bot, a computer program that converses in natural language Social bots ¨ n Twitterbot is a program used to produce automated posts on the Twitter microblogging service Video game bot, a computer-controlled player or opponent. https: //en. wikipedia. org/wiki/Bot ¨ "So you're using an aimbot. . . and he's using an aimbot. . . if you're both going to cheat, why bother to play? “ "Just to show that I cheat better than him. “ http: //www. urbandictionary. com/define. php? term=bot ¨ An aimbot is an very complex peice of programming that, in effect, takes data from your game, and uses that data to lock on the heads of enemy targets. http: //www. urbandictionary. com/define. php? term=Aimbot
Malware Bots and Botnets n Zombie computer, a computer that is part of a botnet. https: //en. wikipedia. org/wiki/Bot n A botnet is a number of Internet-connected devices used by a botnet owner to perform various tasks. Botnets can be used to perform Distributed Denial Of Service Attack, steal data, send spam, and allow the attacker access to the device and its connection. The owner can control the botnet using command control (C&C) software. [1] The word botnet is a combination of the words robot and network. The term is usually used with a negative or malicious connotation. https: //en. wikipedia. org/wiki/Botnet n A "bot" is a type of malware that allows an attacker to take control over an affected computer. Also known as “Web robots”, bots are usually part of a network of infected machines, known as a “botnet”, which is typically made up of victim machines that stretch across the globe. https: //us. norton. com/botnet
Trading Bots http: //sebfor. com/botsethereum-trading/
Market matching and trading bots Market registrar Trading agents Market Making Bots/Algorithms Trading Bots/Algorithms
Robots vs. Trading Bots 1. Sense physical environment to estimate position 2. Rotate an angle Advance a distance 3. If not in target go back to 1. Sense the financial environment – analyze information (historic prices and volumes, public company information, news, twits, . . ) to predict future prices 2. Reconfigure portfolio i. Select stocks to sell / how many? ii. Select stocks to buy /how many? 3. Determine when to go back to 1.
Trading algorithms/bots: online algorithms/agents that place trading orders
Classification Portfolio Configuration Source: A. Arevalo – Based on (Aldridge, 2009; Chan, 2009; Seth, 2015) Sniffing algorithms Model Based Strategies (LF, MF, HF) Discover other algorithms (Adversaries) and beat them. Financial Assets Price Modelling Splitting up large orders (LF -> MF/HF) Predict trend patterns Minimize extra costs Arbitrage Opportunities (HF) Minimize the market impact Operate large orders at best market average price Discover price differentials Obtain free-risk profit Types of Trading Algorithms/Bots Adversarial Depredators Algorithms (LF, MF, HF)
Financial Markets TODAY: Interconnected Virtual Market Venues + Algorithmic (Low, Middle and High Frequency) Trading Bots Follow this link to see G. Calhoun in 'Real Money” explaining high frequency trading
Kevin Slavin: How algorithms shape our world -TED Talk Follow this link to see the talk
Sean Gourley - High frequency trading and the new algorithmic ecosystem - TEDx. New. Wall. Street - Follow this link to see the talk
Digitalization is Extending also in Other Markets
2. Financial Markets and Products “The most efficient mechanisms to channel resources from investors to government and private sector projects, that are needed to foster economic growth”
Financial Markets A financial market can be defined as a system that facilitates trading of financial assets. It has multiple components and actors: • issuers (usually companies or governments); • Intermediaries (usually banks, brokers, market venues and market makers); • investors willing to put capital to work (usually citizens, mutual funds, among others) and • regulators establishing exchange rules and overseeing compliance (usually government agencies, self-governing bodies and international organizations).
Social Function of Financial Markets Financial markets are established in almost any country around the world, because they are considered the most efficient mechanisms to channel resources from investors to government and private sector projects, that are needed to foster economic growth.
http: //crackmba. com/financial-markets/
http: //crackmba. com/financial-markets/
http: //crackmba. com/financial-markets/ http: //www. binarytribune. com/forex-academy/types-of-financial-markets
Stocks = Shares = Equities = “Securities” “Acciones” Shares are units of ownership interest in a corporation or financial asset that provide for an equal distribution in any profits, if any are declared, in the form of dividends. http: //www. investopedia. com/terms/s/shares. asp
Company/Bussiness Valuation
The Value of a Stock P = 15 x E 10 In theory, the value of a stock is a prediction of a company’s future earnings and dividends. Although earnings may be hard to predict, you can look at what a company has made in the recent past (Shiller’s formula uses the past ten years of earnings) and compare it with the value of the stock. This calculation —known as the P/E 10 or price-to-earnings ratio—has gravitated toward a value of about 15 over the long run, meaning that the market price per share is generally about fifteen times larger than a company’s annual profits. There are exceptions in individual stocks, and sometimes they are justified. A company in an emerging industry (say, Facebook) might reasonably expect to make more in future years than in past ones. It therefore deserves a higher P/E ratio than a company in a declining industry (say, Blockbuster Video).
The money making motto in all markets Whatever the method, the money making motto is “Buy low, sell high!” In practice, it’s much harder to do than it sounds. Phynance, Zura. Kakushadze, 2014 https: //arxiv. org/abs/1405. 1948.
Long position
In financial assets the money making motto is extended because you can also “Sell high, buy low!” .
Trading with only one asset/stock Zar de la Papa en Corabastos Marco Antonio Gil Garzón http: //www. eltiempo. com/archivo/documento/CMS-3506750
Short position
Stocks = Shares are units of ownership interest in a corporation or financial asset that provide for an equal distribution in any profits, if any are declared, in the form of dividends. http: //www. investopedia. com/terms/s/shares. asp
Predicting the Price of a Stock - Company/Business Valuation
Predicting the Price of a Stock P = 15 x E 10 S = P / # stocks Shiller’s formula Shiller studied the price-to-earnings ratio of large number of companies and concluded that the price (value) P of company, under normal conditions, tends to be 15 times the company’s annual expected earnings E. Shiller’s formula uses the past ten years average of earnings E. 10
Predicting the Value of a Stock “There are exceptions in individual stocks, and sometimes they are justified. A company in an emerging industry (say, Facebook) might reasonably expect to make more in future years than in past ones. It therefore deserves a higher P/E ratio than a company in a declining industry (say, Blockbuster Video)”.
Paul Wilmott Introduces Quantitative Finance Tools. For. Computational. Finance. Seydel. Springe 2006. pdf
3. Fin. Tech - emerging innovative financial services based on technology that are transforming the financial industry -
Fin. Tech • Financial technology (Fin. Tech or fintech) is the new technology and innovation that aims to compete with traditional financial methods in the delivery of financial services. Wikipedia • People use the term “fintech” very differently. Historically it was used to describe technology applied to the middle or back office of banks. Others use it to refer to the innovation that is disrupting traditional financial institutions. I prefer a broad definition: “Fintech is technology that either enables or delivers financial services. ” Ruven. Levy
https: //wso 2. com/library/articles/2017/08/fintech-creating-apis-to-support-the-financial-industry/
Fin. Tech: Electronic money and Cryptocurrencies Before Money
Fin. Tech: Digital Lending (Crowdfunding, P 2 P, Receivables)
Daily Fintech Analysis from a constellation of stars with over 23 k subscribers from 172 countries
https: //www. colombiafintech. co/miembros
4. The Crowdsourced Hedge Funds Revolution “Leveling the financial world playing field allowing anyone in the world with an internet connection to develop trading algorithms (even ML based trading algorithms) and profit form them. ” 4 Crowdsourced Hedge Funds for Algorithmic Trading- Nanalyze
Fin. Tech: Crowd-Sourcing Algorithmic Trading Platforms 4 Crowdsourced Hedge Funds for Algorithmic Trading- Nanalyze
https: //www. quantopian. com/
https: //www. quantopian. com/
Is a Boston-based company foundedin 2011 that aims to create a crowd-sourced hedge fund by letting freelance quantitative analysts develop test, and use trading algorithms to buy and sell securities (US stocks and futures). The company has a twosided market business model: (Wikipedia – Quantopian).
The first side consists of algorithm-developer members who develop (Python API - Sklearn), and test (Zipline back tester), for free, and trade for no charge (other than the associated brokerage commission and spread). These members can compete against other members in a series of contests called the “Quantopian Open. ” Anyone can join the site and (optionally) enter the contests: no particular educational qualification nor work experience are required.
The second side is investor-members in a socalled crowd-sourced hedge fund. These members have their investments managed by the winning algorithms. Successful developer-members can get a royalty or commission from investor-members, who profit from the former’s algorithm- (Wikipedia – Quantopian).
Recent News n First Pile of Steven Cohen Cash Is Handed Out to Quantopian's Amateur Coders, Bloomberg, April 6, 2017 – Bloomberg n Quantopian Hands Out $50 M Allocation to a Single Strategy August 2, 2018 – Bloomberg n 4 Crowdsourced Hedge Funds for Algorithmic Trading- Nanalyze
More Crowdsourced Hedge Funds n n n Quantopian -Select members license their algorithms and share in the profits Cloudquant – Trading strategy incubator for algorithmic trading Quantiacs – Code a trading algorithm. We connect it to capital. You profit. Quant. Connect – Pioneering Tomorrow’s Trading Research, Backtest and Trade Your Investments Numerai – A new kind of hedge fund built by a network of data scientists Oanda – First FX and CFD online trading fully automated trading platform Worldquant – Operates the World. Quant Challenge, where participants compete in the field of quantitative finance Collective 2 – Trading Strategy Platform and Marketplace Dukascopy – FX and CFD online trading fully automated trading JForex platform UQER. IO is a crowd-sourced hedge fund in China Joint. Quant– Fully automated Python strategy real trading China
5. Machine Learning - ML “Machines (computers) that learn form data (or experience)”
ML Definitions Machine learning is a core sub-area of artificial intelligence; it enables computers to get into a mode of self-learning without being explicitly programmed Machine Learning - Simplilearn Machine learning is a subset of artificial intelligence in the field of computer science that often uses statistical techniques to give computers the ability to “learn” (i. e. , progressively improve performance on a specific task) with data, without being explicitly programmed. ” Wikipedia - Machine_learning Advanced machine learning algorithms are composed of many technologies (such as deep learning, neural networks and naturallanguage processing), used in unsupervised and supervised learning, that operate guided by lessons from existing information. Machine Learning - Gartner IT Glossary
Jeremy Howard: The wonderful and terrifying implications of computers that can learn -TED Talk Follow this link to see the talk
Areas of application of ML Machine Learning Overview, Benjamin Timmermans, Data Science Blog
Others no included: • • • • Financial services , Algorithmic trading, Marketing and Sales, Online customer support, Speech recognition, Data security, Data science (discovering patterns in data), Bioinformatics (DNA and protein sequence analysis, genomics), Drug discovery and design Time series prediction, Game playing (reinforcement, web agents), Biometrics. Video surveillance, Information retrieval Search engine result refining, Sentiment analysis
ML Techniques and Algorithms A Tour of Machine Learning Algorithms, Jason Brownlee, 2013.
Others no included: • • • On Line Learning Graph - Network Analytics Probabilistic Graphical Models • • • Bayesian Networks Dynamic Bayesian Networks Hidden Markov Models Probabilistic Neural Networks Random Iterated Networks Other Recurrent Neural Networks Elman networks • Jordan networks • • Genetic Programming Adversarial Generalized Networks Auto-Machine Learning
Machine Learning Workflow WTF is Machine Learning? A Quick Guide, Hussnain Fareed, Towardsdatascience
Machine learning 10 – Funny pictures
6. Machine Learning in Trading “Machines (computers) that learn how to trade form data (or experience)” ”
Matthew Dixon: Deepmind and the Future of the Finance Industry - TEDx. IIT Follow this link to see the talk
Financial Assets Behaviour Modelling and Prediction Analytical Techniques Machine Learning Techniques Statistical Models Simulation Techniques Montecarlo – Games Artificial Neural Networks (ANN) Deep Neural Networks (DNN) Linear Models: LR, MLR, ES, ARMA, ARIMA, GARCH Non Linear Models: N- GARCH Recurrent Neural Networks (RNN) Decision trees Kernel Methods Support Vector Machines Probabilistic Graphical Models Stochastic Models Hidden Markov Models (HMM) Dynamic Bayesian Networks (DBN) BM, Diffusion, Poisson, Jumps, and Levy Processes Sentiment Analysis Graph - Network Analytics
A Word of Caution
My landscape on artificial intelligence quantitative funds and DIY funds, Etienne Brunet, Medium,
Our Research Group Activities § Courses (4 - 200) Computational Finance, Algorithms – ATE Quantopian § Data Structures - ATE FX Dukascopy § Machine Learning – ML AR+TE Quantopian § § Competitions Bolsa Millonaria (5) § Quantopian (100 – 10 -1) § Dukascopy (8) § § Meetup (350)
Our Research Group Activities § Thesis § MSc. (2) § § § Ph. D. Thesis (3) § § § DMLP HF US Stocks - A. Arevalo Ensemble Learning FX Colombia X P/V LMO – M. DBN – HMM FX Colombia X P/V LMO – J. Sandoval DNN-CNN P/V LMO Colombia US Stocks – J Niño RNN Wavelets P/V US Stocks - A. Arevalo Papers (20) Companies (3) Alliances BVC, Algocodex, Facturex, Info. Capitales § ODEON - Externado, § Stevens IT – NJ § Quantopian §
One: Example: DMLP One Minute Pseudo. Return Prediction Artificial Neuron
Deep Neural Networks Artificial Neural Networks: One-hidden layer perceptron Deep Learning Techniques Hierarchy feature building from lowlevel to high-level. Deep Multilayer Perceptron (DMLP)
REFERENCES n n n n n Wikipedia Quantopian. (2017). https: //en. wikipedia. org/wiki/Quantopian ML for Trading Resources – Machine Learning UN Col 2018. http: //disi. unal. edu. co/~gjhernandezp/ML/ ML FOR TRADING RESOURCES Machine Learning for Trading – Tucker Balch – Georgia Tech – Udacity The wisdom of the herd, The Economist, May 13 th 2017. https: //www. economist. com/news/finance-and-economics/21721946 -amateur-coderswrite-algorithms-compete-funds-new-sort-hedge-fund First Pile of Steven Cohen Cash Is Handed Out to Quantopian's Amateur Coders, Bloomberg, April 6, 2017. https: //www. bloomberg. com/news/articles/2017 -04 -06/firstpile-of-steven-cohen-cash-is-injected-into-quantopian-code ‘Crowdsourced’ Quantopian dives into algorithms, Financial Times, April 6, 2017. https: //www. ft. com/content/b 88 e 6830 -1969 -11 e 7 -9 c 35 -0 dd 2 cb 31823 a? mhq 5 j=e 3 MIT Enigma's Catalyst Could Be The Quantopian Of Crypto-Assets, International Business Times, Jul 7 2017. http: //www. ibtimes. com/mit-enigmas-catalyst-could-bequantopian-crypto-assets-2563708 Amazon engineer will let strangers on the internet manage his $50, 000 stock portfolio 'forever‘. http: //www. cnbc. com/2017/07/06/amazon-engineer-will-let-strangersmanage-his-portfolio-forever. html My landscape on artificial intelligence quantitative funds and DIY funds, Etienne Brunet, Medium, https: //medium. com/@etiennebr/my-landscape-on-artificialintelligence-quantitative-funds-and-diy-funds-13 e 1 b 4 c 25706











































































































