-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.R
54 lines (51 loc) · 2.02 KB
/
server.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
source("Model/GetProbability.R")
source("Model/GetGraph.R")
library(data.table)
probabilities <- fread("Data\\overall_probabilities.csv")
betstape <- fread("Data\\InCSV\\tickdata_betstape.csv")
markets <- fread("Data\\InCSV\\tickdata_markets.csv")
selections <- fread("Data\\InCSV\\tickdata_selections.csv")
server <- function(input, output) {
event_name <- reactive(input$event_name)
event_name_deb <- debounce(event_name, 1000)
timemoment <- reactive(input$time)
timemoment_deb <- debounce(timemoment, 1000)
outcome <- reactive(input$outcome_name)
outcome_deb <- debounce(outcome, 1000)
output$table1 <- renderTable({
names <- unique(probabilities$name)
host <- probabilities[probabilities$selection=="HOST WINS", ]$probability
draw <- probabilities[probabilities$selection=="DRAW", ]$probability
guest <- probabilities[probabilities$selection=="GUEST WINS", ]$probability
probabilities_wide <- data.frame(name = names,
host_wins = host,
draw = draw,
guest_wins = guest)
probabilities_wide
})
output$table2 <- renderTable({
evt_id <- probabilities$id[probabilities$name == event_name_deb()]
selection <- -1
if (outcome_deb() == "HOST WINS") {
selection <- 1
} else if (outcome_deb() == "DRAW") {
selection <- 2
} else if (outcome_deb() == "GUEST WINS") {
selection <- 3
}
dat <- GetDataFromCSV(evt_id, betstape, markets, selections)
forecast <- GetForecast(timemoment_deb(), dat, selection, 1000, iStart = 1)
res <- data.frame(name = character(5), value = character(5), stringsAsFactors = FALSE)
res$name[1] <- "event name"
res$value[1] <- event_name_deb()
res$name[2] <- "outcome"
res$value[2] <- outcome_deb()
res$name[3] <- "estimated probability"
res$value[3] <- forecast$mu
res$name[4] <- "estimated error"
res$value[4] <- forecast$sgm
res$name[5] <- "accumulated volume"
res$value[5] <- forecast$j
res
})
}