Skip to content

Instantly share code, notes, and snippets.

@cdiaz
Last active July 17, 2023 21:16
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cdiaz/a623334ee994a836cba3 to your computer and use it in GitHub Desktop.
Save cdiaz/a623334ee994a836cba3 to your computer and use it in GitHub Desktop.
Obtener La tasa de cambio representativa del mercado (TRM) para Colombia consumiendo el webservice de la Superintentencia Financiera desde Python
#!/usr/bin/env python
from suds.client import Client
import time
WSDL_URL = 'https://www.superfinanciera.gov.co/SuperfinancieraWebServiceTRM/TCRMServicesWebService/TCRMServicesWebService?WSDL'
date = time.strftime('%Y-%m-%d')
def trm(date):
try:
client = Client(WSDL_URL, location=WSDL_URL, faults=True)
trm = client.service.queryTCRM(date)
except Exception as e:
return str(e)
return trm
print trm(date)
@eusmas
Copy link

eusmas commented Jun 12, 2022

...
print (trm(date))

valor_dolar= trm(date)[4] #Obtienes el valor exacto de la TRM en pesos colombianos

@sistematod
Copy link

Sabes cómo obtener todas la tazas de cambio que están hay

@JFiTech
Copy link

JFiTech commented Mar 24, 2023

valor_dolar= trm(date)[4]

Una alternativa para sacar el el valor exacto también podría ser:

...
print(trm(date)[4])

o

...
valor_dolar = trm(date)[4]
print(valor_dolar)

@cdiaz
Copy link
Author

cdiaz commented May 10, 2023

Sabes cómo obtener todas la tazas de cambio que están hay

@sistematod puedes utilizar un ciclo con el rango de fechas deseado, luego en cada iteración del ciclo consultas la TRM y las vas almacenando o pusheando en un dict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment