-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
173 lines (110 loc) · 2.79 KB
/
index.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
163
164
165
166
167
168
169
170
171
172
---
title: "example automated dashboard"
output:
rmdformats::downcute:
self_contained: false
default_style: "dark"
downcute_theme: "chaos"
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
## Global options
knitr::opts_chunk$set(cache = FALSE,message = FALSE, warning = FALSE)
```
<h1 id="date-diff"></h1>
```{r}
library(shiny)
library(tidyverse)
devtools::load_all()
```
```{r}
# R mixed with JS
cur_date <- Sys.time();attr(cur_date,"tzone") <- "UTC"
tags$script(shiny::HTML(glue::glue('
$(function(){{
$("#date-diff").html("Last Updated " + get_time_diff("{cur_date}") + " ago");
}});
')))
```
```{r}
macro_data <- macro_indicators %>%
dplyr::mutate(data = purrr::map(id,~tidyquant::tq_get(.,get = "economic.data",from = Sys.Date() - 20*365)))
usethis::use_data(macro_data,overwrite = TRUE)
```
# Macro Indicators
## `DISCLAIMER: Regression lines are provided for informational purposes only, fit against their 20 yr trends.`
## Rates
```{r}
macro_data %>% chart_indicators("Interest Rates")
```
## Inflation
```{r}
macro_data %>% chart_indicators("Inflation")
```
## Core Indicators
```{r}
macro_data %>% chart_indicators("Others")
```
## Employment
```{r}
macro_data %>% chart_indicators("Employment")
```
## Housing & construction
```{r}
macro_data %>% chart_indicators("Housing & construction")
```
## Retail and Consumption
```{r}
macro_data %>% chart_indicators("Retail and Consumption")
```
## Surveys
```{r}
macro_data %>% chart_indicators("Surveys")
```
## Manufacturing
```{r}
macro_data %>% chart_indicators("Manufacturing")
```
## Income
```{r}
macro_data %>% chart_indicators("Income")
```
### cap mkts
```{r}
sector_ticks %>%
gather(etf_family,ticker,-(1:2)) %>%
select(etf_family,sector,ticker,weight) %>%
mutate(prices = map(ticker,tidyquant::tq_get)) %>%
plot_index_splines()
```
```{css}
/*fix for 0 padding*/
.col-1-2, .col-6-12 {
padding: 0.5%;
}
```
```{js}
// add in last updated date
function get_time_diff( datetime ){
var datetime = new Date(datetime.replace(" ", "T") + "Z").getTime();;
var now = new Date().getTime();
var milisec_diff = now - datetime;
var msec = milisec_diff;
var hh = Math.floor(msec / 1000 / 60 / 60);
msec -= hh * 1000 * 60 * 60;
var mm = Math.floor(msec / 1000 / 60);
msec -= mm * 1000 * 60;
var ss = Math.floor(msec / 1000);
msec -= ss * 1000;
return hh + " Hours " + mm + " Minutes " + ss + " Seconds";
}
// resize highcharts to fit in main cotent area
document.addEventListener("DOMContentLoaded", function() {
$(".highchart, .highcharts-container, .highcharts-root").css("max-width","100%");
var t = setInterval(function(){
var resizeEvent = new Event('resize');
window.dispatchEvent(resizeEvent);
}, 1000);
});
```