-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tex
414 lines (364 loc) · 15.4 KB
/
index.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
%
\documentclass[
letterpaper,
DIV=11,
numbers=noendperiod]{scrreprt}
\usepackage{amsmath,amssymb}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
\usepackage{lmodern}
\ifPDFTeX\else
% xetex/luatex font selection
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\setcounter{secnumdepth}{5}
% Make \paragraph and \subparagraph free-standing
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\usepackage{framed}
\definecolor{shadecolor}{RGB}{241,243,245}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.40,0.45,0.13}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\BuiltInTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\ExtensionTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.28,0.35,0.67}{#1}}
\newcommand{\ImportTok}[1]{\textcolor[rgb]{0.00,0.46,0.62}{#1}}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\NormalTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\RegionMarkerTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.07,0.07,0.07}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}\usepackage{longtable,booktabs,array}
\usepackage{calc} % for calculating minipage widths
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
% definitions for citeproc citations
\NewDocumentCommand\citeproctext{}{}
\NewDocumentCommand\citeproc{mm}{%
\begingroup\def\citeproctext{#2}\cite{#1}\endgroup}
\makeatletter
% allow citations to break across lines
\let\@cite@ofmt\@firstofone
% avoid brackets around text for \cite:
\def\@biblabel#1{}
\def\@cite#1#2{{#1\if@tempswa , #2\fi}}
\makeatother
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newenvironment{CSLReferences}[2] % #1 hanging-indent, #2 entry-spacing
{\begin{list}{}{%
\setlength{\itemindent}{0pt}
\setlength{\leftmargin}{0pt}
\setlength{\parsep}{0pt}
% turn on hanging indent if param 1 is 1
\ifodd #1
\setlength{\leftmargin}{\cslhangindent}
\setlength{\itemindent}{-1\cslhangindent}
\fi
% set entry spacing
\setlength{\itemsep}{#2\baselineskip}}}
{\end{list}}
\usepackage{calc}
\newcommand{\CSLBlock}[1]{\hfill\break\parbox[t]{\linewidth}{\strut\ignorespaces#1\strut}}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{\strut#1\strut}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{\strut#1\strut}}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
\KOMAoption{captions}{tableheading}
\makeatletter
\@ifpackageloaded{bookmark}{}{\usepackage{bookmark}}
\makeatother
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\AtBeginDocument{%
\ifdefined\contentsname
\renewcommand*\contentsname{Table of contents}
\else
\newcommand\contentsname{Table of contents}
\fi
\ifdefined\listfigurename
\renewcommand*\listfigurename{List of Figures}
\else
\newcommand\listfigurename{List of Figures}
\fi
\ifdefined\listtablename
\renewcommand*\listtablename{List of Tables}
\else
\newcommand\listtablename{List of Tables}
\fi
\ifdefined\figurename
\renewcommand*\figurename{Figure}
\else
\newcommand\figurename{Figure}
\fi
\ifdefined\tablename
\renewcommand*\tablename{Table}
\else
\newcommand\tablename{Table}
\fi
}
\@ifpackageloaded{float}{}{\usepackage{float}}
\floatstyle{ruled}
\@ifundefined{c@chapter}{\newfloat{codelisting}{h}{lop}}{\newfloat{codelisting}{h}{lop}[chapter]}
\floatname{codelisting}{Listing}
\newcommand*\listoflistings{\listof{codelisting}{List of Listings}}
\makeatother
\makeatletter
\makeatother
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\@ifpackageloaded{subcaption}{}{\usepackage{subcaption}}
\makeatother
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\usepackage{bookmark}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same} % disable monospaced font for URLs
\hypersetup{
pdftitle={quant\_book},
pdfauthor={Mislav Sagovac},
colorlinks=true,
linkcolor={blue},
filecolor={Maroon},
citecolor={Blue},
urlcolor={Blue},
pdfcreator={LaTeX via pandoc}}
\title{quant\_book}
\author{Mislav Sagovac}
\date{2024-06-05}
\begin{document}
\maketitle
\renewcommand*\contentsname{Table of contents}
{
\hypersetup{linkcolor=}
\setcounter{tocdepth}{2}
\tableofcontents
}
\bookmarksetup{startatroot}
\chapter*{Preface}\label{preface}
\addcontentsline{toc}{chapter}{Preface}
\markboth{Preface}{Preface}
This is a Quarto book.
To learn more about Quarto books visit
\url{https://quarto.org/docs/books}.
\begin{Shaded}
\begin{Highlighting}[]
\DecValTok{1} \SpecialCharTok{+} \DecValTok{1}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
[1] 2
\end{verbatim}
\bookmarksetup{startatroot}
\chapter{Introduction
(\#section-intro)}\label{introduction-section-intro}
\section{Becktesting engine
(Quantconnect)}\label{becktesting-engine-quantconnect}
In most cases, you will use a backtesting engine to test your trading
strategies. A backtesting engine is a software that simulates the
performance of a trading strategy on historical data. There are many
backtesting engines available. In out work we mostly use Quantconnect.
Quantconnect is cloud platform for quant research and trading. It is
based on LEAN engine, which is open source. It supports backtesting and
live trading. It is written in C\# and supports python. It has a lot of
data sources, and it is relativly easy to use. It is a perfect
environment for backtesting trading strategies and simple migration to
paper/live trading.
Similar, to programming languges, we want learn you how to use
Quantconnect. We can only give you some recommendations on how to learn
it.
\begin{itemize}
\tightlist
\item
register as a new user on https://www.quantconnect.com/
\item
go through bootcamps that can be found by clicking on Algorithm Lab -
Learning Center.
\item
go through you tube video series (especially
https://www.youtube.com/playlist?list=PLgWn81pQ2CNKcuUgFosE5YlfJvIZmbVG8)
\item
Read the documentation
https://www.quantconnect.com/docs/v2/writing-algorithms
\end{itemize}
It is not necessary to go into details. The recommendation is to start
with equity for the beginning. Later you can try with options/futures or
some other asset classes. You can use python and C\#, but we recommend
you to use python. Python is much more used in finance, and it has
numerous packages that make your job easier.
Except Quantconnect, there are other backtesting platforms. Here are
some for information, you can check them if you want: - Zorro trading
engine - Writing fasting trading strategies in C-lite or C++. Source:
https://zorro-project.com/ (C i C++) - Natulius trader - write trading
strategies in python or rust. Source: https://nautilustrader.io/ -
Backtrader - very popular backtesting engine written in pure python.
Source: https://www.backtrader.com/ - Vectorbt - vektorized backtester
in python. Source: https://vectorbt.dev/ - Some people develop their own
backtester, but we don't recommend it for the beginning, except for
simple strategies that include for loops for quick analysis.
\section{Programming languages}\label{programming-languages}
The most used programming language in the world of finance is Python. It
is a high-level programming language that is relatively easy to learn
and use. Other popular programming languages in finance include R, C++,
Java, and MATLAB. In our researching process, backtesting and
deployment, we mostly use R, python and, occasionally, C++. Learning one
of this languages is a must for every quant. The more languages you
know, the more versatile you are.
We can't teach you any of this languages in this book. We can only give
you some recommendations on how to learn them. We recommend you to start
with Python, as it is the most used language in finance. You can learn
it through online tutorials, books, or courses. There are plenty of
sources online. It also depends on you preferences, If you like more to
watch videos start with them, if you like books start with them.
If you are beginnes, we recommend you to start with DataCamp
(https://www.datacamp.com/). It has a lot of courses for beginners and
advanced users. Second, don't just learn the language, start developing
strategies with it as soon as possible. The best way to learn a
programming language is by using it. Just strt the project in your
favorit IDE (say VS code) and start coding.
If you prefer R, we recommend you to start learn following packages: -
data.table - for all data wrangling tasks. It is faster than dplyr in R
and pandas in python and uses less memory. - ggplot - for visualization.
- PerformanceAnalytics - for calculating various portfolio or individual
stock performances. - runner - for creating rolling and expanding
windows. Here only one function is important. - lubridate - for working
with times in R (converting time zones and similar). - mlr3 (optional,
if you use ML, (Binder et al. 2023)) - Something like scikit learn in
python. - Rcpp (optional, if you want to use c++ within R). - the
biggest advantage of R is the rich set of statistical packages that are
already developed. By simply googling you can quickly find a lot of
information. You need GARCH? USe ugarch package. You need ARIMA? Use
forecast package. You need to calculate VaR? Use rugarch package. And so
on.
All above packages are learned continuously, through the development of
strategies and projects. Every day you learn something new.
\section{Data}\label{data}
List of vendors are available on the link:
https://miltonfmr.com/historical-data-vendor-list/\#
We would add two more sources: - Databento - new data provider for very
quality and granular market data. Source: https://databento.com/ -
Financial Modeling Prep (FMP) - free and paid data provider for various
type of data. Source: https://financialmodelingprep.com/
We use daily and hour OHLCV data from Algoseek (bought from
Quantconnect) and minute data from Databento. We also use fundamental
data from FMP.
\section{Start developing strategies as soon as
possible}\label{start-developing-strategies-as-soon-as-possible}
Except learning programming languages and backtesting engines, you
should start developing strategies as soon as possible. The best way to
learn is by doing. When you start developing strategies, start with
simple ones. The more complex the strategy, the more difficult it is to
debug and understand. We will give you some recommendations on how to
start developing strategies.
\ldots{}
Osim učenja gornjih tehnologija, poslat ću i: 1) jednu postojeću
strategiju kako bi je proučili i potencijalno poboljšali (zajednički
možemo raspraviti kako se može poboljšati). 2) jednu novu strategiju
koju možeš testirati kroz skriptu/notebook u programskom jeziku po
izboru i/ili Quantconnectu.
\ldots{}
\subsection{Market orders vs limit
orders}\label{market-orders-vs-limit-orders}
https://x.com/macrocephalopod/status/1375937561366003723
You can always submit a limit order which crosses the spread, combining
the benefit of immediacy for all reasonable cases with the protection of
a price limit in case of an illiquid market or price jump. A market buy
order is a limit order with a price limit of infinity.
Seems relevant given the recent BRK.A shenanigans on 06/2024.
\bookmarksetup{startatroot}
\chapter*{References}\label{references}
\addcontentsline{toc}{chapter}{References}
\markboth{References}{References}
\phantomsection\label{refs}
\begin{CSLReferences}{1}{0}
\bibitem[\citeproctext]{ref-mlr3book}
Binder, Martin, Michel Lang, Lars Kotthoff, Patrick Schratz, Giuseppe
Casalicchio, and Bernd Bischl. 2023. \emph{Machine Learning with r: A
Complete Guide}. mlr3book.mlr-org.com.
\url{https://mlr3book.mlr-org.com/}.
\end{CSLReferences}
\end{document}