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
<!doctype html> | |
<title>🐍📈 Python e Finanças - Retrieval Augmented Generation 🦜️🔗</title> | |
<body> | |
{% with messages = get_flashed_messages() %} | |
{% if messages %} | |
<ul class=flashes> | |
{% for message in messages %} | |
<li>{{ message }}</li> | |
{% endfor %} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 |
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
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): |
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
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) |
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
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') |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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) |
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
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", |
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
import csv | |
import time | |
import zipfile | |
from pprint import pprint | |
import pandas | |
import requests | |
contas_list = [ | |
'BPA', # Balanço Patrimonial de Ativos |
NewerOlder