-
Notifications
You must be signed in to change notification settings - Fork 30
/
binary-forex-trading-Q3.Rmd
162 lines (112 loc) · 10.1 KB
/
binary-forex-trading-Q3.Rmd
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
---
title: "<img src='https://raw.githubusercontent.com/englianhu/binary.com-interview-question/757b27e1e93132368b0898152078be4961b05a28/www/binary-logo-resize.jpg' width='240'>"
subtitle: "[<span style='color:blue'>binary.com</span>](https://github.com/englianhu/binary.com-interview-question) Interview Question III"
author: "[<span style='color:blue'>®γσ, Lian Hu</span>](https://englianhu.github.io/) <img src='https://raw.githubusercontent.com/englianhu/binary.com-interview-question/master/www/ENG.jpg' width='24'> <img src='https://raw.githubusercontent.com/englianhu/binary.com-interview-question/master/www/RYO.jpg?raw=true' width='24'>白戸則道®"
date: "`r Sys.Date()`"
output:
tufte::tufte_html:
toc: yes
toc_depth: 4
self_contained: no
tufte::tufte_book:
citation_package: natbib
latex_engine: xelatex
tufte::tufte_handout:
citation_package: natbib
latex_engine: xelatex
link-citations: yes
---
```{r setup, include = FALSE}
#'@ rm(list = ls(all = TRUE))
suppressPackageStartupMessages(library('BBmisc'))
pkgs <- c('knitr', 'kableExtra', 'tint', 'devtools', 'lubridate', 'data.table', 'plyr', 'stringr', 'magrittr', 'dplyr', 'tidyr', 'tidyverse', 'tidyquant', 'sparklyr', 'readr', 'quantmod', 'htmltools', 'highcharter', 'googleVis', 'formattable', 'ggfortify', 'DT', 'forecast', 'Mcomp', 'MCMCpack', 'PerformanceAnalytics', 'broom', 'microbenchmark', 'doParallel', 'engsoccerdata', 'Rmodel')
suppressAll(lib(pkgs))
#'@ install.packages(pkgs, lib = 'C:/Program Files/R/R-3.4.0/library')
## Set option to below if you want to plot an independent webpage with graph
#'@ op <- options(gvis.plot.tag=NULL)
op <- options(gvis.plot.tag = 'chart')
options(gvis.plot.tag = 'chart', warn = -1)
#'@ options(rpubs.upload.method = 'internal')
## R: llply fully reproducible results in parallel
## https://stackoverflow.com/questions/34946177/r-llply-fully-reproducible-results-in-parallel
cl <- makeCluster(detectCores())
registerDoParallel(cl)
## Create a cluster object to be used for rugarcgh and rmgarch models.
cluster = makePSOCKcluster(15)
## Connect to Spark.
#'@ spark_install()
#'@ sc <- spark_connect(master = 'local')
rm(pkgs)
```
# 1. Introduction
<center><iframe src="https://raw.githubusercontent.com/englianhu/binary.com-interview-question/ff20ee95aa60ef5cca3cf797066089103eb62acf/reference/quant-analyst-skills-test.pdf" width="600" height="900"></iframe></center>
For the question III, here I list down all possible scenario.
- **Observation 1 :** The bets on the first six games, if each team wins three, must land you at wining/losing zero (I call this winnings of 00). If this is not the case, then no bet^[Or in token of place bet $1] on the last game achieves ±100.
- **Observation 2 :** The bets on the first five games, if one team wins three of them, must land you at ±50 (+50 if team 1 wins three, −50 if team 2 wins three). Then (and only then) you can bet $50 on team 1 in game six and be assured of either immediately getting the proper result, or reaching a 3-3 tie at 00 winnings.
- **Observation 3 :** The bets on the first four games, if each team wins two, must land you at 00 (and you bet $50 on team 1 in the next game).
- **Observation 4 :** The bets on the first four games, if one team team wins three, must land you at ±75. Then you can bet $25 on team 1 and either terminate in the proper winnings or arrive at 3-2 at the proper amount ahead or behind.
- **Observation 5 :** The bets on the first three games, if one team wins two, must land you at some value that allows you to reach either ±75 or 00 depending on the outcome of the fourth game. That implies that the wager in that situation must be $37.5 and that the bets on the first three games, if one team wins two, must land you at ±37.5.
- **Observation 6 :** The bets on the first three games, if one team wins all three, must land you at some value that allows your next result to be ±100 or ±75 (see observation 4, which says in a 3-1 situation you need to be up or down by $75). The value that allows this is ±87.5 and the wager, of course, is $12.5.
- **Observation 7 :** The bets on the first two games, if each team wins one, must land you even, and at that point you will bet $37.5 (see observation 5).
- **Observation 8 :** The bets on the first two games, if one team wins both, must land you at some value that allows your next result to be ±87.5 or ±37.5, depending on the winner of game 3. Therefore, the bets on the first two games, if one team wins both, must land you at ±62.5 and you will bet $25.
- **Observation 9 :** The bet on the first game must land you mid-way between even and ±62.5. Than means the first bet must be $31.25.
So here is your strategy:
Bet $31.25 on team 1 in the first game. Then bet $31.25 on team 1 in the second game. At game three, if the teams are even, increase your bet for game three to $37.5. But if either team is up 2-0, decrease your bet to $25.
After three games, if one team has won all three you will be ahead or behind by $87.5 and you will bet $12.5 on the fourth game. But if either team is ahead 2-1, you will be ahead or behind by $37.5 and you will bet $37.5 on the fourth game.
After four games, if the series is not over, you will either be even and bet $50 on game five, or ahead or behind by $75, in which case you will bet on $25.
After five games either the series will be over, or you will be ahead or behind by $50, in which case you will bet $50 on game six.
And of course if the teams are tied after six games, then you are even as well, and you bet the full $100 on the final game.
Kindly refer to [Probability+Game Theory Problem [closed]](https://math.stackexchange.com/questions/1889792/probabilitygame-theory-problem?answertab=votes#tab-top) for further information.
Due to the betting strategy for question III has indenpent probability 50% without any edge, now we look at the soccer scores modelling and Kelly criterion betting strategy which is the best strategy for professional gamblers. Here I do not repeat the same model applicable to the English soccer leagues.
# 2. Data
Kindly refer to [Odds Modelling and Testing Inefficiency of Sports Bookmakers](https://github.com/scibrokes/odds-modelling-and-testing-inefficiency-of-sports-bookmakers) to know the English soccer dataset.
# 3. Statiscal Modelling
Kindly refer to [Odds Modelling and Testing Inefficiency of Sports Bookmakers](https://github.com/scibrokes/odds-modelling-and-testing-inefficiency-of-sports-bookmakers) for statistical modelling.
# 4. Betting Strategy
Kindly refer to [Application of Kelly Criterion model in Sportsbook Investment](https://github.com/scibrokes/kelly-criterion) to know the betting strategy applied to English soccer leagues over 2 years.
# 5. Return of Investment
Kindly refer to [Application of Kelly Criterion model in Sportsbook Investment](https://github.com/scibrokes/kelly-criterion) to know the return of investment applied to English soccer leagues over 2 years.
# 6. Conclusion
From the papers, we know that from my firstly betting strategy with $1 on every single match whith an edge of overcame the handicap, it might be win or loss depends the level of edge. In later paper I applied Kelly criterion method and get a confirmed ROI over 2 years.
```{r stopPar, echo = FALSE}
## Set options back to original options
options(op)
options(warn = 0)
stopCluster(cl)
```
# 7. Appendix
## 7.1 Documenting File Creation
It's useful to record some information about how your file was created.
- File creation date: 2015-10-08
- File latest updated date: `r Sys.Date()`
- `r R.version.string`
- R version (short form): `r getRversion()`
- [<span style='color:blue'>**rmarkdown** package</span>](https://github.com/rstudio/rmarkdown) version: `r packageVersion('rmarkdown')`
- [<span style='color:blue'>**tufte** package</span>](https://github.com/rstudio/tufte) version: `r packageVersion('tufte')`
- File version: 1.0.1
- Author Profile: [<span style='color:blue'>®γσ, Eng Lian Hu</span>](https://beta.rstudioconnect.com/englianhu/ryo-eng/)
- GitHub: [<span style='color:blue'>Source Code</span>](https://github.com/englianhu/binary.com-interview-question)
- Additional session information
```{r info, echo = FALSE, warning = FALSE, results = 'asis'}
suppressMessages(require('dplyr', quietly = TRUE))
suppressMessages(require('formattable', quietly = TRUE))
lubridate::now()
sys1 <- devtools::session_info()$platform %>% unlist %>% data.frame(Category = names(.), session_info = .)
rownames(sys1) <- NULL
sys1 %>% formattable %>% as.htmlwidget
data.frame(Sys.info()) %>% mutate(Category = rownames(.)) %>% .[2:1] %>% rename(Category = Category, Sys.info = Sys.info..) %>% formattable %>% as.htmlwidget
rm(sys1)
```
## 7.2 Reference
01. [<span style='color:blue'>Binary.com Interview Q1</span>](https://englianhu.github.io/2017/09/binary-forex-trading-Q1.html) (<span style='color:blue'>[Alternate link</span>](http://rpubs.com/englianhu/binary-forex-trading-Q1))
02. [<span style='color:blue'>Odds Modelling and Testing Inefficiency of Sports Bookmakers</span>](https://github.com/scibrokes/odds-modelling-and-testing-inefficiency-of-sports-bookmakers)
03. [<span style='color:blue'>Apply Kelly-Criterion on English Soccer 2011/12 to 2012/13</span>](https://github.com/scibrokes/kelly-criterion)
04. [<span style='color:blue'>Betting Strategy and Model Validation</span>](https://github.com/scibrokes/betting-strategy-and-model-validation)
05. [<span style='color:blue'>
Betting Strategy</span>](http://mathforum.org/library/drmath/view/62870.html)
06. [<span style='color:blue'>Probability+Game Theory Problem [closed]</span>](https://math.stackexchange.com/questions/1889792/probabilitygame-theory-problem)
07. [<span style='color:blue'>...</span>](...)
08. [<span style='color:blue'>...</span>](...)
09. [<span style='color:blue'>...</span>](...)
10. [<span style='color:blue'>...</span>](...)
**Powered by - Copyright® Intellectual Property Rights of <img src='https://raw.githubusercontent.com/englianhu/binary.com-interview-question/master/www/oda-army2.jpg?raw=true' width='24'> [<span style='color:blue'>Scibrokes®</span>](http://www.scibrokes.com)個人の経営企業**