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