Skip to content

Commit

Permalink
Merge pull request #2871 from Sublian/main
Browse files Browse the repository at this point in the history
Reto #10 - Python
  • Loading branch information
Roswell468 authored Apr 3, 2023
2 parents 8f4f0e4 + acb99d1 commit 180695a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Retos/Reto #10 - LA API [Media]/python/sublian.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# * Llamar a una API es una de las tareas más comunes en programación.
# *
# * Implementa una llamada HTTP a una API (la que tú quieras) y muestra su
# * resultado a través de la terminal. Para este ejemplo: Yahoo Finance
# * Se obtiene un registro historico de los precios del oro/dolar en base a un año
# * al final muestro el ultimo valor registrado en tiempo real
# * Aquí tienes un listado de posibles APIs:
# * https://github.com/public-apis/public-apis

import yfinance as yf
import pandas as pd
import json, requests

def golddata():
golddata= yf.Ticker("GC=F").history(period="1y")
print(golddata)
print("Gold csv extraction Finished :)")

golddata()

gold = json.loads(requests.get("https://forex-data-feed.swissquote.com/public-quotes/bboquotes/instrument/XAU/USD").text)
data = gold[0]
dataextract = data["spreadProfilePrices"]
dataextract = dataextract[0]["ask"]
print(f"<Data>: Gold price {dataextract} <USD> in real time ")

0 comments on commit 180695a

Please sign in to comment.