Modelled and Computer-Assisted Trading...8. GUI or web application (we don’t do) PyQT5 or tkinter...
Transcript of Modelled and Computer-Assisted Trading...8. GUI or web application (we don’t do) PyQT5 or tkinter...
Modelled and Computer-Assisted Trading
... or algotrading ...
background and introduction to the topic
The younger the better
... but make them build
their own equipment.
© 2019 Gary R. Evans. This slide set by Gary R. Evans is
licensed under a Creative Commons Attribution-
NonCommercial-ShareAlike 4.0 International License.
From seekingalpha January 7, 2018, reprint from investingcafeine.com
Is this algotrading ...?
What is algo(rithmic) trading, modelled trading, and or computer-assisted trading?
• Modelled trading implies that the trading strategy, and such components of strategy as asset pricing, price
discovery, trade timing, alpha assessment (historical profitability or capacity to make a future profit), risk
assessment, correlation analysis, and so forth, is guided by a logical model, almost always mathematical and
typically, but not always, statistical (drawing from statistics). Modelled trading does not imply that execution of
trade is undertaken by the model – execution can be manual.
Example: Using an options pricing model, like Black-Scholes-Merton, to evaluate the pricing of a strangle,
then executing the strangle manually.
• Algorithmic trading takes modelled trading one step further, and maybe many steps further, in that trading models
perform the same role as they do in modelled trading, but the execution of trade is also carried out by the
model, minimizing the human role in trading. To be specific, the model submits limit orders directly to the market
(and similar acts) guided by its own internal instruction set, always, of course, as computer program(s) operating
on workstations.
• Computer-assisted trading (my term) represents a hybrid of these two extremes, where modelling still guides the
strategy (although there is room for the input of “experience,” such as especially in trade timing), and execution
algos are used in a limited or very dedicated capacity, and the trading execution ends up being a mix of algo
trading and direct manual trading.
Specialize algo-trading: HST and HFTMarket-making, or what we refer to as spread-arbitrage, is probably the dominant form of algo-trading, and it
involves a combination of high-speed trading (HST) and high-frequency trading (HFT).
High-speed trading gives an advantage to the trader who is the first to see limit orders and respond to them, where
delays are measured in milliseconds, microseconds, and even picoseconds (shortening a fiber-optic cable shortens a
message by about 4,000 picoseconds). They therefore employ extremely expensive technology (fiber-optic and
microwave) and pay premium rents for proximity to the exhanges with which they work.
High frequency trading implies limit order placement and withdrawal on a staggering scale (resulting in the fact that
90% of limit orders are never executed), which can only be done by very fast computers with low-latency I/O
parallel and concurrency technology.
Many of these HFTs also pay directly for order-flow (increasingly controversial). Robinhood and Alpaca sell all order
flow to HFTs (none of the orders go to exchanges) and the buyers include (from Robinhood: Citadel, Two Sigma,
G1 Execution, Wolverine, Virtu), Knight Capital, Getco, Goldman Sachs, JP Morgan.
To understand what they do we need to understand spread arbitrage (which you should remember from Econ104),
Except for small, illiquid pockets, this is not our market. We can’t hope to compete with these traders.
A list of strategies used by firms and traders ...
STOCKS, FUTURES, OPTIONS
Spread arbitrage (market making)
Momentum trading
Mean reversion
• Pairs trading (and similar)
Pricing anomalies
• Statistical arbitrage (stat arb)
• ETF arbitrage
OPTIONS:
Pricing anomalies
Writing covered calls
Earnings strangles
• Complex dividend strategies (like wheels)
• Naked option writing and credit and debit spreads
• Will teach Will do with a model! Maybe a model, will teach otherwise
And now ...Contributions to this made by Avi Thaker ‘17
Background sources for the material already introduced are too extensive to document here. But this course
has links for many, many of them at
https://www.palmislandtraders.com/econ136/e136lit.htm
Assignment: Look this over in the next week
[end of Thaker contribution ...for the time being]
What the complete algo-set must be able to do ...
Task Example
1. Use an API to connect to a brokerage site. Using a Python API, aided by a 3rd-party library
like ibinsync (the one I use) or IbPy, through IB’s
algo interface (TWS or IBGateway).
2. Collect live low-latency data, quotes, and
primary information, like Level I and Level II
quotes.
Knowing the internal IB data structure (which is
complex and similar to a Python dictionary:
keyword and attribute).
3. Collect historical data from the brokerage
database and other sources.
IEX and IB are our primary free sources, and we
can buy data from Quandl and CBOE DataShop.
4. Standing, looping programs to gather systematic
recurring data for your own database and/or for
your machine learning algos.
Gathering strangle option IV for 10 days every 15
minutes as you approach an earnings report?
5. Gathering concurrent data, including large sets
of data, for making low latency, large scale
calculations of key variables or indicators that can
be used in an algo or for subjective trading.
Data for making large-scale stock behavior
correlation calculations, dynamically, frequently,
and with very low latency.
(algo must do ... continued)
Task Example
6. Perform the core algo after gathering quotes or
similar.
Retrieving BB and BA from limit order books, then
after satisfying spread requirements, process limit
orders to buy and sell to establish BB and BA.
7. Performing response functions (possibly using
machine learning) and setting threshold functions
for market response (hard part).
Responding to (initially) unexpected responses to
your orders, and adjusting to your own market
impact (on the example above)
8. GUI or web application (we don’t do) PyQT5 or tkinter GUI or Django web interface.
9. Logging and time-testing. Evaluating latency for the different candidate
methods that you are considering plus systematic
recording of experiments and recording of data in
timed sequences.
10. Backtesting where necessary or appropriate
(we don’t do, but you should).
Evaluating mean-reversion and momentum algos
or the “high-margin retirement” theory.
11. Maintain a database and/or log Anywhere and everywhere – you don’t really have
an algo unless you keep records.
Under-the-radar algo-trading and the horse-racing story ... a Bayesian approach
Your teacher, Avi Thaker and a few other of the Palm Island Traders believe that there are endless opportunities in
under-the-radar computer-assisted trading. Lack of liquidity and/or very limited profit opportunities keep large traders
away from a large segment of these markets. Would Citadel be interested in a trading strategy that could make little
more than $18 per day? Probably not. But would you if it could be automated? A lot of these trades do not lend
themselves to economics of scale, and are more suitable for the nimble small trader or the small trading team than
large firms.
An example that we will consider will be spread-arbitrage on relatively illiquid stocks with wide B/A spreads (like
NATH in the past, but we will look for better examples this semester). Can we write an arbitrage algo that makes us
into a market maker on a tiny scale?
A Bayesian approach – the FORTAN horse-racing model, vintage 1978.
A story about getting an edge ...
Typical job ad .. which I think I saw on Reddit
Note that sales,
management, team,
and leadership skills
are emphasized here.
RobinHood scrambles
options trades and
shuts valid accounts,
Dec 12, 2018
Topical: Why I am a little skeptical of
using Robinhood (aside from the
order-routing issue):