diff --git a/iol/handler.py b/iol/handler.py index 77aa0f9..0a0250d 100644 --- a/iol/handler.py +++ b/iol/handler.py @@ -62,3 +62,67 @@ def get_accion(secret, pais, accion): ) data = get(url, ttl_hash=get_ttl_hash()) return [a for a in data["titulos"] if a["simbolo"] == accion][0] + +@router.get("/{secret}/bono/{nombre}") +def get_bono(secret, nombre): + if secret != SECRET: + raise Exception("BAD") + nombre = nombre.upper() + access, refresh = get_token(ttl_hash=get_ttl_hash()) + url = ( + BASE_URL + + f"/api/v2/Cotizaciones/titulosPublicos/ar/Todos?cotizacionInstrumentoModel.instrumento=titulosPublicos&cotizacionInstrumentoModel.pais=argentina&api_key={access}" + ) + data = get(url, ttl_hash=get_ttl_hash()) + return [a for a in data["titulos"] if a["simbolo"] == nombre][0] + +@router.get("/{secret}/cedear/{nombre}") +def get_cedear(secret, nombre): + if secret != SECRET: + raise Exception("BAD") + nombre = nombre.upper() + access, refresh = get_token(ttl_hash=get_ttl_hash()) + url = ( + BASE_URL + + f"/api/v2/Cotizaciones/cedears/ar/Todos?cotizacionInstrumentoModel.instrumento=cedears&cotizacionInstrumentoModel.pais=argentina&api_key={access}" + ) + data = get(url, ttl_hash=get_ttl_hash()) + return [a for a in data["titulos"] if a["simbolo"] == nombre][0] + +@router.get("/{secret}/ON/{nombre}") +def get_on(secret, nombre): + if secret != SECRET: + raise Exception("BAD") + nombre = nombre.upper() + access, refresh = get_token(ttl_hash=get_ttl_hash()) + url = ( + BASE_URL + + f"/api/v2/Cotizaciones/obligacionesnegociables/ar/Todos?cotizacionInstrumentoModel.instrumento=obligacionesNegociables&cotizacionInstrumentoModel.pais=argentina&api_key={access}" + ) + data = get(url, ttl_hash=get_ttl_hash()) + return [a for a in data["titulos"] if a["simbolo"] == nombre][0] + +@router.get("/{secret}/ADR/{nombre}") +def get_adrs(secret, nombre): + if secret != SECRET: + raise Exception("BAD") + nombre = nombre.upper() + access, refresh = get_token(ttl_hash=get_ttl_hash()) + url = ( + BASE_URL + + f"/api/v2/Cotizaciones/adrs/us/Todos?cotizacionInstrumentoModel.instrumento=aDRs&cotizacionInstrumentoModel.pais=estados_Unidos&api_key={access}" + ) + data = get(url, ttl_hash=get_ttl_hash()) + return [a for a in data["titulos"] if a["simbolo"] == nombre][0] +@router.get("/{secret}/ON/{nombre}") +def get_on(secret, nombre): + if secret != SECRET: + raise Exception("BAD") + nombre = nombre.upper() + access, refresh = get_token(ttl_hash=get_ttl_hash()) + url = ( + BASE_URL + + f"/api/v2/Cotizaciones/obligacionesnegociables/ar/Todos?cotizacionInstrumentoModel.instrumento=obligacionesNegociables&cotizacionInstrumentoModel.pais=argentina&api_key={access}" + ) + data = get(url, ttl_hash=get_ttl_hash()) + return [a for a in data["titulos"] if a["simbolo"] == nombre][0]