Preface |
|
xvii | |
About the Authors |
|
xxiii | |
|
PART ONE Language Fundamentals |
|
|
|
Chapter 1 Fundamentals of the q Programming Language |
|
|
3 | (38) |
|
1.1 The (Not So Very) First Steps in q |
|
|
3 | (2) |
|
|
5 | (9) |
|
|
11 | (3) |
|
1.3 Basic Language Constructs |
|
|
14 | (5) |
|
1.3.1 Assigning, Equality and Matching |
|
|
14 | (3) |
|
1.3.2 Arithmetic Operations and Right-to-Left Evaluation: Introduction to q Philosophy |
|
|
17 | (2) |
|
|
19 | (12) |
|
1.5 Difference between Strings and Symbols |
|
|
31 | (2) |
|
|
31 | (2) |
|
1.6 Matrices and Basic Linear Algebra in q |
|
|
33 | (2) |
|
1.7 Launching the Session: Additional Options |
|
|
35 | (3) |
|
|
38 | (3) |
|
Chapter 2 Dictionaries and Tables: The q Fundamentals |
|
|
41 | (16) |
|
|
41 | (3) |
|
|
44 | (4) |
|
2.3 The Truth about Tables |
|
|
48 | (2) |
|
2.4 Keyed Tables are Dictionaries |
|
|
50 | (1) |
|
2.5 From a Vector Language to an Algebraic Language |
|
|
51 | (6) |
|
|
57 | (24) |
|
|
59 | (1) |
|
3.1.0.1 .quantQ. Namespace |
|
|
60 | (1) |
|
|
60 | (12) |
|
|
60 | (1) |
|
|
61 | (1) |
|
|
61 | (1) |
|
|
62 | (1) |
|
3.2.1.4 Cross Product /: \: |
|
|
62 | (1) |
|
|
63 | (3) |
|
|
66 | (1) |
|
|
67 | (1) |
|
|
67 | (1) |
|
|
68 | (1) |
|
3.2.5.1 EMA: The Exponential Moving Average |
|
|
69 | (1) |
|
|
70 | (1) |
|
|
70 | (1) |
|
|
71 | (1) |
|
|
72 | (3) |
|
|
72 | (1) |
|
|
73 | (2) |
|
3.4 Protected Evaluations |
|
|
75 | (1) |
|
|
76 | (3) |
|
|
76 | (1) |
|
3.5.1.1 Simple Aggregators |
|
|
76 | (1) |
|
3.5.1.2 Weighted Aggregators |
|
|
77 | (1) |
|
|
77 | (1) |
|
3.5.2.1 Running Functions |
|
|
77 | (1) |
|
|
78 | (1) |
|
3.6 Convention for User-Defined Functions |
|
|
79 | (2) |
|
Chapter 4 Editors and Other Tools |
|
|
81 | (12) |
|
|
81 | (1) |
|
|
82 | (2) |
|
|
84 | (6) |
|
|
85 | (3) |
|
|
88 | (2) |
|
|
90 | (2) |
|
|
92 | (1) |
|
Chapter 5 Debugging q Code |
|
|
93 | (14) |
|
5.1 Introduction to Making It Wrong: Errors |
|
|
93 | (7) |
|
|
94 | (1) |
|
|
94 | (1) |
|
|
95 | (3) |
|
|
98 | (2) |
|
|
100 | (2) |
|
5.3 Debugging Server-Side |
|
|
102 | (5) |
|
|
|
Chapter 6 Splayed and Partitioned Tables |
|
|
107 | (14) |
|
|
107 | (1) |
|
6.2 Saving a Table as a Single Binary File |
|
|
108 | (2) |
|
|
110 | (3) |
|
|
113 | (6) |
|
|
119 | (2) |
|
|
121 | (30) |
|
|
121 | (4) |
|
|
125 | (19) |
|
|
125 | (1) |
|
|
126 | (1) |
|
|
126 | (1) |
|
|
127 | (1) |
|
|
128 | (1) |
|
|
129 | (2) |
|
|
131 | (3) |
|
|
134 | (1) |
|
7.2.8.1 The Next Valid Join |
|
|
135 | (3) |
|
|
138 | (2) |
|
|
140 | (4) |
|
7.3 Advanced Example: Running TWAP |
|
|
144 | (7) |
|
Chapter 8 Parallelisation |
|
|
151 | (10) |
|
8.1 Parallel Vector Operations |
|
|
152 | (3) |
|
8.2 Parallelisation over Processes |
|
|
155 | (1) |
|
|
155 | (3) |
|
8.4 Advanced Topic: Parallel File/Directory Access |
|
|
158 | (3) |
|
Chapter 9 Data Cleaning and Filtering |
|
|
161 | (4) |
|
|
161 | (2) |
|
|
161 | (2) |
|
9.1.2 Aggregation Filtering |
|
|
163 | (1) |
|
9.2 Data Cleaning, Normalising and APIs |
|
|
163 | (2) |
|
|
165 | (16) |
|
|
166 | (5) |
|
|
166 | (4) |
|
10.1.2 Parse Tree Creation |
|
|
170 | (1) |
|
10.1.3 Read-Only Evaluation |
|
|
170 | (1) |
|
|
171 | (10) |
|
|
174 | (4) |
|
|
178 | (1) |
|
|
179 | (1) |
|
|
180 | (1) |
|
Chapter 11 A Few Use Cases |
|
|
181 | (10) |
|
|
181 | (2) |
|
|
181 | (1) |
|
|
182 | (1) |
|
11.2 Weighted Mid for N Levels of an Order Book |
|
|
183 | (2) |
|
11.3 Consecutive Runs of a Rule |
|
|
185 | (1) |
|
11.4 Real-Time Signals and Alerts |
|
|
186 | (5) |
|
|
|
Chapter 12 Basic Overview of Statistics |
|
|
191 | (38) |
|
|
191 | (5) |
|
|
196 | (2) |
|
|
198 | (31) |
|
|
198 | (3) |
|
|
201 | (1) |
|
|
202 | (1) |
|
12.3.3 t-test: One Sample |
|
|
202 | (2) |
|
|
204 | (1) |
|
12.3.4 t-test: Two Samples |
|
|
204 | (1) |
|
|
205 | (1) |
|
|
206 | (2) |
|
12.3.5.1 Implementation of the Test |
|
|
208 | (3) |
|
|
211 | (1) |
|
12.3.6 Wilcoxon Signed-Rank Test |
|
|
212 | (2) |
|
12.3.7 Rank Correlation and Somers' D |
|
|
214 | (2) |
|
|
216 | (5) |
|
12.3.8 Multiple Hypothesis Testing |
|
|
221 | (3) |
|
12.3.8.1 Bonferroni Correction |
|
|
224 | (1) |
|
12.3.8.2 Sidak's Correction |
|
|
224 | (1) |
|
|
225 | (1) |
|
|
226 | (3) |
|
Chapter 13 Linear Regression |
|
|
229 | (36) |
|
|
230 | (1) |
|
13.2 Ordinary Least Squares |
|
|
231 | (2) |
|
13.3 The Geometric Representation of Linear Regression |
|
|
233 | (7) |
|
13.3.1 Moore-Penrose Pseudoinverse |
|
|
235 | (2) |
|
|
237 | (3) |
|
13.4 Implementation of the OLS |
|
|
240 | (3) |
|
13.5 Significance of Parameters |
|
|
243 | (1) |
|
13.6 How Good is the Fit: R2 |
|
|
244 | (4) |
|
13.6.1 Adjusted R-squared |
|
|
247 | (1) |
|
13.7 Relationship with Maximum Likelihood Estimation and AIC with Small Sample Correction |
|
|
248 | (4) |
|
|
252 | (2) |
|
13.9 Comparing Two Nested Models: Towards a Stopping Rule |
|
|
254 | (3) |
|
13.9.1 Comparing Two General Models |
|
|
256 | (1) |
|
13.10 In-/Out-of-Sample Operations |
|
|
257 | (5) |
|
|
262 | (2) |
|
|
264 | (1) |
|
Chapter 14 Time Series Econometrics |
|
|
265 | (36) |
|
14.1 Autoregressive and Moving Average Processes |
|
|
265 | (20) |
|
|
265 | (1) |
|
|
266 | (1) |
|
|
266 | (2) |
|
14.1.2.2 Estimation of AR(p) Parameters |
|
|
268 | (1) |
|
14.1.2.3 Least Square Method |
|
|
268 | (1) |
|
|
269 | (1) |
|
14.1.2.5 Maximum Likelihood Estimator |
|
|
269 | (1) |
|
14.1.2.6 Yule-Walker Technique |
|
|
269 | (2) |
|
|
271 | (1) |
|
14.1.3.1 Estimation of MA(q) Parameters |
|
|
272 | (1) |
|
|
272 | (1) |
|
|
273 | (1) |
|
14.1.4 ARMA(p, q) Process |
|
|
273 | (1) |
|
14.1.4.1 Invertibility of the ARMA(p, q) Process |
|
|
274 | (1) |
|
14.1.4.2 Hannan-Rissanen Algorithm: Two-Step Regression Estimation |
|
|
274 | (1) |
|
14.1.4.3 Yule-Walker Estimation |
|
|
274 | (1) |
|
14.1.4.4 Maximum Likelihood Estimation |
|
|
275 | (1) |
|
|
275 | (1) |
|
|
276 | (1) |
|
14.1.5 ARIMA(p, d, q) Process |
|
|
276 | (1) |
|
|
276 | (1) |
|
|
277 | (1) |
|
|
278 | (4) |
|
|
282 | (3) |
|
14.2 Stationarity and Granger Causality |
|
|
285 | (2) |
|
|
285 | (1) |
|
14.2.2 Test of Stationarity -- Dickey-Fuller and Augmented Dickey-Fuller Tests |
|
|
286 | (1) |
|
|
286 | (1) |
|
14.3 Vector Autoregression |
|
|
287 | (14) |
|
|
288 | (1) |
|
|
288 | (1) |
|
|
288 | (1) |
|
|
289 | (4) |
|
|
293 | (4) |
|
14.3.2 VARX(p, q) Process |
|
|
297 | (1) |
|
|
297 | (1) |
|
|
298 | (3) |
|
Chapter 15 Fourier Transform |
|
|
301 | (24) |
|
|
301 | (7) |
|
15.1.1 Properties of Complex Numbers |
|
|
302 | (6) |
|
15.2 Discrete Fourier Transform |
|
|
308 | (6) |
|
15.3 Addendum: Quaternions |
|
|
314 | (7) |
|
|
321 | (4) |
|
Chapter 16 Eigensystem and PCA |
|
|
325 | (34) |
|
|
325 | (2) |
|
|
327 | (5) |
|
|
328 | (2) |
|
16.2.2 QR Algorithm for Eigenvalues |
|
|
330 | (1) |
|
|
331 | (1) |
|
16.3 Implementation of Eigensystem Calculation |
|
|
332 | (9) |
|
|
333 | (4) |
|
|
337 | (4) |
|
16.4 The Data Matrix and the Principal Component Analysis |
|
|
341 | (10) |
|
|
341 | (3) |
|
16.4.2 PCA: The First Principal Component |
|
|
344 | (1) |
|
16.4.3 Second Principal Component |
|
|
345 | (2) |
|
16.4.4 Terminology and Explained Variance |
|
|
347 | (2) |
|
16.4.5 Dimensionality Reduction |
|
|
349 | (1) |
|
16.4.6 PCA Regression (PCR) |
|
|
350 | (1) |
|
16.5 Implementation of PCA |
|
|
351 | (3) |
|
16.6 Appendix: Determinant |
|
|
354 | (5) |
|
|
354 | (1) |
|
16.6.2 Techniques to Calculate a Determinant |
|
|
355 | (1) |
|
16.6.3 Implementation of the Determinant |
|
|
356 | (3) |
|
Chapter 17 Outlier Detection |
|
|
359 | (10) |
|
17.1 Local Outlier Factor |
|
|
360 | (9) |
|
Chapter 18 Simulating Asset Prices |
|
|
369 | (12) |
|
18.1 Stochastic Volatility Process with Price Jumps |
|
|
369 | (2) |
|
18.2 Towards the Numerical Example |
|
|
371 | (7) |
|
18.2.1 Numerical Preliminaries |
|
|
371 | (3) |
|
18.2.2 Implementing Stochastic Volatility Process with Jumps |
|
|
374 | (4) |
|
|
378 | (3) |
|
PART FOUR Machine Learning |
|
|
|
Chapter 19 Basic Principles of Machine Learning |
|
|
381 | (10) |
|
19.1 Non-Numeric Features and Normalisation |
|
|
381 | (5) |
|
19.1.1 Non-Numeric Features |
|
|
381 | (1) |
|
19.1.1.1 Ordinal Features |
|
|
382 | (1) |
|
19.1.1.2 Categorical Features |
|
|
383 | (1) |
|
|
383 | (1) |
|
|
384 | (1) |
|
|
385 | (1) |
|
19.2 Iteration: Constructing Machine Learning Algorithms |
|
|
386 | (5) |
|
|
386 | (3) |
|
19.2.2 Constructing Machine Learning Algorithms |
|
|
389 | (2) |
|
Chapter 20 Linear Regression with Regularisation |
|
|
391 | (28) |
|
20.1 Bias--Variance Trade-off |
|
|
392 | (1) |
|
|
393 | (1) |
|
|
394 | (2) |
|
20.4 Implementation of the Ridge Regression |
|
|
396 | (7) |
|
20.4.1 Optimisation of the Regularisation Parameter |
|
|
401 | (2) |
|
|
403 | (2) |
|
20.6 Implementation of the Lasso Regression |
|
|
405 | (14) |
|
Chapter 21 Nearest Neighbours |
|
|
419 | (18) |
|
21.1 k-Nearest Neighbours Classifier |
|
|
419 | (4) |
|
21.2 Prototype Clustering |
|
|
423 | (6) |
|
21.3 Feature Selection: Local Nearest Neighbours Approach |
|
|
429 | (8) |
|
|
430 | (7) |
|
Chapter 22 Neural Networks |
|
|
437 | (28) |
|
22.1 Theoretical Introduction |
|
|
437 | (8) |
|
|
440 | (1) |
|
|
441 | (2) |
|
22.1.2 The Learning Rate Parameter |
|
|
443 | (1) |
|
|
443 | (1) |
|
|
444 | (1) |
|
22.1.5 Dimension of the Hidden Layer(s) |
|
|
444 | (1) |
|
22.2 Implementation of Neural Networks |
|
|
445 | (6) |
|
22.2.1 Multivariate Encoder |
|
|
445 | (1) |
|
|
446 | (2) |
|
22.2.3 Training the Neural Network |
|
|
448 | (3) |
|
|
451 | (12) |
|
22.3.1 Binary Classification |
|
|
451 | (3) |
|
22.3.2 M-class Classification |
|
|
454 | (3) |
|
|
457 | (6) |
|
22.4 Possible Suggestions |
|
|
463 | (2) |
|
Chapter 23 AdaBoost with Stumps |
|
|
465 | (12) |
|
|
465 | (1) |
|
|
466 | (1) |
|
|
467 | (1) |
|
23.4 Implementation of AdaBoost |
|
|
468 | (6) |
|
23.5 Recommendation for Readers |
|
|
474 | (3) |
|
|
477 | (18) |
|
24.1 Introduction to Trees |
|
|
477 | (2) |
|
|
479 | (3) |
|
24.2.1 Cost-Complexity Pruning |
|
|
481 | (1) |
|
|
482 | (2) |
|
|
484 | (1) |
|
24.5 Implementation of Trees |
|
|
485 | (10) |
|
|
495 | (14) |
|
|
495 | (3) |
|
|
498 | (2) |
|
|
499 | (1) |
|
|
500 | (9) |
|
|
503 | (2) |
|
|
505 | (4) |
|
Chapter 26 Unsupervised Machine Learning: The Apriori Algorithm |
|
|
509 | (14) |
|
|
510 | (1) |
|
26.2 Implementation of the Apriori Algorithm |
|
|
511 | (12) |
|
Chapter 27 Processing Information |
|
|
523 | (18) |
|
27.1 Information Retrieval |
|
|
523 | (9) |
|
27.1.1 Corpus: Leonardo da Vinci |
|
|
523 | (1) |
|
27.1.2 Frequency Counting |
|
|
524 | (4) |
|
|
528 | (4) |
|
27.2 Information as Features |
|
|
532 | (9) |
|
27.2.1 Sample: Simulated Proteins |
|
|
533 | (2) |
|
27.2.2 Kernels and Metrics for Proteins |
|
|
535 | (1) |
|
27.2.3 Implementation of Inner Products and Nearest Neighbours Principles |
|
|
535 | (4) |
|
|
539 | (2) |
|
Chapter 28 Towards Al -- Monte Carlo Tree Search |
|
|
541 | (42) |
|
28.1 Multi-Armed Bandit Problem |
|
|
541 | (17) |
|
28.1.1 Analytic Solutions |
|
|
543 | (1) |
|
|
543 | (1) |
|
28.1.3 Confidence-Based Algorithms |
|
|
544 | (2) |
|
28.1.4 Bayesian Algorithms |
|
|
546 | (1) |
|
28.1.5 Online Gradient Descent Algorithms |
|
|
547 | (1) |
|
28.1.6 Implementation of Some Learning Algorithms |
|
|
547 | (11) |
|
28.2 Monte Carlo Tree Search |
|
|
558 | (7) |
|
|
561 | (1) |
|
|
562 | (1) |
|
|
563 | (1) |
|
28.2.4 Back Propagation Step |
|
|
563 | (1) |
|
28.2.5 Finishing the Algorithm |
|
|
563 | (1) |
|
28.2.6 Remarks and Extensions |
|
|
564 | (1) |
|
28.3 Monte Carlo Tree Search Implementation -- Tic-tac-toe |
|
|
565 | (14) |
|
|
566 | (4) |
|
|
570 | (9) |
|
|
579 | (1) |
|
28.4 Monte Carlo Tree Search -- Additional Comments |
|
|
579 | (4) |
|
28.4.1 Policy and Value Networks |
|
|
579 | (2) |
|
28.4.2 Reinforcement Learning |
|
|
581 | (2) |
|
Chapter 29 Econophysics: The Agent-Based Computational Models |
|
|
583 | (12) |
|
29.1 Agent-Based Modelling |
|
|
584 | (3) |
|
29.1.1 Agent-Based Models in Society |
|
|
584 | (2) |
|
29.1.2 Agent-Based Models in Finance |
|
|
586 | (1) |
|
29.2 Ising Agent-Based Model for Financial Markets |
|
|
587 | (5) |
|
29.2.1 Ising Model in Physics |
|
|
587 | (1) |
|
29.2.2 Ising Model of Interacting Agents |
|
|
587 | (1) |
|
29.2.3 Numerical Implementation |
|
|
588 | (4) |
|
|
592 | (3) |
|
|
595 | (6) |
Bibliography |
|
601 | (6) |
Index |
|
607 | |