This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(bizdays) | |
library(lubridate) | |
create.calendar(name='MyCalendar', | |
weekdays=c('saturday', 'sunday'), | |
start.date = ymd("2019-12-28"), | |
end.date = ymd("2021-01-01")) | |
calendars()[["MyCalendar"]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(bizdays) | |
library(lubridate) | |
create.calendar(name='MyCalendar', | |
weekdays=c('saturday', 'sunday'), | |
start.date = ymd("2019-12-28"), | |
end.date = ymd("2021-01-01")) | |
calendars()[["MyCalendar"]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(compiler) | |
library(foreach) | |
f.original <- function() { | |
x <- 0 | |
for (p in 1:2) { | |
for (i in 1:500) { | |
for (j in 1:5000) { | |
x <- x + i * j |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl http://bvmf.bmfbovespa.com.br/InstDados/SerHist/COTAHIST_A2019.ZIP --output COTAHIST_A2019.ZIP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tseries) | |
library(magrittr) | |
library(ggplot2) | |
data(EuStockMarkets) | |
dax <- diff(log(EuStockMarkets))[,"DAX"] | |
dax.garch <- garch(dax) | |
dax.garch | |
tidy(dax.garch) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' @export | |
next_anniversary = function(x, ...) UseMethod("next_anniversary") | |
#' @export | |
next_anniversary.bond = function(x, ...) { | |
refdate = crf.options$get("REFDATE") | |
start_year = year(refdate) | |
start_month = month(refdate) | |
anniversary = as.Date(ISOdate(start_year, start_month, x$anniversary)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Computes option price via Black-76 formula. | |
#' | |
#' Black-76 formula implementation, pricing european options. | |
#' | |
#' @param type 'call' for call option, any other value for put. | |
#' @param future current future price. | |
#' @param strike the strike price. | |
#' @param time time to option expiration in years. | |
#' @param rate the risk-free interest rate. | |
#' @param sigma volatility of the future price. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(httr) | |
library(xml2) | |
get_deb_list <- function(.which = c("registrados", "excluidos", "todos")) { | |
.which <- match.arg(.which) | |
.which <- switch(.which, | |
registrados = "False", | |
excluidos = "True", | |
todos = "Nada") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(utils) | |
b3_download_handler <- function(obj, data_ref, dest_dir) { | |
function () { | |
mapply(function(url_fname, fname) { | |
b3_file_downloader(url_fname, fname, dest_dir, data_ref) | |
}, obj$url_file, obj$filename) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bvbg_download_handler <- function(obj, data_ref, dest_dir) { | |
function () { | |
data <- as.Date(data_ref) | |
# if (obj$jump_to_current) { | |
# data <- today() | |
# } | |
data <- format(x=data, format="%y%m%d") | |
url <- 'http://www.bmfbovespa.com.br/pesquisapregao/download?filelist=' | |
url <- paste(url, obj$url_file, data, '.zip', sep="") |