gauss314 / bursatil-argentina-python Goto Github PK
View Code? Open in Web Editor NEWGuia de ejemplos didácticos en python temática finanzas bolsa trading argentina usa
Guia de ejemplos didácticos en python temática finanzas bolsa trading argentina usa
No es necesario hacer el for loop, dado que yfinance soporte que le ingreses múltiples tickers y te devuelve el dataframe completo con la información completa de todos.
Básicamente el for loop se puede cambiar por la siguiente línea
df = yf.download(cartera, period='10y')['Adj Close']
import requests
from bs4 import BeautifulSoup
import datetime
import pandas as pd
def scrap(año, mes, url):
for i in range(1,7):
try:
fecha = datetime.datetime(año,mes,i)
data = {'fecha': fecha.strftime('%d-%m-%y')}
resp = requests.post(url, data=data)
soup = BeautifulSoup(resp.text, "html.parser")
break
except:
print('Falló en ',i)
filas = soup.find_all('td', {'style' : 'padding: 1%'})
return filas
def parsear(filas):
mensual = pd.DataFrame()
for i in range(1, int(len(list(filas))/3)):
dic = {}
dic['fecha'] = filas[3i].text
dic['bid'] = filas[3i+1].text
dic['ask'] = filas[3*i+2].text
rueda = pd.DataFrame.from_dict(dic, orient='index').transpose().set_index('fecha')
rueda.index = pd.to_datetime(rueda.index, format='%d-%m-%y ')
mensual = pd.concat([mensual,rueda], axis=0)
return mensual
def downloadAño(año,url):
tablaAnual = pd.DataFrame()
for i in range(1,13):
filas = scrap(año=año, mes=i,url=url)
tabla = parsear(filas)
tablaAnual = pd.concat([tablaAnual,tabla],axis=0)
print('mes',i,'listo')
tablaAnual.to_excel('blue_'+str(año)+'.xlsx')
print(tablaAnual)
return tablaAnual
año=2022
dolar_blue= downloadAño(año,'https://www.cotizacion-dolar.com.ar/dolar-blue-historico-'+str(año)+'.php')
dolar_oficial= downloadAño(año,'https://www.cotizacion-dolar.com.ar/dolar-historico-bna-'+str(año)+'.php')
Hola Juan. Excelente Trabajo.
Encontre tu hilo en twitter y me puse a ver q onda, no se nada de programación, pero soy bastante curioso y estoy hace tiempo en el mercado búrsatil, por eso me intereso.
Espero poder hacer alguno de tus cursos. Indagando en el py de opciones (black_scholes) sabes que cuando lo quiero compilar para que me quede en un excel me tira un error en la linea 130 y no se como arreglarlo.
Muchas Gracias de antemano.
Buenas!
Estoy teniendo problemas con el código para usar la API del BCRA, ¿se puede seguir usando?
Es la primera vez que me conecto a una API y me aparecen los siguientes errores:
SysCallError: (10054, 'WSAECONNRESET')
MaxRetryError: HTTPSConnectionPool(host='api.estadisticasbcra.com', port=443): Max retries exceeded with url: /reservas (Caused by SSLError(SSLError("bad handshake: SysCallError(10054, 'WSAECONNRESET')")))
SSLError: HTTPSConnectionPool(host='api.estadisticasbcra.com', port=443): Max retries exceeded with url: /reservas (Caused by SSLError(SSLError("bad handshake: SysCallError(10054, 'WSAECONNRESET')")))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.