mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
Conflicts: currency_rate_update/services/__init__.py currency_rate_update/services/currency_getter.py currency_rate_update/services/update_service_CA_BOC.py currency_rate_update/services/update_service_CH_ADMIN.py currency_rate_update/services/update_service_ECB.py currency_rate_update/services/update_service_PL_NBP.py currency_rate_update/services/update_service_RO_BNR.py
52 lines
2.4 KiB
Python
52 lines
2.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
# © 2009 Camptocamp
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
|
|
from .currency_getter_interface import CurrencyGetterInterface
|
|
|
|
|
|
class YAHOOGetter(CurrencyGetterInterface):
|
|
"""Implementation of Currency_getter_factory interface
|
|
for Yahoo finance service
|
|
"""
|
|
code = 'YAHOO'
|
|
name = 'Yahoo Finance'
|
|
|
|
supported_currency_array = [
|
|
"AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN",
|
|
"BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BRL",
|
|
"BSD", "BTN", "BWP", "BYR", "BZD", "CAD", "CDF", "CHF", "CLF", "CLP",
|
|
"CNH", "CNY", "COP", "CRC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP",
|
|
"DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GHS",
|
|
"GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF",
|
|
"IDR", "IEP", "ILS", "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY",
|
|
"KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK",
|
|
"LBP", "LKR", "LRD", "LSL", "LTL", "LVL", "LYD", "MAD", "MDL", "MGA",
|
|
"MKD", "MMK", "MNT", "MOP", "MRO", "MUR", "MVR", "MWK", "MXN", "MXV",
|
|
"MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB",
|
|
"PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB",
|
|
"RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS",
|
|
"SRD", "STD", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP",
|
|
"TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "UYU", "UZS", "VEF",
|
|
"VND", "VUV", "WST", "XAF", "XAG", "XAU", "XCD", "XCP", "XDR", "XOF",
|
|
"XPD", "XPF", "XPT", "YER", "ZAR", "ZMW", "ZWL"]
|
|
|
|
def get_updated_currency(self, currency_array, main_currency,
|
|
max_delta_days):
|
|
"""implementation of abstract method of curreny_getter_interface"""
|
|
self.validate_cur(main_currency)
|
|
url = ('http://download.finance.yahoo.com/d/'
|
|
'quotes.csv?s=%s=X&f=sl1c1abg')
|
|
if main_currency in currency_array:
|
|
currency_array.remove(main_currency)
|
|
for curr in currency_array:
|
|
self.validate_cur(curr)
|
|
res = self.get_url(url % (main_currency + curr))
|
|
val = res.split(',')[1]
|
|
if val:
|
|
self.updated_currency[curr] = val
|
|
else:
|
|
raise Exception('Could not update the %s' % (curr))
|
|
|
|
return self.updated_currency, self.log_info
|