Skip to content

Instantly share code, notes, and snippets.

View wilsonfreitas's full-sized avatar

Wilson Freitas wilsonfreitas

View GitHub Profile
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"]]
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"]]
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
curl http://bvmf.bmfbovespa.com.br/InstDados/SerHist/COTAHIST_A2019.ZIP --output COTAHIST_A2019.ZIP
library(tseries)
library(magrittr)
library(ggplot2)
data(EuStockMarkets)
dax <- diff(log(EuStockMarkets))[,"DAX"]
dax.garch <- garch(dax)
dax.garch
tidy(dax.garch)
#' @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))
#' 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.
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")
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)
}
}
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="")