Skip to content

Instantly share code, notes, and snippets.

import pandas as pd
import requests
import datetime
import csv
import io
from io import StringIO
import warnings
# Suppress the SettingWithCopyWarning
warnings.filterwarnings("ignore", category=pd.errors.SettingWithCopyWarning)
@eduardobsg
eduardobsg / commit_jupyter_notebooks_code_to_git_and_keep_output_locally.md
Created April 13, 2024 00:16 — forked from 33eyes/commit_jupyter_notebooks_code_to_git_and_keep_output_locally.md
How to commit jupyter notebooks without output to git while keeping the notebooks outputs intact locally
  1. Add a filter to git config by running the following command in bash inside the repo:
git config filter.strip-notebook-output.clean 'jupyter nbconvert --ClearOutputPreprocessor.enabled=True --to=notebook --stdin --stdout --log-level=ERROR'  
  1. Create a .gitattributes file inside the directory with the notebooks

  2. Add the following to that file:

*.ipynb filter=strip-notebook-output  
from langchain.llms import Anthropic
from langchain.agents import load_tools, initialize_agent
from langchain.tools import AIPluginTool
PREFIX = """\n\nHuman: Answer the following questions as best you can. You have access to the following tools:"""
SUFFIX = """Begin!
Question: {input}
\n\nAssistant:
Thought:{agent_scratchpad}"""
@eduardobsg
eduardobsg / list.md
Created January 28, 2022 00:42 — forked from ih2502mk/list.md
Quantopian Lectures Saved
@eduardobsg
eduardobsg / kalman_filter.py
Created December 6, 2020 18:10 — forked from swang225/kalman_filter.py
Kalman Filter
import numpy as np
import pandas as pd
# dropping tennis ball
def problem1():
dt = 1
F = np.matrix([[1, dt, dt**2/2],
@eduardobsg
eduardobsg / intraday-sp500.R
Created November 14, 2020 22:25 — forked from joshuaulrich/intraday-sp500.R
Track the S&P 500 throughout the trading day
require(quantmod)
do_chart <- function(symbol) {
quote <- getQuote(symbol)
quote$Close <- quote$Last
xts(OHLCV(quote), quote[,"Trade Time"],
pct_change = quote[,"% Change"])
}
x <- readRDS("intraday-sp500.rds")
cdb <- function(capital, data_aplicacao, data_resgate, di, pct_cdi){
library(dplyr)
library(bizdays)
dias_corridos <- as.numeric(difftime(data_resgate, data_aplicacao, units = "days"))
# computar biz days entre datas
bizdays::create.calendar("Brazil/ANBIMA",
bizdays::holidaysANBIMA,
weekdays=c("saturday", "sunday"))
library(tabulizer)
library(tidyverse)
arquivo <- "C:/Users/sillas.gonzaga/Downloads/gsa.pdf"
tab <- tabulizer::extract_tables(arquivo, encoding = "UTF-8", method = "lattice")
map(tab,dim)
# extrair tabelas com 8 colunas
@eduardobsg
eduardobsg / api_quotas_fundos.R
Created November 9, 2020 16:16 — forked from sillasgonzaga/api_quotas_fundos.R
API para baixar quotas de fundos
library(httr)
library(magrittr)
library(xml2)
library(rvest)
url_raw <- "http://dados.cvm.gov.br/dados/FI/DOC/INF_DIARIO/DADOS/"
output_file <- "fundos/api/informe_diario.csv"
csv_links <- httr::GET(url_raw) %>%
httr::content("text") %>%