OUTSPOKEN MARKET
  • Home
  • Área do Aluno
  • Sobre o OMNP
  • Consultoria
  • Cursos Gratuitos
    • Curso de R para Finanças Quantitativas
    • Curso de Python para Finanças Quantitativas
    • Trading com I.A.
    • Excel na Prática
  • Blog
  • Diurnalis Series
  • Papers
  • E-Books
  • Contato

Seu 1º Modelo Matemático Aplicado - Finanças Quantitativas - Vídeo

12/28/2017

2 Comments

 
​Neste vídeo mostro todas as etapas para desenvolver o seu 1º Modelo Matemático Aplicado utilizando o Excel. O resultado foi 35% superior ao buy and hold no índice Bovespa. Se inscreva no canal para acompanhar todos os vídeos e aprender como você pode aproximar esse mundo das finanças quantitativas ao seu dia a dia! Deixe também um comentário com dúvidas e sugestões!
​



​Faça o download do arquivo aqui!


regressao_linear.xlsx
File Size: 78 kb
File Type: xlsx
Baixar o arquivo

regressao_linear.r
File Size: 3 kb
File Type: r
Baixar o arquivo

2 Comments
Rafael Castro
8/21/2019 10:56:43 pm

Leandro encontrei alguns pequenos problemas no codigo, eu corrigi, pode ajudar o pessoal, muito obrigado

############################################################
##################### Outspoken Market #####################
############################################################
# > First Indicator #
# > Last update ...... 27/12/2017 #
# > Developed by Leandro Guerra #
# > www.outspokenmarket.com #
# > www.youtube.com/outspokenmarket #
# > A liberdade eh o caminho #
# > Freedom is the way #
############################################################

install.packages('quantmod')

library(quantmod)
#Seleção do período de análise
startDate = as.Date("2017-01-01")
endDate = as.Date("2017-12-27")
#Seleção das ações
tickers = c('^BVSP','BTCUSD=X','PETR4.SA','ITUB4.SA')
#Captura dos dados
getSymbols(tickers, src = "yahoo", from = startDate, to = endDate)

#Cálculo dos retornos
BVSP_RET <- dailyReturn(BVSP)
BTC_RET <- dailyReturn(`BTCUSD=X`)
PETR_RET <- dailyReturn(`PETR4.SA`)
ITUB_RET <- dailyReturn(`ITUB4.SA`)

#Atribui os valores que são conjuntos
BVSP_SAME <- BVSP_RET[index(BVSP_RET)%in%index(ITUB_RET)]
BTC_SAME <- BTC_RET[index(BTC_RET)%in%index(ITUB_RET)]
PETR_SAME <- PETR_RET[index(PETR_RET)%in%index(ITUB_RET)]
ITUB_SAME <- ITUB_RET[index(ITUB_RET)%in%index(ITUB_RET)]

length(BVSP_SAME) #216
length(BTC_SAME) #216
length(PETR_SAME) #216
length(ITUB_SAME) #216

BVSP <- data.frame(BVSP)
BTC <- data.frame(`BTCUSD=X`)
PETR4 <- data.frame(PETR4.SA)
ITUB4 <- data.frame(ITUB4.SA)

names(BVSP) <- c("Open","High","Low","Close","Volume","Adjusted")
BVSP <- BVSP[ , (names(BVSP) %in% c("Open","High","Low","Close"))]
names(BTC) <- c("Open","High","Low","Close","Volume","Adjusted")
BTC <- BTC[ , (names(BTC) %in% c("Open","High","Low","Close"))]
names(PETR4) <- c("Open","High","Low","Close","Volume","Adjusted")
PETR4 <- PETR4[ , (names(PETR4) %in% c("Open","High","Low","Close"))]
names(ITUB4) <- c("Open","High","Low","Close","Volume","Adjusted")
ITUB4 <- ITUB4[ , (names(ITUB4) %in% c("Open","High","Low","Close"))]

PETR4$Close_Shift <- PETR4$Close
PETR4['Close_Shift'] <- c(NA, head(PETR4['Close_Shift'], dim(PETR4)[1] - 1)[[1]])
PETR4$Return <- (PETR4$Close/PETR4$Close_Shift - 1)
PETR4$Return_Shift <- PETR4$Return
PETR4['Return_Shift'] <- c(NA, head(PETR4['Return_Shift'], dim(PETR4)[1] - 1)[[1]])

