Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Vido
Vido / dfp_consolidado.py
Last active August 18, 2023 13:01
Exporta as DFPs da CVM para Excel
import csv
import time
import zipfile
from pprint import pprint
import pandas
import requests
contas_list = [
'BPA', # Balanço Patrimonial de Ativos
import yfinance
import numpy as np
import statsmodels.api as sm
import matplotlib.pyplot as mplt
# Download dos dados
data = yfinance.download(
tickers = 'PSSA3.SA ITUB4.SA',
start="2020-05-01",
end="2020-08-05",
import numpy as np
import pandas as pd
import yfinance
import matplotlib.pyplot as mplt
from bs4 import BeautifulSoup
import dryscrape
iframe_url = 'http://www2.bmf.com.br/pages/portal/bmfbovespa/lumis/lum-taxas-referenciais-bmf-ptBR.asp'
session = dryscrape.Session()
session.visit(iframe_url)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import time
import locale
locale.setlocale(locale.LC_ALL, 'pt_BR.UTF-8')
import requests
import pandas as pd
from bs4 import BeautifulSoup
def parse_df(content):
soup = BeautifulSoup(content, 'html.parser')
@Vido
Vido / calc_ibov.py
Last active September 26, 2021 17:06
import time
import yfinance
import dryscrape
from bs4 import BeautifulSoup
import pandas as pd
def get_b3_html():
url = 'https://sistemaswebb3-listados.b3.com.br/indexPage/day/IBOV?language=pt-br'
session = dryscrape.Session()
session.visit(url)
import time
import yfinance
import dryscrape
from bs4 import BeautifulSoup
import numpy as np
import pandas as pd
from sklearn.decomposition import PCA
import matplotlib.pyplot as plt
def get_market_data(tickers, start, end):
@Vido
Vido / portifolio.py
Created July 4, 2023 15:23
Modelo de Markowitz com dados da Binance
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import scipy.optimize as sco
from quotes import tickers
df = pd.read_pickle("quotes.pkl")
logrets = np.log(df / df.shift(1))
rmean = logrets.mean() * 365