replace yahoo currency by FT currency
This commit is contained in:
@@ -10,7 +10,6 @@ zope.sqlalchemy
|
||||
waitress
|
||||
MySQL-python
|
||||
docutils
|
||||
yahoo_finance
|
||||
BeautifulSoup
|
||||
|
||||
[testing]
|
||||
|
||||
@@ -143,15 +143,18 @@ def delete_histo(request, no_id):
|
||||
|
||||
def getCurrencyRate(currency):
|
||||
# specify the url
|
||||
quote_page = 'http://www.finances.net/devises/courseuro'
|
||||
quote_page = 'https://markets.ft.com/data/currencies/tearsheet/summary?s=%seur' % currency
|
||||
|
||||
# query & parse the html using beautiful soap and store in variable `soup`
|
||||
soup = BeautifulSoup(urllib2.urlopen(quote_page), 'html.parser')
|
||||
# get the history table
|
||||
rows = soup.find('table', attrs={'class': 'news_table'}).tbody.findAll('tr')
|
||||
divs = rows[1].findAll('td')
|
||||
rate = divs[1].span.text
|
||||
return float(rate.replace(',','.'))
|
||||
data_list = soup.find_all("span", class_="mod-ui-data-list__value")
|
||||
if data_list:
|
||||
# get the rate price in EUR
|
||||
rate_price = float(data_list[0].text.replace(',',''))
|
||||
else:
|
||||
rate_price = 0.0
|
||||
|
||||
return rate_price
|
||||
|
||||
def getFTQuote(ticker):
|
||||
# specify the url of The Financial Times
|
||||
|
||||
@@ -105,8 +105,8 @@ def home(request):
|
||||
|
||||
# MAJ du prtefeuille
|
||||
if 'form.submitted' in request.params:
|
||||
# maj des parités des devises d'après Yahoo finance
|
||||
update_actif_devise(request, 'USD', getCurrencyRate('USD'))
|
||||
# maj des parités des devises
|
||||
update_actif_devise(request, 'USD', getCurrencyRate('usd'))
|
||||
|
||||
for item in actifs:
|
||||
if item.type == 'ACTION':
|
||||
|
||||
Reference in New Issue
Block a user