-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadme.Rmd
101 lines (64 loc) · 2.66 KB
/
Readme.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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# fin.backend
This is a basic `R` package used in AI forecasts, which is intended to define loading functions, technical indicator calculations and rebalancing data. Its specific objective is also to calculate\
target values.
This R package is intended to be part of a trading signals application.
## Quick Guide
```{r example}
library(fin.backend)
library(future)
library(ggplot2)
plan(multisession)
dt <- data_tools.load_raw_data("CAC_40", "2022-11-11")
dt_plot <- data_tools.flat_raw_data(dt, 7, "2022-11-11", "2022-06-01")
ggplot(dt_plot[date >= "2022-06-01", .(date, close, Target)]) + geom_line(aes(x = as.Date(date), y = close)) + geom_point(aes(x = as.Date(date), y = close, color = factor(round(Target))))
plan(sequential)
```
## Data
- Historical FCHI : [Yahoo Finance](https://fr.finance.yahoo.com/quote/%5EFCHI/history?p=%5EFCHI)
- Historical InterBank exchanges rates : [Banque de France](http://webstat.banque-france.fr/fr/downloadFile.do?id=5385564&exportType=csv)
- Historical currencies rates : [Banque de France](http://webstat.banque-france.fr/fr/downloadFile.do?id=5385698&exportType=csv)
- Historical VIX : [Yahoo Finance](https://finance.yahoo.com/quote/%5EVIX/history?period1=631238400&period2=1649462400&interval=1d&filter=history&frequency=1d&includeAdjustedClose=true) CBOE Volatility Index (\^VIX)
- Other historical VIX : [CBOE](https://cdn.cboe.com/api/global/us_indices/daily_prices/VIX_History.csv)
- Historical VXD : [CBOE](https://cdn.cboe.com/api/global/us_indices/daily_prices/VXD_History.csv) DJIA Volatility
## Restricted User Guide
### Manage MongoDB
#### Clean-up (if needed)
- DB is located under `~/fin.db`
- Delete all files in `./fin.db/mongo-db/*`
- Delete log file `./fin.db/log/mongo.log`
#### Start the DB
- DB is located under `~/fin.db`
- Execute `./fin-db/mongo.sh`
### Manage R project
- R project is located under `~/fin.backend`
#### Build with RStudio
- Onglet `Build` / `More` / `Clean and Install`
```bash
Restarting R session...
* Project '~/fin.backend' loaded. [renv 0.16.0]
> library(fin.backend)
>
```
- Put the downloaded CSV data under `./fin.backend/inst/testdata/` directory
- Execute the import function `init-db.import_data()`
### Export data to CSV
```{r export}
library(fin.backend)
library(future)
library(progress)
plan(multisession)
export_csv.X_y("CAC_40", "2022-11-11", "2022-11-01", "~/fin.data/")
plan(sequential)
```