ITUB4$Close_Shift <- ITUB4$Close
ITUB4['Close_Shift'] <- c(NA, head(ITUB4['Close_Shift'], dim(ITUB4)[1] - 1)[[1]])
ITUB4$Return <- (ITUB4$Close/ITUB4$Close_Shift - 1)
ITUB4$Return_Shift <- ITUB4$Return
ITUB4['Return_Shift'] <- c(NA, head(ITUB4['Return_Shift'], dim(ITUB4)[1] - 1)[[1]])

BTC$Close_Shift <- BTC$Close
BTC['Close_Shift'] <- c(NA, head(BTC['Close_Shift'], dim(BTC)[1] - 1)[[1]])
BTC$Return <- (BTC$Close/BTC$Close_Shift - 1)
BTC$Return_Shift <- BTC$Return
BTC['Return_Shift'] <- c(NA, head(BTC['Return_Shift'], dim(BTC)[1] - 1)[[1]])


BVSP$Close_Shift <- BVSP$Close
BVSP['Close_Shift'] <- c(NA, head(BVSP['Close_Shift'], dim(BVSP)[1] - 1)[[1]])
BVSP$Return <- (BVSP$Close/BVSP$Close_Shift - 1)
BVSP$Return <- (BVSP$Close/BVSP$Close_Shift - 1)
BVSP$Return_Shift <- BVSP$Return
BVSP['Return_Shift'] <- c(NA, head(BVSP['Return_Shift'], dim(BVSP)[1] - 1)[[1]])


BVSP$Return_Petr4 <- PETR4$Return_Shift
BVSP$Return_BTC <- BTC$Return_Shift[index(BTC$Return_Shift)%in%index(BVSP
)]
BVSP$Return_ITUB4 <- ITUB4$Return_Shift[index(ITUB4$Return_Shift)%in%index(BVSP)]
plot(BVSP$Return ,BVSP$Return_BTC)

fit_RET_BVSP_PETR <- lm(BVSP$Return ~ BVSP$Return_BTC + PETR4$Return_Shift + BVSP$Return_Shift + BVSP$Return_ITUB4)
summary(fit_RET_BVSP_PETR)
plot(fit_RET_BVSP_PETR)

y_predicted <- predict(fit_RET_BVSP_PETR,BVSP)

write.csv(BVSP,"BVSP.csv")

Reply
Leandro Guerra link
8/23/2019 04:19:40 pm

Olà Rafael, muito obrigado pela contribuiçao! Com certeza vai ajudar. Abraço!

Reply

Your comment will be posted after it is approved.


Leave a Reply.

    View my profile on LinkedIn

    Archives

    March 2023
    December 2022
    September 2022
    July 2022
    April 2022
    February 2022
    January 2022
    December 2021
    November 2021
    October 2021
    August 2021
    July 2021
    April 2021
    March 2021
    February 2021
    January 2021
    December 2020
    November 2020
    October 2020
    September 2020
    August 2020
    July 2020
    June 2020
    May 2020
    April 2020
    March 2020
    January 2020
    November 2019
    October 2019
    September 2019
    August 2019
    July 2019
    June 2019
    May 2019
    February 2019
    January 2019
    December 2018
    November 2018
    September 2018
    August 2018
    July 2018
    June 2018
    May 2018
    April 2018
    March 2018
    February 2018
    January 2018
    December 2017
    November 2017
    September 2017
    August 2017
    July 2017
    June 2017
    May 2017
    March 2017
    February 2017
    January 2017
    December 2016
    November 2016
    October 2016

    Categories

    All
    Assuntos Gerais
    Conhecimento Express
    Economia
    Opiniões

    RSS Feed

Outspoken Market - ​Copyright © 2016
Imagem
  • Home
  • Área do Aluno
  • Sobre o OMNP
  • Consultoria
  • Cursos Gratuitos
    • Curso de R para Finanças Quantitativas
    • Curso de Python para Finanças Quantitativas
    • Trading com I.A.
    • Excel na Prática
  • Blog
  • Diurnalis Series
  • Papers
  • E-Books
  • Contato