How to create a program that enters the web and takes data from the stock exchange

Asked

Viewed 4,373 times

-5

Well my idea is to create a program that takes the data of cryptocurrency quotations for me to monitor, but I don’t know how to take this data live and make the program stay updating the data.

1 answer

3

You can use the suggestions of:

API for stock exchange quotation

Sane all via HTTP and paid, the only one marked as free is for the Excel program and I don’t think will serve for this, the example that seems more interesting is Bolsafinanceira, follows the link of how to use:

Price tables:

Using with Python 3

In Python 3 you can use urllib.request with json

import json
import urllib.request

url = "http://api.bolsafinanceira.com:8080/composition/?token=<seu-token>&codelist=ibovespa,ibrx50"

with urllib.request.urlopen(urlData) as f:
   data = f.read()
   encoding = f.info().get_content_charset('utf-8')
   json.loads(data.decode(encoding))

Or use the import requests

To install use the command:

 pip install requests

Or pipenv (depends on your environment)

 pipenv install requests

Should stay like this:

import requests

url = 'http://api.bolsafinanceira.com:8080/composition/?token=<seu-token>&codelist=ibovespa,ibrx50';

r = requests.get(url, print=pretty')

# Exibe a resposta
print(r.json())
  • Alphavantage also offers an API (free with limitations). Contains most of the symbols traded on Bovespa.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.