|
| 1 | +# Welcome to qStudio - SqlNotebooks |
| 2 | + |
| 3 | +If you want help there are guides located at http://www.timestored.com/qstudio/help/ |
| 4 | + |
| 5 | +Any feature requests etc feel free to raise on [github](https://github.com/timeseries/qstudio/issues). |
| 6 | + |
| 7 | +# Latest Trade Prices |
| 8 | + |
| 9 | +Table display can be configured using column names. See help->charts for details on format. |
| 10 | + |
| 11 | +```sql type="grid" server="localhost:5000" |
| 12 | +update percbar_SD_DATABAR:percent_SD_PERCENT0 ,bid_SD_FG:((`$("#FF6666";"#66FF66";""))!`$("#222";"#222";"")) bid_SD_BG from |
| 13 | + ([] time:.z.t-til 50; |
| 14 | + status:50?`partial`filled; |
| 15 | + instrument:50?`GBPUSD`USDNZD`USDCAD`CHFJPY`EURUSD; |
| 16 | + symbol_SD_TAG:50?`UBS`C`MS`HSBC`NOMURA`DB; |
| 17 | + price_SD_CURUSD:50?100.0; |
| 18 | + bid:50?20.0; |
| 19 | + bid_SD_BG:50?`$("#FF6666";"";"";"";"";"";"";"";"";"";"";"";"";"#66FF66"); |
| 20 | + bid_SD_CODE:50?("0.xXXx";"0.XXx";"0.xxXX"); |
| 21 | + percent_SD_PERCENT0:50?1.0 ) |
| 22 | +``` |
| 23 | + |
| 24 | +# Gold vs Bitcoin 2024 |
| 25 | + |
| 26 | +```sql type="timeseries" server="localhost:5000" |
| 27 | +{ walk:{ [seed;n] |
| 28 | + r:{{ abs ((1664525*x)+1013904223) mod 4294967296}\[y-1;x]}; |
| 29 | + prds (100+((r[seed;n]) mod 11)-5)%100}; |
| 30 | + c:{x mod `long$00:20:00.0t}x; st:x-c; cn:`long$c%1000; |
| 31 | + ([] time:.z.d+st+1000*til cn; gold:walk[100;cn]; bitcoin:walk[2;cn]) }[.z.t] |
| 32 | +``` |
| 33 | + |
| 34 | +## Candlestick Chart |
| 35 | + |
| 36 | + |
| 37 | +- The table should contain columns labelled open/high/low/close/volume. |
| 38 | +- The table must atleast contain high/low or open/close to allow it to be drawn. |
| 39 | + |
| 40 | + |
| 41 | +```sql type="candle" server="localhost:5000" |
| 42 | +{ r:{{ abs ((1664525*x)+1013904223) mod 4294967296}\[y-1;x]}; |
| 43 | + walk:{ [r;seed;n] prds (100+((r[seed;n]) mod 11)-5)%100}[r;;]; |
| 44 | + c:{x mod `long$00:05:00.0t}x; st:x-c; cn:100+`long$c%1000; |
| 45 | + t:([] time:`second$.z.d+st+1000*til cn; open:walk[9;cn]; close:walk[105;cn]); |
| 46 | + -100 sublist update low:?[open > close;close;open]-(r[11;cn] mod 11)*0.02,high:?[open < close;close;open]+(r[44;cn] mod 11)*0.02,volume:(r[44;cn] mod 110) from t}[.z.t] |
| 47 | +``` |
| 48 | + |
| 49 | +# Bar |
| 50 | + |
| 51 | +- The first string columns are used as category labels. |
| 52 | +- Whatever numeric columns appear after the strings represents a separate series in the chart. |
| 53 | + |
| 54 | +```sql type="bar" server="localhost:5000" |
| 55 | +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; |
| 56 | + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; |
| 57 | + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; |
| 58 | + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) |
| 59 | +``` |
| 60 | + |
| 61 | +# Bar Horizontal |
| 62 | + |
| 63 | +```sql type="bar_horizontal" server="localhost:5000" |
| 64 | +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; |
| 65 | + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; |
| 66 | + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; |
| 67 | + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) |
| 68 | +``` |
| 69 | + |
| 70 | +# Stack |
| 71 | + |
| 72 | +- The first string columns are used as category labels. |
| 73 | +- Whatever numeric columns appear after the strings represents a separate series in the chart. |
| 74 | + |
| 75 | +```sql type="stack" server="localhost:5000" |
| 76 | +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; |
| 77 | + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; |
| 78 | + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; |
| 79 | + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) |
| 80 | +``` |
| 81 | + |
| 82 | +# Bar Horizontal |
| 83 | + |
| 84 | +```sql type="stack_horizontal" server="localhost:5000" |
| 85 | +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; |
| 86 | + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; |
| 87 | + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; |
| 88 | + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) |
| 89 | +``` |
| 90 | + |
| 91 | +# Line |
| 92 | + |
| 93 | +- The first string columns are used as category labels. |
| 94 | +- Whatever numeric columns appear after the strings represents a separate series in the chart. |
| 95 | + |
| 96 | +```sql type="line" server="localhost:5000" |
| 97 | +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; |
| 98 | + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; |
| 99 | + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; |
| 100 | + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) |
| 101 | +``` |
| 102 | + |
| 103 | + |
| 104 | +# Area |
| 105 | + |
| 106 | +- The first string columns are used as category labels. |
| 107 | +- Whatever numeric columns appear after the strings represents a separate series in the chart. |
| 108 | + |
| 109 | +```sql type="area" server="localhost:5000" |
| 110 | +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; |
| 111 | + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; |
| 112 | + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; |
| 113 | + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) |
| 114 | +``` |
| 115 | + |
| 116 | +# Pie |
| 117 | + |
| 118 | + - Each numeric column represents one pie chart. The title of each pie chart will be the column title. |
| 119 | + - The segments of the pie chart use the string columns as a title where possible. If there are no string columns, row numbers are used. |
| 120 | + |
| 121 | +```sql type="pie" server="localhost:5000" |
| 122 | +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; |
| 123 | + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; |
| 124 | + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; |
| 125 | + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) |
| 126 | +``` |
| 127 | + |
| 128 | +# Hierarchical |
| 129 | + |
| 130 | +## Tree |
| 131 | + |
| 132 | + - Starting from the left each string column is taken as one nesting level |
| 133 | + - The first numerical column will be taken as size. |
| 134 | + |
| 135 | +```sql type="tree" server="localhost:5000" |
| 136 | +([] Continent:`NA`Asia`Asia`Europe`Asia`Europe`Europe`SA`Europe`NA`Europe`Asia`Australia`Europe`NA; |
| 137 | + TradingBloc:`US`China`Japan`EU`India`UK`EU`Brazil`EU`US`Russia`SouthKorea`Australia`EU`US; |
| 138 | + Country:`US`China`Japan`Germany`India`UK`France`Brazil`Italy`Canada`Russia`SouthKorea`Australia`Spain`Mexico; |
| 139 | + GDP:19.485 12.238 4.872 3.693 2.651 2.638 2.583 2.054 1.944 1.647 1.578 1.531 1.323 1.314 1.151 ) |
| 140 | +``` |
| 141 | + |
| 142 | + |
| 143 | +## TreeMap |
| 144 | + |
| 145 | + - Starting from the left each string column is taken as one nesting level |
| 146 | + - The first numerical column will be taken as size. |
| 147 | + |
| 148 | +```sql type="treemap" server="localhost:5000". |
| 149 | +update exports:(0.1+9?0.1)*GDP, exportsPerCapita:(0.4+9?0.1)*GDPperCapita from |
| 150 | + ([] Country:`US`France`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; |
| 151 | + Population:(0.9+9?0.2)*313847.0 213847.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0 87840.0 ; |
| 152 | + GDP:(0.9+9?0.2)*15080.0 3333. 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ; |
| 153 | + GDPperCapita:(0.9+9?0.2)*0.001*48300.0 37000 34700.0 38100.0 36500.0 413.0 1788.0 732.0 3359.0) |
| 154 | +``` |
| 155 | + |
| 156 | + |
| 157 | +## Sankey |
| 158 | + |
| 159 | + - Assuming string columns named S1,S2,S3 with a numeric column of value V. |
| 160 | + - Each row represents one flow from the top level S1 to the leaf node S3. S1->S2->S3->V |
| 161 | + - The first numeric column reprents the size of the flow between nodes. |
| 162 | + - Sizes are back-propagated to the top level. |
| 163 | + - Null can be used to represent either gaps or allow assigning value to a node that is neither an inflow nor outflow. |
| 164 | + |
| 165 | + |
| 166 | +```sql type="sankey" server="localhost:5000" |
| 167 | +([] OrderOrigin:`Internal`GUI`Web`Platform`Internal`GUI`Web`Platform`Internal`GUI`Web`Platform; |
| 168 | + Exchange:`ICE`ICE`ICE`NYSE`NYSE`NYSE`LDN`LDN`LDN`CBE`CBE`CBE; |
| 169 | + State:12?`New`Partial`Filled`Filled`Filled`; |
| 170 | + v:12?20) |
| 171 | +``` |
| 172 | + |
| 173 | + |
| 174 | +## Sunburst |
| 175 | + |
| 176 | + - Starting from the left each string column is taken as one nesting level |
| 177 | + - The first numerical column will be taken as size. |
| 178 | + |
| 179 | + |
| 180 | +```sql type="sunburst" server="localhost:5000" |
| 181 | +([] Continent:`NA`Asia`Asia`Europe`Asia`Europe`Europe`SA`Europe`NA`Europe`Asia`Australia`Europe`NA; |
| 182 | + TradingBloc:`US`China`Japan`EU`India`UK`EU`Brazil`EU`US`Russia`SouthKorea`Australia`EU`US; |
| 183 | + Country:`US`China`Japan`Germany`India`UK`France`Brazil`Italy`Canada`Russia`SouthKorea`Australia`Spain`Mexico; |
| 184 | + GDP:19.485 12.238 4.872 3.693 2.651 2.638 2.583 2.054 1.944 1.647 1.578 1.531 1.323 1.314 1.151 ) |
| 185 | +``` |
| 186 | + |
| 187 | + |
| 188 | +## Scatter |
| 189 | + |
| 190 | + |
| 191 | + - Two or more numeric columns are required. |
| 192 | + - The values in the first column are used for the X-axis. |
| 193 | + - The values in following columns are used for the Y-axis. Each column is displayed with a separate color. |
| 194 | + |
| 195 | + |
| 196 | +```sql type="scatter" server="localhost:5000" |
| 197 | +update exports:(0.1+9?0.1)*GDP, exportsPerCapita:(0.4+9?0.1)*GDPperCapita from |
| 198 | + ([] Country:`US`France`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; |
| 199 | + Population:(0.9+9?0.2)*313847.0 213847.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0 87840.0 ; |
| 200 | + GDP:(0.9+9?0.2)*15080.0 3333. 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ; |
| 201 | + GDPperCapita:(0.9+9?0.2)*0.001*48300.0 37000 34700.0 38100.0 36500.0 413.0 1788.0 732.0 3359.0) |
| 202 | +``` |
| 203 | + |
| 204 | +## bubble |
| 205 | + |
| 206 | + - The first string columns are used as category labels. |
| 207 | + - There must then be 3 numeric columns which are used for x-coord, y-coord, size in that order. |
| 208 | + |
| 209 | +```sql type="bubble" server="localhost:5000" |
| 210 | +update exports:(0.1+9?0.1)*GDP, exportsPerCapita:(0.4+9?0.1)*GDPperCapita from |
| 211 | + ([] Country:`US`France`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; |
| 212 | + Population:(0.9+9?0.2)*313847.0 213847.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0 87840.0 ; |
| 213 | + GDP:(0.9+9?0.2)*15080.0 3333. 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ; |
| 214 | + GDPperCapita:(0.9+9?0.2)*0.001*48300.0 37000 34700.0 38100.0 36500.0 413.0 1788.0 732.0 3359.0) |
| 215 | +``` |
| 216 | + |
| 217 | +## Heatmap |
| 218 | + |
| 219 | + - Each numerical column in the table becomes one column in the chart. |
| 220 | + - The numerical values represent the shading within the chart. |
| 221 | + |
| 222 | +```sql type="heatmap" server="localhost:5000" |
| 223 | +update exports:(0.1+9?0.1)*GDP, exportsPerCapita:(0.4+9?0.1)*GDPperCapita from |
| 224 | + ([] Country:`US`France`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; |
| 225 | + Population:(0.9+9?0.2)*313847.0 213847.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0 87840.0 ; |
| 226 | + GDP:(0.9+9?0.2)*15080.0 3333. 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ; |
| 227 | + GDPperCapita:(0.9+9?0.2)*0.001*48300.0 37000 34700.0 38100.0 36500.0 413.0 1788.0 732.0 3359.0) |
| 228 | +``` |
| 229 | + |
| 230 | +## Radar |
| 231 | + |
| 232 | + - A radar chart requires 3 or more numeric columns to render sensibly. |
| 233 | + - Each numeric column represents one spoke in the radar. The column titles are used as spoke titles. |
| 234 | + - Each row in the data represents one circle withing the radar. |
| 235 | + |
| 236 | +```sql type="radar" server="localhost:5000" |
| 237 | +([] portfolio:`threadneedle`diamonte; agri:100 10; realEstate:100 10; tech:0 80; growthPotential:50 100; finance:60 20) |
| 238 | +``` |
| 239 | + |
| 240 | +## Calendar |
| 241 | + |
| 242 | + - The table should contain a date and atleast one numeric column. |
| 243 | + - The first numeric column will be used as the value for that date. |
| 244 | + - Dates should not be repeated. If they are the value selected is not guaranteed. |
| 245 | + |
| 246 | + |
| 247 | +```sql type="calendar" server="localhost:5000" |
| 248 | +([] dt:2023.12.31 - til 730; v:(asc 730?50)+(730?50)+730#90 80 72 83 40 2 3) |
| 249 | +``` |
| 250 | + |
| 251 | +## Boxplot |
| 252 | + |
| 253 | + - Each numerical column in the table becomes one boxplot item in the chart. |
| 254 | + - The min/max/median/Q1/Q3 are calculated from the raw data. |
| 255 | + - This is inefficient as a lot more data is being passed than needed but useful for toggling an existing data set view quickly. |
| 256 | + |
| 257 | +```sql type="boxplot" server="localhost:5000" |
| 258 | +([] gold:10?10; silver:til 10; crude:desc til 10; slick:13-til 10; copper:10?3; iron:10?8; diamond:4+10?8; rubber:6+10?10; lead:8+10?12) |
| 259 | +``` |
| 260 | + |
| 261 | +## Metrics |
| 262 | + |
| 263 | + - Two or more numeric columns are required. |
| 264 | + - The values in the first column are used for the X-axis. |
| 265 | + - The values in following columns are used for the Y-axis. Each column is displayed with a separate color. |
| 266 | + |
| 267 | + |
| 268 | +```sql type="metrics" server="localhost:5000" |
| 269 | +([] gold:10?10; silver:til 10; crude:desc til 10; slick:13-til 10) |
| 270 | +``` |
0 commit comments