Leemos los datos de FCI 1826 - Valores Negociables de Banco Provincia
library(dplyr) #para manipulación de datos
##
## Adjuntando el paquete: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyr) #para manipulación de datos
library(readxl) #leer los datos
library(ggplot2) #para gráficos
library(flextable)
library(lubridate)
##
## Adjuntando el paquete: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
Tomamos los datos de movimiento de suscripción y rescate de información
df = read_excel("20082024_1822_movimientos.xlsx", skip = 1)
Luego tomamos el comportamiento de la variable (VN)
df_fci = read_excel("Provincia Fondos - Sociedad Gerente de Fondos Comunes de Inversión del Grupo Provincia.xlsx")
transacciones = df %>%
filter(Descripción == "Suscripción Cuotas P")
transacciones = transacciones %>%
rename(Fecha_Movimiento = 'Fecha Movimiento')
Si tenemos fechas repetidas las agrupamos para tener los fondos por día.
transacciones_agrupadas = transacciones %>%
group_by(Fecha_Movimiento, Descripción) %>%
summarise(
Credito = sum(Crédito, na.rm = TRUE),
Debito = sum(Débito, na.rm = TRUE),
Saldo = sum(Saldo, na.rm = TRUE)
) %>%
ungroup() #quito el agrupamiento
## `summarise()` has grouped output by 'Fecha_Movimiento'. You can override using
## the `.groups` argument.
Configuramos las fechas
transacciones_agrupadas = transacciones_agrupadas %>%
mutate(Fecha_Movimiento = as.Date(Fecha_Movimiento, format = "%d/%m/%Y"))
str(transacciones_agrupadas)
## tibble [7 × 5] (S3: tbl_df/tbl/data.frame)
## $ Fecha_Movimiento: Date[1:7], format: "2023-08-03" "2023-09-05" ...
## $ Descripción : chr [1:7] "Suscripción Cuotas P" "Suscripción Cuotas P" "Suscripción Cuotas P" "Suscripción Cuotas P" ...
## $ Credito : num [1:7] 67.05 16.55 31.42 8.09 118.34 ...
## $ Debito : num [1:7] 0 0 0 0 0 0 0
## $ Saldo : num [1:7] 67.05 16.55 54.58 8.09 126.95 ...
transacciones_agrupadas = transacciones_agrupadas %>%
arrange(desc(Fecha_Movimiento))
transacciones_agrupadas
## # A tibble: 7 × 5
## Fecha_Movimiento Descripción Credito Debito Saldo
## <date> <chr> <dbl> <dbl> <dbl>
## 1 2024-06-18 Suscripción Cuotas P 8.09 0 8.09
## 2 2023-11-17 Suscripción Cuotas P 31.4 0 54.6
## 3 2023-09-05 Suscripción Cuotas P 16.6 0 16.6
## 4 2023-08-03 Suscripción Cuotas P 67.0 0 67.0
## 5 2023-06-27 Suscripción Cuotas P 23.6 0 23.6
## 6 2023-06-22 Suscripción Cuotas P 118. 0 127.
## 7 2023-05-24 Suscripción Cuotas P 8.61 0 8.61
Se fragmentara en dos etapas. Revisión de saldos y de credito. El primero es para revisar el acumulado y el de credito para simular cuanto hubiera sido el saldo si se mantenia la suscripción y no teniamos rescate.
Revisar como se comportaron los saldos para revisar como fue la fluctuación del total de las variables.
Primero revisamos como estan los datos del fondo y su comportamiento diario.
Ajustamos la variable Fecha a Date
#str(df_fci)
df_fci = df_fci %>%
mutate(Fecha = as.Date(Fecha, format = "%d/%m/%Y"))
str(df_fci)
## tibble [323 × 4] (S3: tbl_df/tbl/data.frame)
## $ Fecha : Date[1:323], format: "2024-08-27" "2024-08-26" ...
## $ Número Fondo : num [1:323] 1 1 1 1 1 1 1 1 1 1 ...
## $ Nombre Fondo : chr [1:323] "1822 RAÍCES VALORES NEGOCIABLES" "1822 RAÍCES VALORES NEGOCIABLES" "1822 RAÍCES VALORES NEGOCIABLES" "1822 RAÍCES VALORES NEGOCIABLES" ...
## $ Valor Cuota Parte: num [1:323] 15856 15632 15769 15483 15904 ...
Revisamos comportamiento de la variable
# Instalar la librería (si aún no está instalada)
#install.packages("quantmod")
# Cargar la librería
library(quantmod)
## Cargando paquete requerido: xts
## Cargando paquete requerido: zoo
##
## Adjuntando el paquete: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
##
## ######################### Warning from 'xts' package ##########################
## # #
## # The dplyr lag() function breaks how base R's lag() function is supposed to #
## # work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or #
## # source() into this session won't work correctly. #
## # #
## # Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
## # conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop #
## # dplyr from breaking base R's lag() function. #
## # #
## # Code in packages is not affected. It's protected by R's namespace mechanism #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning. #
## # #
## ###############################################################################
##
## Adjuntando el paquete: 'xts'
## The following objects are masked from 'package:dplyr':
##
## first, last
## Cargando paquete requerido: TTR
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
library(xts)
df_fci = df_fci %>%
rename(Valor_Cuota_Parte = 'Valor Cuota Parte')
Necesitamos convertir el dataframe a un objeto xts, donde las fechas sean las filas y los valores sean los precios.
# Convierte el dataframe a un objeto xts, usando Fecha como índice
df_fci_xts = xts(df_fci$Valor_Cuota_Parte, order.by = df_fci$Fecha)
chartSeries(df_fci_xts, theme = "white", name = "Cotizacion de FCI")