-
Notifications
You must be signed in to change notification settings - Fork 30
/
ui.R
633 lines (615 loc) · 58.9 KB
/
ui.R
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
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
## ========= Setup Options =================================
## Setup Options, Loading Required Libraries and Preparing Environment
## Loading the packages and setting adjustment
appCSS <- "
#loading-content {
position: absolute;
opacity: 0.9;
z-index: 100;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
text-align: center;
background: url(loader.gif) center no-repeat #fff;
}
"
## ================ ShinyUI ================================
# Define UI for application that draws a histogram
ui <- shinyUI(fluidPage(
shinythemes::themeSelector(), # <--- Add this somewhere in the UI
## this is your web page header information
tags$head(
## here you include your inline styles
tags$style(HTML("
body {
Text color: yellow;
background-color: darkgoldenrod;
}
"))),
#'@ tags$audio(src = 'sound.mp3', type = 'audio/mp3', autoplay = NA, controls = 'controls'),
useShinyjs(),
shinyjs::inlineCSS(appCSS),
div(id = 'loading-content'),
shinyjs::hidden(
div(id = 'app-content',
titlePanel(
tags$a(href='https://www.binary.com/ja/home.html', target='_blank',
tags$img(height = '40px', alt='hot', #align='right',
src='binary-logo-resize.jpg'))),
navbarPage('Hedge Fund',
tabPanel('Job Discription', h4('Quantitative Analyst at Binary.com'),
p('The webpage describes the requirement as well as the location and benefit of the vacancy. ',
'Due to the quantitative analyst relevant vacancy for gambling industry in Malaysia is not',
'popular and a lot of working opprtunity moreover and the location is just near to my home ',
'being Equine Park and Cyberjaya where I used to work in ', em('Telebiz SB'), ' and ',
em('Scicom (MSC) Bhd')),
br(),
htmlOutput('jobdes')),
#'@ tags$iframe(src='https://angel.co/binary-com-1/jobs/145277-quantitative-analyst',
#'@ height = 800, width = '100%', frameborder = 0)),
#, seamless = 'seamless')), #seamless will hide the scroller.
tabPanel('Interview Questionaire',
tabsetPanel(
tabPanel('Questions',
h4('Question Paper'),
p('I used to work in sportsbook industry since couple years ago and tried ,',
'to apply to join binary last year after I resigned from Scott Garden as ',
'a daily trader but due to qualification not yet meet the minimum requirement. ',
'Today I am trying to submit the application with my cv attached with few ',
'technical research and fortunately get reply from the HR which has shortlisted ',
'but request me to answer few questions to test my technical skills on actuarial ',
'and financial trading market modelling. ',
strong('I do appreciate if hired as one among the quantitative analysts and ',
'learning from all experts whom might hold with MSc or phD major in ',
'statistical and couple years experience in hedge fund industry.')),
p('I am just a newbie with couple years working experience in sportsbook industry ',
'and self learning to join the hedge fund indutry from previous baker as a punter. ',
'I like George Soros since year 1998 and used to be clients of ',
tags$a(href='http://www.starlizard.com', target='_blank',
tags$img(height = '20px', alt = 'hot', #align='right',
src = 'sl.jpg')), ' in my first job in sportsbook industry ',
'which was Telebiz AS3388/BetCitics/BetWorks who ',
'accepted billion pounds trading volume as VIP. Besides, I am analysing the bets of ',
tags$a(href='http://www.smartodds.co.uk/', target='_blank',
tags$img(height = '20px', alt = 'hot', #align='right',
src = 'so.jpg')), ' as well.'),
p('I roughly browse over the official website and get to know the binary awarded the ',
'licenses from Japan, UK and Malta.'),
tags$a(href='https://www.binary.com/ja/group-history.html', target='_blank',
tags$img(height = '100px', alt = 'hot', #align='right',
src = 'hist02.jpg')),
br(), br(),
tags$a(href='https://www.binary.com/ja/group-history.html', target='_blank',
tags$img(height = '100px', alt = 'hot', #align='right',
src = 'hist01.jpg')),
br(), br(),
tags$a(href='https://www.binary.com/ja/group-history.html', target='_blank',
tags$img(height = '100px', alt = 'hot', #align='right',
src = 'hist03.jpg')),
br(),
br(),
tags$a(href='https://angel.co/binary-com-1/jobs/145277-quantitative-analyst', target='_blank',
tags$img(height = '100px', alt = 'hot', #align='right',
src = '1st-time-job-application.jpg')),
br(),
br(),
tags$a(href='https://angel.co/binary-com-1/jobs/145277-quantitative-analyst', target='_blank',
tags$img(height = '100px', alt = 'hot', #align='right',
src = '2nd-time-job-application-a.jpg')),
br(),
br(),
tags$a(href='https://angel.co/binary-com-1/jobs/145277-quantitative-analyst', target='_blank',
tags$img(height = '100px', alt = 'hot', #align='right',
src = '2nd-time-job-application-b.jpg')),
br(),
br(),
p('You are feel free to read the questions below and answer tabs with an application.'),
br(),
HTML('<iframe src=\"https://raw.githubusercontent.com/englianhu/binary.com-interview-question/ff20ee95aa60ef5cca3cf797066089103eb62acf/reference/quant-analyst-skills-test.pdf" width=\"900\" height=\"600\"></iframe>'),
imageOutput('imp_pdf', width = '100%')), #, height = '500px')),
tabPanel('Q1',
tabsetPanel(
tabPanel('Question',
h4('Answer the Question'),
p('Find a formula to price the following fixed-odds contract:'),
br(),
p('I wish to win $', em('B'), ' if over the next days, ',
em('i'),' the ', em('y'),' has a high-low range ',
'[exceeding/not exceeding] ', em('p'), ' points.'),
p('Implement the solution in the programming language of your choice.'),
p('Example: I wish to win $1000 if over the next 7 days the USD/JPY has ',
'a high-low range exceeding 2 points.'),
p('For example, if the USD/JPY has a range of low=98.45 and high=100.98 ',
'over the next 7 days, I will win $1000 (because high minus ',
'low = 2.53 > 2).'),
p('You can use Monte Carlo simulation to confirm/verify your results, ',
'but it shouldn\'t be the primary solution. Please provide all the relevant ',
'details about the solution.')),
tabPanel('Answer (Font-End)',
sidebarLayout(
sidebarPanel(
bsCollapse(id = 'selectSIFund', open = 'Select Fund',
bsCollapsePanel('Select Latest Data Date and Predict Date',
#'@ dateRangeInput('dataRange', label = 'Data Range',
#'@ start = first(dateRange), end = last(dateRange)),
dateInput('dataDate', value = today() - 1, label = 'Last Data Date'),
dateInput('preDate', value = today(), label = 'Predict Date'),
#'@ selectInput('BackLay', value = 'lay', label = 'Back/Lay',
#'@ choices = c('Back', 'Lay')),
#'@ selectInput('staking', value = 'optKelly', label = 'Staking model',
#'@ choices = c('optKelly', 'optimalF')),
sliderInput('stakes', value = 10000, label = 'Stakes Leverage',
min = 100, max = 1000000, step = 10,
pre = '¥', animate = TRUE),
actionButton('updatePred', label = 'Update'),
actionButton('tabBut', 'View Table'), style = 'primary'),
bsCollapsePanel('Chart Option',
selectInput('type', label = 'Type', width = '100%',
choices = c(FALSE, 'line', 'column', 'spline', 'bar', 'pie'),
selected = 'line'),
selectInput('stacked', label = 'Stacked', width = '100%',
choices = c(FALSE, "normal", "percent"),
selected = 'normal'),
selectInput('hc_theme', label = 'Theme', width = '100%',
choices = c('theme' = 'hc_theme()', '538' = 'hc_theme_538()',
'chalk' = 'hc_theme_chalk()',
'darkunica' = 'hc_theme_darkunica()',
'db' = 'hc_theme_db()',
'economist' = 'hc_theme_economist()',
'flat' = 'hc_theme_flat()',
'flatdark' = 'hc_theme_flatdark()',
'ft' = 'hc_theme_ft()',
'google' = 'hc_theme_google()',
'gridlight' = 'hc_theme_gridlight()',
'handdrwran' = 'hc_theme_handdrawn()',
'merge' = 'hc_theme_merge()',
'null' = 'hc_theme_null()',
'sandsignika' = 'hc_theme_sandsignika()',
'smpl' = 'hc_theme_smpl()',
'sparkline' = 'hc_theme_sparkline()'),
selected = 'hc_theme_economist()'), style = 'primary')),
br(),
a(id = 'toggleAdvanced', 'Show/hide advanced info', href = '#'),
hidden(
div(id = 'advanced',
p('- Author Profile:', HTML("<a href='https://englianhu.github.io/2016/12/ryo-eng.html'>RYO, ENG Lian Hu</a>")),
p('- GitHub:', HTML("<a href='https://github.com/englianhu/binary.com-interview-question'>Source Code</a>")),
br(),
p('Timestamp: ',
span(id = 'time', base::date()),
a(id = 'update', 'Update', href = '#')),
actionButton('reset', 'Reset form'), style = 'info'))),
mainPanel(
h4('Prediction Price'),
p(tags$a(href = 'https://www.ladbrokescoralplc.com/', target = '_blank',
tags$img(height = '40px', alt = 'hot', #align='right',
src = 'LC.jpg')), ' (Corrected with ',
tags$a(href = 'http://www.lithia.com/', target = '_blank',
tags$img(height = '40px', alt = 'hot', #align='right',
src = 'lithia.jpg')), ')'),
br(),
h4('1. Forecast'),
p('The graph below forecast the stock price. You are feel free to select a predict date from the sidebar.'),
br(),
br(),
p('The graph showing the predicted stock price with closing price of stock counter ',
strong('LAD'), '. You are feel free to select the data date from the sidebar panel.'),
br(),
#'@ highchartOutput("hcontainer", height = "500px"),
highchartOutput("hcmp", height = "500px"),
bsModal("modalExample", "Data Table", "tabBut", size = "large",
dataTableOutput('distTable')),
br(),
br(),
h4('2. Betting Strategy'),
p('Next bet will be $xxxx on xxxx-xx-xx.'),
br(),
br(),
h4('3. Profit and Loss Statement'),
p('You can view the statement as below :'),
br(),
br(),
h4('Miscellaneous'),
p('Since I am taking sportsbook company as a sample for analysis. Here I introduced few affiliates partners ',
'and below are some among our business partners. ',
'You are feel free to join as an affiliate with below client/partner companies.',
tags$ul(
tags$li(tags$a(href='http://www.bwinpartypartners.com/index.do?masterben=ryusukekenji', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='BW_Aff.jpg')),
HTML("<a href='http://www.bwinpartypartners.com/index.do?masterben=ryusukekenji'>bWin.Party Partners</a>"),
tags$a(href='http://www.bwinpartypartners.com/index.do?masterben=ryusukekenji', target='_blank',
tags$img(height = '80px', alt='hot', #align='right',
src='BW_Aff_Dashboard_Sample.jpg'))),
tags$li(tags$a(href='https://portal.ladbrokespartners.com/portal/#/registration?referrer=ryusukekenji', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='LB_Aff.jpg')),
HTML("<a href='https://portal.ladbrokespartners.com/portal/#/registration?referrer=ryusukekenji'>Ladbrokes Partners</a>"),
tags$a(href='https://portal.ladbrokespartners.com/portal/#/registration?referrer=ryusukekenji', target='_blank',
tags$img(height = '80px', alt='hot', #align='right',
src='LB_Aff_Dashboard_Sample.jpg'))),
tags$li(tags$a(href='http://account.affiliates.williamhill.com/signup.html?a=1598928', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='WH_Aff.jpg')),
HTML("<a href='http://account.affiliates.williamhill.com/signup.html?a=1598928'>Affiliates William Hill</a>"),
tags$a(href='http://account.affiliates.williamhill.com/signup.html?a=1598928', target='_blank',
tags$img(height = '80px', alt = 'hot', #align='right',
src='WH_Aff_Dashboard_Sample.jpg'))),
tags$li(tags$a(href='http://affiliates.188bet.com/login.asp', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='188_Aff.jpg')),
HTML("<a href='http://affiliates.188bet.com/login.asp'>Affiliates 188BET</a>"),
tags$a(href='http://affiliates.188bet.com/login.asp', target='_blank',
tags$img(height = '80px', alt = 'hot', #align='right',
src='188_Aff_Dashboard_Sample.jpg'))),
tags$li(tags$a(href='https://mmwebhandler.aff-online.com/c/31469?sr=1102017', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='888_Aff.jpg')),
HTML("<a href='https://mmwebhandler.aff-online.com/c/31469?sr=1102017'>Affiliates 888</a>"),
tags$a(href='https://mmwebhandler.aff-online.com/c/31469?sr=1102017', target='_blank',
tags$img(height = '80px', alt = 'hot', #align='right',
src='888_Aff_Dashboard_Sample.jpg'))),
tags$li(tags$a(href='https://www.betvictor.com', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='VC_Aff.jpg')),
HTML("<a href='https://www.betvictor.com'>Affiliates VCBet</a>"),
tags$a(href='https://www.betvictor.com', target='_blank',
tags$img(height = '80px', alt = 'hot', #align='right',
src='VC_Aff_Dashboard_Sample.jpg'))))),
p('I have conducting few research and development in sportsbook betting and learning Western since year ',
'2007 I resigned from ',
tags$a(href='http://www.hg0088.com', target = '_blank',
tags$img(height = '20px', alt = 'hot', #align='right',
src = 'caspo.jpg')),'.')))),
tabPanel('Answer (Back-End)',
h4('Observation'),
p(tags$a(href = 'https://www.ladbrokescoralplc.com/', target = '_blank',
tags$img(height = '40px', alt = 'hot', #align='right',
src = 'LC.jpg')), ' (Corrected with ',
tags$a(href = 'http://www.lithia.com/', target = '_blank',
tags$img(height = '40px', alt = 'hot', #align='right',
src = 'lithia.jpg')), ')'),
br(),
p('I used to work in ', tags$a(href='http://www.scicom-intl.com/', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='scicom.jpg')),
' with ', tags$a(href='http://www.ladbrokes.com/home/en', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='ladbrokes.jpg')),
' Far East Asia project as customer service executive for couple years. ',
'Here I took the client company as my analysis for this job interview. ',
'In order to predict the LGL (stock price of ',
HTML("<a href='https://www.ladbrokescoralplc.com/'>LadbrokesCoral PLC</a>"),
'), I get the real-time stock price from ',
strong('Yahoo'), ' (Corrected with : ',
tags$a(href = 'http://www.lithia.com/', target = '_blank',
tags$img(height = '20px', alt = 'hot', #align='right',
src = 'lithia.jpg')), ' ',
HTML("<a href='http://www.lithia.com/'>LAD</a>"),
'). Below is a chart trend of LAD stock price from ',
textOutput('firstday', inline = TRUE), ' onwards. (sample data)'),
#'@ highchartOutput("hcontainer", height = "500px"),
p(tags$a(href='http://www.lithia.com/', target='_blank',
tags$img(height = '500px', alt='hot', #align='right',
src='LAD_Price.jpg'))),
br(),
br(),
h4('1. Stock Price Modelling'),
p('Here I refer to papers in subtab ', strong('Reference') , ' under tab ',
strong('Appendix'), 'inside ', strong('MENU'),
' bar for stock price prediction as well as the investment fund management. ',
'You are feel free to read few articles as below for understanding the LASSO ',
'model (if any).',
tags$ul(
tags$li(HTML("<a href='http://statweb.stanford.edu/~tibs/lasso/simple.html'>A simple explanation of the Lasso and Least Angle Regression</a>")),
tags$li(HTML("<a href='http://cos.name/2016/10/data-mining-1-lasso/'>Popular model for data mining (Part I) : Lasso Regression (Chinese)</a>")),
tags$li(HTML("<a href='http://www4.stat.ncsu.edu/~post/josh/LASSO_Ridge_Elastic_Net_-_Examples.html'>LASSO, Ridge, and Elastic Net</a>")))),
p('DATA :', 'The dataset gather from 2015-01-01 until the latest trading day ',
'(unless unable connect to Yahoo and read local saved dataset until 2017-01-20.)',
'Here I simply apply regression models from Ridge, Elastic Net to Lasso as below :',
withMathJax(helpText('$$Y=\\sum_{j=1}^dX_j\\beta_j+e \\cdots equation\\ 1.1.1$$')), 'Where',
tags$ul(
tags$li(em('d'), ' is dimension of matrix Xj'),
tags$li(em('Xo'), ' is baseline'),
tags$li('A cost function for residuals measurement')
), 'to make above equation valid.'),
p('I dont\'t pretend to know the corrected model, the paper',
em('Sanjiban Sekhar Roy, Dishant Mittal, Avik Basu, and Ajith Abraham (2011)'),
'using a linear model (gaussian model) with above criteria but here I test ',
'couples of models (includes 4 models which are \'gaussian\', \'poisson (log link)\', ',
'\'binomial (logit link)\' and \'multinomial (nominal response)\' but skip 2 ',
'models which are \'cox\' and \'mgaussian\'.) from ', code('glmnet'), ' package to compare ',
'among them and get the best fit.'),
p('Besides, I also apply ', code('caret'), ' package to do the comparison as well. ',
'You are feel free to read through below reference or more over the ',
strong('Reference'), ' tab : ',
tags$ul(
tags$li(HTML("<a href='http://topepo.github.io/caret/index.html'>The caret Package</a>")),
tags$li(HTML("<a href='https://rpubs.com/crossxwill/time-series-cv'>Time Series Cross Validation</a>")))),
p('Due to the stock price flutuation, here I try to use different price as my respondent Y value',
tags$ul(
tags$li('1. Open price of first day from the dataset as my baseline b0. ',
'(long and wide format, Opening price of dimension X0 to Xj as intercept)'),
tags$li('2. Closing price. (long and wide format, Opening price of dimension X0 ',
'to Xj as intercept, the Xj I excludes the Closing price column)'),
tags$li('3. Closing price. (long and wide format, Opening price of dimension X0 ',
'to Xj as intercept, the Xj I includes the Closing price column)'),
tags$li('4. Daily mean price 1. (long and wide format, Opening price of dimension ',
'X0 to Xj as intercept, daily Open-Close price average)'),
tags$li('5. Daily mean price 2. (long and wide format, Opening price of dimension ',
'X0 to Xj as intercept, daily High-Low price average)'),
tags$li('6. Daily mean price 3. (long and wide format, Opening price of dimension ',
'X0 to Xj as intercept, daily Open-High-Low-Close price average)'),
tags$li('7. Mixed price 1. (long and wide format, Opening price of dimension X0 ',
'to Xj as intercept, daily Open-Close price average multiply by b0)'),
tags$li('8. Mixed price 2. (long and wide format, Opening price of dimension X0 ',
'to Xj as intercept, daily High-Low price average multiply by b0)'),
tags$li('9. Mixed price 3. (long and wide format, Opening price of dimension X0 ',
'to Xj as intercept, daily Open-High-Low-Close price average multiply by b0)')),
'Remarks : Not yet test baseline stock price multiply by the coefficient of binomial ',
'and multinomial models, as well as review my poisson model.'),
tagList(
tags$div(align = "center",
class = "bg-info",
tags$h3(class = "bg-primary", "Mean-Squared Error Summary"),
tags$h5(align = "center", class = "text-muted",
"Table Summary of Gaussian Models (Sample)")), dataTableOutput('gsmse')),
htmlOutput('gsform'),
formattableOutput('gsmse1'),
#'@ tagList(
#'@ tags$div(align = "center",
#'@ class = "bg-info",
#'@ tags$h3(class = "bg-primary", "Testing models"),
#'@ tags$h5(align = "center", class = "text-muted",
#'@ "Fitted Value (Sample)")), dataTableOutput('testTable')),
p('Due to I checked above models and all same (with different ', code('pred.type'),
' or ', code('measure.type') , '). Here I randomly pick one to compare from Ridge ',
'to Lasso (0, 0.1, 0.2... 1.0, where Ridge < Elastic Net < Lasso). Above models shows ',
'get the from 2015-01-01 until 2017-01-20.'),
p('Well, here we know the profit and loss from our basic model which is taking 365 days',
'(remarks : for leap years will also be monthly based. For example, in order to predict ',
'the price of 2016-02-29, the dataset from 2015-02-28 until 2016-02-28).'),
p('Here I tried to simulate the MCMC with selecting a 365 days dataset to test the best ',
'model to compare from Ridge to Lasso (0, 0.1, 0.2... 1.0).'),
p('Remarks : From my research, different size of observation, order of the date or ',
'maximum iteration will come out with different result as well.'),
br(),
br(),
h4('2. Weighted Model'),
p('For the weight models, I tried to refer to ',
HTML("<a href='https://github.com/scibrokes/betting-strategy-and-model-validation/blob/master/references/Creating%20a%20Profitable%20Betting%20Strategy%20for%20Football%20by%20Using%20Statistical%20Modelling.pdf'>Creating a Profitable Betting Strategy for Football by Using Statistical Modelling</a>"),
' to build a ', em('half normal distribution'), ' and also original ', em('normal distribution'), 'decay function from ',
em('Dixon & Coles 1997'), ' to do a comparison to get the weighted parameters for all 224 models.'),
p(withMathJax(helpText('$$\\phi (t) = exp(-\\xi t) \\cdots equation\\ 1.2.1$$')),
withMathJax(helpText('$$\\phi (t) = exp(-\\xi (t - t_{0})^2) \\cdots equation\\ 1.2.2$$')),
' and get to know the weighted parameters around -0.69 and 0 for half normal distribution due to the stock price is going on ',
'every weekdays compare to the sports soccer teams. Therefore no defferent with ', code('ξ'), ' but with the different of days.'),
br(),
br(),
h4('3. Prediction'),
p('sample graph for comparison of predicted price from alpha 0, 0.1, 0.2... 1. ',
'You can simply using ', code('predict'), ' function and set a ', code('newx') ,
' will do.'),
#'@ highchartOutput("hcmp", height = "500px"),
p(tags$a(href='https://www.ladbrokescoralplc.com/', target='_blank',
tags$img(height = '500px', alt='hot', #align='right',
src='LAD_Cmp.jpg'))),
br(),
br(),
h4('4. Staking Model'),
p('I am currently conducting research on betting strategy. You are feel free to ',
' browse over my researchs.',
tags$ul(
tags$li(HTML("<a href='https://github.com/scibrokes/betting-strategy-and-model-validation'>Betting Strategy and Model Validation</a>")),
tags$li(HTML("<a href='https://github.com/scibrokes/kelly-criterion'>Application of Kelly Criterion model in Sportsbook Investment</a>")),
tags$li(HTML("<a href='https://github.com/scibrokes/analyse-the-finance-and-stock-price-of-bookmakers'>Analyse the Finance and stock Price of Bookmakers</a>")))),
p('The formula of Kelly as below :',
withMathJax(helpText('$$B=W+\\frac{W-1}{P} \\cdots equation\\ 1.4.1$$')), 'Where',
tags$ul(
tags$li(em('B'), ' = Bet Size'),
tags$li(em('W'), ' = Winning Percentage'),
tags$li(em('P'), ' = Payout'))),
p('Kelly Criterion and Optimal f are very similar models for geometric growth ',
'optimization. Ralph Vince’s article ',
em('Optimal f and the Kelly Criterion'),
' has explained their differences in detail and here are main takeaways.',
tags$ul(
tags$li(em('Kelly Criterion'), ' does not yield the optimal fraction to risk in trading, Optimal f does'),
tags$li(em('Kelly Criterion'), ' only generates a leverage factor which could go infinitely large; Optimal f is bounded between 0 and 1'),
tags$li('The reconciliation between two models could be written as Optimal f = Kelly * (-W/Px), where W is the possible maximum loss on each trade, Px is the price per share. Both are in dollar amount')),
'Inspired by Ralph\'s article, ', HTML("<a href='https://alphaism.wordpress.com/author/alphaism/'>Roy Wei</a>"),
' did a test in R to compare these two models. Considering a 50/50 coin flipping ',
'game that pays $2 on heads and -$0.5 on tails for every $1 you bet. Through optimizing Kelly’s objective function',
withMathJax(helpText('$$\\sum_{i=1}^{n}(\\ln(1+R_i*f)*P_i) \\cdots equation\\ 1.3.2$$')),
'we should get optimal f = 0.75. While Optimal f, with objective function',
withMathJax(helpText('$$\\prod_{i=1}^{n}(1+f*(Px_i/-W))^{P_i} \\cdots equation\\ 1.3.3$$')),
'will give a different optimal f = 0.375. Let’s see if they can be consistent with observations in R.'),
p('You are feel free to read the article in ', strong('Reference'), ' named ',
HTML("<a href='https://alphaism.wordpress.com/2012/04/13/testing-kelly-criterion-and-optimal-f-in-r/'>Testing Kelly Criterion and Optimal f in R</a>"),
' for further understanding.'),
p('However, there has another concern which is the stock price fluctuation from opened ',
'market until closed market. How do we determine the best time to buy and sell? From ',
strong('1. Stock Price Modelling'), ' I tried to test and the mean price of daily ',
'High-Low price will be best fit as Y (since High-Low is the variance). ',
'Then I use the daily closing price as settlement price in Ti where T is the timeline from T0 ',
'(same theory if we set the time range to 5 minutes, 1 hours etc. In order to know the best size ',
'of dataset to predict the accurate highest or lowest price and buy/sell to close the ',
'transaction at largest gap to maximzie the profit. Thats why the RSI200 is not RSI199 or RSI201).'),
br(),
br(),
h4('5. Profit & Loss'),
p('In progress...'),
br(),
br(),
hr('6. MCMC'),
p(''),
p('In progress...'),
br(),
br(),
hr('7. Future Works'),
p('For MCMC, how do we maximize our profit and minimize our loss? Here I refer to few articles ',
'which regards RSI (Relative Strength Index) and SMA (Simple Moving Average).',
tags$ul(
tags$li(HTML("<a href='http://www.investopedia.com/university/technical/techanalysis9.asp'>Technical Analysis: Moving Averages</a>")),
tags$li(HTML("<a href='http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:relative_strength_index_rsi'>Relative Strength Index (RSI)</a>"))),
'Above articles brief the formula of RSI 14 days and SMA 50, 100, 200 days. ',
'Again, I don\'t pretend to know the true data size and the weighted parameters, ',
'here I try to apply the MCMC (Markov Chain Monte Carlo) based on 365 days data size to get ',
'the optimal return from investment. ', strong('LAD'), ' just a sample among the thousands of ',
'stock counters. The stock market but the currency only few counters. Moreover the stock ',
'price from google showing the price for splited shares only a marking/indicator inside the ',
'graoh but the stock price is same. (Besides, I\'ve just noticed the position only trde on ',
'forex but no equity while initially I noticed the official website trade the stock counter as well.)',
tags$ul(
tags$li(HTML("<a href='http://www.investopedia.com/articles/stocks/05/062905.asp'>Understanding Rights Issues</a>")),
tags$li(HTML("<a href='http://www.investopedia.com/terms/b/bonusissue.asp'>Bonus Issue</a>"))),
'Therefore the forex market will be main compare to stock market. I will refer to ',
HTML("<a href='https://github.com/englianhu/SIT'>Systematic Investor Toolkit</a>"),
'. You are feel free to browse over below link :',
tags$ul(
tags$li(HTML("<a href='https://github.com/scibrokes/financial-betting'>Financial Betting</a>")),
tags$li(HTML("<a href='https://github.com/scibrokes/analyse-the-finance-and-stocks-price-of-bookmakers'>Analyse the Finance and Stocks Price of Bookmakers</a>")))),
p('The investment fund portfolio management will need to refer to my current research with ',
'regards betting strategy via my ', strong('CV') , '.')))),
tabPanel('Q2',
tabsetPanel(
tabPanel('Question',
h4('Answer the Question'),
p('Simulate the following situation. Attach the code as part of your submission.'),
br(),
p('At a post office, customers enter a single line waiting to be served by any one of two clerks.
Every minute there is a 60% chance that a new customer arrives. If there is no one in line and a
server is free, the customer does not wait to be served. When a customer is being served there
is a 25% chance every minute that they complete their business and leave. When the clerk is free
he will take the next customer in line, in the order that they arrived. Every minute, there is a
5% chance that a person standing in line will give up and leave. The post office is always open
(24/7/365).'),
p('Note: For simplicity you can assume customers will always arrive at the beginning of the minute
and if they leave they do so at the end of the minute.'),
br(),
p(strong('a)'), ' What is the average amount of time a customer spends in the post office (including those not
served)?'),
br(),
p(strong('b)'), ' What percentage of customers leave without being served?'),
br(),
p(strong('c)'), ' What percentage of time are the clerks idle?')),
tabPanel('Answer',
p('')))),
tabPanel('Q3',
tabsetPanel(
tabPanel('Question',
h4('Answer the Question'),
p('Sports teams "A" and "B" are to play each other until one has four wins and is declared the series
winner. You have $100 to bet on Team A to win the series. You are, however, only allowed to bet on
individual games, not the final outcome directly, and you must bet a positive amount on each game.
So, if Team A wins the series, you must walk away with $200, but if Team A loses the series, you
must walk away with zero, and you must do so having placed a non-zero bet on every game. How do you
place your bets?')),
tabPanel('Answer',
p('In progress...')))))),
tabPanel('Appendix',
tabsetPanel(
tabPanel('Speech',
h4('Speech & Blooper'),
br(),
h4('Question 1'),
p('The question ask for analyse the ', em('JPY/USD'), ' but I didn\'t notice the job description states ',
em('No Equity'), ' and I noted from the binary official website states that their products include stock counter ',
'as well. Intially I tried to ', code('getSymbols'), ' the ', code('AAPL'), ' because my ex-classmate\'s ',
'nickname is APPLE but due to noticed the split shares and stock price divided based on the portion. There will ',
'be no history data to predict the effects/factors of splitted stock price. Then I think of I worked betting ',
'industry and currently conducting research project ',
HTML("<a href='https://github.com/scibrokes/analyse-the-finance-and-stocks-price-of-bookmakers'>Analyse the Finance and Stocks Price of Bookmakers</a>"),
'. I initially testing Gaussian, poison, logistics and multinomial models. Due to I checked models and noted that ',
'the logit and multinomial models all need to use the baseline since it only get the coefficients in portion figures ',
'and it will consume quite a long time for all more than 10000 models per day. After that I checking the outcome ',
'and just choose the Gaussian as the model I stated as my reference. I didn\'t compare but then checking with the ',
'different ', code('pred.type'), ' and different ', code('measure.type') , ' of the models and noticed the same result ',
'and after that reduced the selection to be 224 models per day from more than 10000 models per day. Here I randomly ',
'pick one to compare from Ridge to Lasso (0, 0.1, 0.2... 1.0). Above models all get the same result which is ',
'alpha 0.8. from 2015-01-01 until 2017-01-18.',
' but didn\'t notice that the merged company stock counter changed to ', code('LGL'), ' but no longer ',
code('LAD'), ' after I rest 2 days from eve of Chinese New Year 2017 to 1st day of Chinese New Year 2017. ',
'Then I just marked the correction since I ran the time series model for 224 models to test the independent ',
'and dependent variables as well from 2015-01-01 to 2017-01-20.'),
p('I tried to refer some articles as well for the coding and mostly from ,',
tags$a(href='http://stackoverflow.com', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='stackoverflow.jpg')), '. Below are some among the coding I learnt from below to avoid some error : ',
tags$ul(
tags$li(HTML("<a href='http://stackoverflow.com/questions/13446256/meaning-of-tilde-dot-argument?answertab=votes#tab-top'>Meaning of ~. (tilde dot) argument?</a>")),
tags$li(HTML("<a href='http://stats.stackexchange.com/questions/10712/what-is-the-meaning-of-the-dot-in-r?answertab=votes#tab-top'>What is the meaning of the \".\" (dot) in R?</a>")),
tags$li(HTML("<a href='http://stackoverflow.com/questions/7526467/what-does-the-dot-mean-in-r-personal-preference-naming-convention-or-more?answertab=votes#tab-top'>What does the dot mean in R - personal preference, naming convention or more?</a>")),
tags$li(HTML("<a href='http://adv-r.had.co.nz'>Advanced R</a>"))),
' and then I filtered the models with the formula ', code('xy.matrix'), ' argument inside function ',
code('glmPrice()'), ' to checked if the duplicated arguments and filter to be unique formula.'),
p('There are a lot of anonymous errors or unmatched outcome when I test my function and models, ',
'you are feel free to read the files named ', code('draft'), code('draft2'), '.'),
br(),
HTML('<iframe width="560" height="315" src="https://www.youtube.com/embed/Utbs2EgRMIE" frameborder="0" allowfullscreen></iframe>'),
br(),
HTML('<iframe width="560" height="315" src="https://www.youtube.com/embed/2igEZxPFz38" frameborder="0" allowfullscreen></iframe>'),
br(),
br(),
h4('Question 2'),
br(),
br(),
h4('Question 3'),
br(),
br()),
tabPanel('Reference',
h4('Reference'),
p('01. ', HTML("<a href='https://github.com/englianhu/binary.com-interview-question/blob/master/reference/Stock%20Market%20Forecasting%20Using%20LASSO%20Linear%20Regression%20Model.pdf'>Stock Market Forecasting Using LASSO Linear Regression Model</a>"),
tags$a(href='https://github.com/scibrokes/owner', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='hot.jpg'))),
p('02. ', HTML("<a href='http://stats.stackexchange.com/questions/58531/using-lasso-from-lars-or-glmnet-package-in-r-for-variable-selection?answertab=votes#tab-top'>Using LASSO from lars (or glmnet) package in R for variable selection</a>")),
p('03. ', HTML("<a href='http://stackoverflow.com/questions/29311323/difference-between-glmnet-and-cv-glmnet-in-r?answertab=votes#tab-top'>Difference between glmnet() and cv.glmnet() in R?</a>")),
p('04. ', HTML("<a href='https://alphaism.wordpress.com/2012/04/13/testing-kelly-criterion-and-optimal-f-in-r/'>Testing Kelly Criterion and Optimal f in R</a>"),
tags$a(href='https://github.com/scibrokes/owner', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='hot.jpg'))),
p('05. ', HTML("<a href='https://github.com/scibrokes/kelly-criterion/blob/master/references/Portfolio%20Optimization%20and%20Monte%20Carlo%20Simulation.pdf'>Portfolio Optimization and Monte Carlo Simulation</a>"),
tags$a(href='https://github.com/scibrokes/owner', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='hot.jpg'))),
p('06. ', HTML("<a href='https://web.stanford.edu/~hastie/glmnet/glmnet_alpha.html'>Glmnet Vignette</a>")),
p('07. ', HTML("<a href='http://cos.name/cn/topic/101533/#post-418215'>How to implement Lasso Algorithm? (Chinese Version)</a>")),
p('08. ', HTML("<a href='http://amunategui.github.io/sparse-matrix-glmnet/'>The Sparse Matrix and {glmnet}</a>")),
p('09. ', HTML("<a href='https://github.com/englianhu/binary.com-interview-question/blob/master/reference/Regularization%20and%20Variable%20Selection%20via%20the%20Elastic%20Net.pdf'>Regularization and Variable Selection via the Elastic Net</a>")),
p('10. ', HTML("<a href='http://www4.stat.ncsu.edu/~post/josh/LASSO_Ridge_Elastic_Net_-_Examples.html'>LASSO, Ridge, and Elastic Net</a>"),
tags$a(href='https://github.com/scibrokes/owner', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='hot.jpg'))),
p('11. ', HTML("<a href='https://web.stanford.edu/~hastie/glmnet/glmnet_alpha.html'>Popular Data Mining Models for Beginner(1) (Chinese Version)</a>")),
p('12. ', HTML("<a href='http://statweb.stanford.edu/~tibs/lasso.html'>The Lasso Page</a>")),
p('13. ', HTML("<a href='https://api.rpubs.com/Mariano/call'>Call_Valuation.R</a>")),
p('14. ', HTML("<a href='http://zorro-trader.com/manual/en/Lecture%206.htm'>Lecture 6 - Stochastic Processes and Monte Carlo</a>")),
p('15. ', HTML("<a href='http://topepo.github.io/caret/index.html'>The `caret` Package</a>"),
tags$a(href='https://github.com/scibrokes/owner', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='hot.jpg'))),
p('16. ', HTML("<a href='https://rpubs.com/crossxwill/time-series-cv'>Time Series Cross Validation</a>"),
tags$a(href='https://github.com/scibrokes/owner', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='hot.jpg'))),
p('17. ', HTML("<a href='http://character-code.com/'>Character-Code.com</a>")),
p('18. ', HTML("<a href='https://alphaism.wordpress.com/2012/03/26/size-matters-kelly-optimization/'>Size Matters - Kelly Optimization</a>"),
tags$a(href='https://github.com/scibrokes/owner', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='hot.jpg'))),
p('19. ', HTML("<a href='https://zhuanlan.zhihu.com/p/42122611'>Statistical Learning:Paramters Selection for Lasso (Chinese Version)</a>"),
tags$a(href='https://github.com/scibrokes/owner', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='hot.jpg')))),
tabPanel('Applicant',
h4('Applicant\'s CV'),
tags$iframe(src = 'https://englianhu.github.io/2016/12/ryo-eng.html', height = 800, width = '100%', frameborder = 0))))))),
br(),
p('Powered by - Copyright® Intellectual Property Rights of ',
tags$a(href='http://www.scibrokes.com', target='_blank',
tags$img(height = '20px', alt='hot', #align='right',
src='https://raw.githubusercontent.com/scibrokes/betting-strategy-and-model-validation/master/regressionApps/oda-army.jpg')),
HTML("<a href='http://www.scibrokes.com'>Scibrokes®</a>"))))