library(rb3)
fname <- download_marketdata("TaxasReferenciais",
refdate = as.Date("2024-01-12"),
curve_name = "TR")
df <- read_marketdata(fname, "TaxasReferenciais", TRUE)
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import requests,json,sys | |
# Script simples para consulta de dados na base dados nacional do SUS utilizando o CPF. | |
# Jhonathan Davi A.K.A jh00nbr / Insightl4b lab.insightsecurity.com.br | |
# Blog: lab.insightsecurity.com.br | |
# Github: github.com/jh00nbr | |
# Twitter @jh00nbr |
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
class B3FilesURLDownloader(SingleDownloader): | |
calendar = bizdays.Calendar.load('ANBIMA.cal') | |
def download(self, refdate=None): | |
filename = self.attrs.get('filename') | |
refdate = refdate or self.get_refdate() | |
logging.info('refdate %s', refdate) | |
date = refdate.strftime('%Y-%m-%d') | |
url = f'https://arquivos.b3.com.br/api/download/requestname?fileName={filename}&date={date}&recaptchaToken=' | |
res = requests.get(url) | |
msg = 'status_code = {} url = {}'.format(res.status_code, url) |
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
from functools import wraps | |
try: | |
from functools import lru_cache | |
except ImportError: | |
def lru_cache(user_function): | |
cache = {} | |
@wraps(user_function) | |
def wrapper(*args): | |
key = tuple(args) |
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
f <- function(x) cos(x*20) | |
expi <- function(x) cos(x) + sin(x)*1i | |
par(mfrow = c(1,2)) | |
L <- 40 | |
medias_Re <- c() | |
fs <- c() | |
as <- seq(0.01, 1, l = 140) | |
animation::saveGIF({ | |
for(a in as) { |
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(rb3) | |
library(tidyverse) | |
top_weight <- function(.data, n = 10) { | |
top_10 <- .data |> | |
arrange(desc(weight)) |> | |
slice_head(n = n) |> | |
select(symbol, weight) | |
total_weight <- sum(top_10$weight) | |
others <- tibble( |
forwardrate
method, for a SpotRateCurve
and with arguments t1
and t2
, computes the forward rate between
two future terms that exist in the term structure.
library(rb3)
library(fixedincome)
df_yc <- yc_get("2022-05-20")
crv <- spotratecurve(
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
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "Untitled0.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"authorship_tag": "ABX9TyNsy4RaWWJJXRN8opuCmESy", | |
"include_colab_link": true |
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="") |
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. |
NewerOlder