Mas instrumentos

This commit is contained in:
Roberto Alsina 2023-07-01 21:50:44 -03:00
parent f0ab7c90dd
commit f059e48ce2
1 changed files with 64 additions and 0 deletions

View File

@ -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]