-
Notifications
You must be signed in to change notification settings - Fork 0
/
Introduction to tidyquant.Rmd
87 lines (66 loc) · 1.84 KB
/
Introduction to tidyquant.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
---
title: "Introduction to tidyquant"
runtime: shiny
output: html_notebook
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(
echo = FALSE,
message = FALSE,
warning = FALSE
)
```
```{r}
library(tidyverse)
library(magrittr)
library(tidyquant)
```
Copied from Matt Dancho
tidyquant is a package that integrates other R package resourses for collecting and analyzing financial
data into a tidy framework.
Three packages integrated
: xts, zoo, quantmod, TTR, PerfomanceAnalytics
## tq_index()
Financial index data can be collected using `tq_index`. A list of the indexes available can
be listed with `tq_index_options()`.
```{r,include=FALSE}
index_options <- tq_index_options()
inputPanel(
selectInput("index_options", label = "tq_index_options:",
choices = index_options, selected = index_options[1])
)
```
```{r,include=FALSE}
renderDataTable({
tq_index(input$index_options)
})
```
A list of the exchanges available through `tq_exchange()` can be listed using `tq_exchange_options()`
```{r}
exchange_options <- tq_exchange_options()
inputPanel(
selectInput("exchange_options", label = "tq_exchange_options:",
choices = exchange_options, selected = exchange_options[1])
)
actionButton("list_exchange","List Selected Exchange")
```
```{r,include=TRUE}
exchange_list <-eventReactive(input$list_exchange,{
tq_exchange(input$exchange_options)
})
exchange_options <-eventReactive(input$list_exchange,{
exchange_list() %>%
select(symbol,company) %$%
structure(as.character(symbol), names = as.character(company))
})
renderDataTable({ exchange_list() })
```
```{r,include=FALSE}
renderPrint({ exchange_options() })
```
```{r,include=FALSE}
renderUI({
selectInput("exchange_index", label = "Exchange Index:",
choices = exchange_options(), selected = exchange_options()[1])
})
```