Low Latency Systematic Trading Algorithm Based on Markowitz Portfolio
1
Markowitz Portfolio Simulator
Systematic Trading
2 With systematic trading, regardless of what has happened at that moment, you would do the exact same thing. Systematic
3 trading is similar to some branches of algorithmic trading in that you execute according to a set of rules or
4 principles and different from others in implementation.With systematic trading, you can place the trade or have the
5 execution automated.
6
7 Algorithmic Trading
8 Algorithmic trading alternatively, includes semiand fully automated trading, quantitative trading, and Figh - Frequency
9 Trading (HFT). While algorithmic trading is systematic in the sense of following a set of rules, all systematic trading
10 is not necessarily algorithmic. Algorithmic trading encompasses quantitative trading.
11 Inside of quantitative trading is high - frequency trading.
12
13 Basics of Algorithmic Trading : Concepts and Examples
14
15 ExSan uses for this simulation data market from Yahoo Finance.
16 About + 1000 files in txt format, each containing 4K to 7K records entries containing data since Jan 2000.
17
18 This simulator can handle more than + 1000 stocks / assets. It is only limited by the amount of RAM installedand the
19 addressable memory. Datum - Data Files
20
21 ///---BEGIN Code
22 fstream fDB[1000]; // ExSan can read more files, depends on RAM installed
23 //...some code
24 unsigned short shftSTock(0);
25 for (i = 0; i < j; i++) {
26 fileID[i] = "...ubication/filename_" + stockID[i] + ".txt";
27 fDB[i].open(fileID[i], ios::in);
28 if (!fDB[i]) {
29 printf("Error!");
30 fout.flush() << "\n\tThis file does not exist " << fileID[i];
31 exit(1);
32 }
33 shftReadSTock = dist(generator); //much better randomness
34 while (shftReadSTock--) fDB[i] >> datum; /// shift in this file i, forces to a new position to start reading
35 }
36 ///---Code END.
37
38 datum is a multimap < StockName, time_stamp, bid, ask, Volume> the actual data is read using Yahoo intraday data
39 each datum File fDB[s] has a different number of records depending of the corresponding stok volatiliy
40
41 At the beginning all + 1000 files are opened and right away their access pointers are randomly shifted to a new position,
42 so every time the portfolio simulator is executed the scenario is does not repeat because at the very beginning all data
43 files start to be read at a random position from their beginning.
44
45 Every data file is read(accessed) sequentially but ExSan randomly picks ONE of the files(already opened at the beginning)
46 to provide one datum < StockName, time_stamp, bid, ask, Volume> at a time to the simulator.
47
48
49
50 Data data files are accesed randomly to read a new value(stock price) that will be feeded into the simulator
51 ///---BEGIN Code
52 while (!portfolio && ...) {
53 do {
54 s = dist(generator);
55 fDB[s] >> datum; //random file is choosen from fDB
56 } while (s < 0 || s >= stockCounterDB); //
57 //...some stuff
58 }
59 ///---Code END.
60 Polulating ExSan with Market Data
61 This Simulator has been implemented using Markowitz’s Portfolio Optimization Theory(Quant Finance), it uses matrix
62 generalization version that is based on Lagrange’s Theorem, maximum return has been implemented.
63
64 Once ExSan has capture enough data the actual simulator begins, it looks like : Datum Uploaded to ExSan
65
66 label 1
67 Let's say v is the volatility of an active/asset/stock
68 dv/dt and d2v/dt2 are stochastic t: time
69
70 In order to establish correlations a very innovative algorithm has been implemented to select those entries that are
71 closely concurrent on time. The algoritm takes a snap shot of the market uploaded to exsan, it uses datum.time_stamp
72 to descriminates those stocks that can be used to configure an \"instant portfolio\", this filter produces a db simmilar
73 to this: Closely concurrent Data Market Selection
74
75 An N asset Portfolio simulator will require a correlation matrix of dim(N x N).
76 A portfolio of 1000 stocks requires a correlation matrix of dimension Corr(1000 x 1000).
77
78 Portfolio Optimization imposed restrictions at the beginning like leverage and others led to modify the the correlation
79 matrix during execution, if an element or the correlation matrix[i, j] does not satisfies a particular condition the whole
80 matrix must be corrected if CorrMatrix[i, j] = 0 then all entries i and j should be set to zero and it's corresponding [i, j]
81 this implies a recursive procedure that is achieved by the following ALGORITHM
Comments
Post a Comment