Пример #1
0
        def downloadDateData(day):

            baseUrl = config.getConfigParameter('restApiRatesUrl')
            if currencyConfig['currency'] == 'EUR':
                url = baseUrl + '/' + day
            else:
                url = baseUrl + day + '?base=' + currencyConfig['currency']
            obj = 'a'
            try:
                a = requests.get(url)
                obj = a.json()
            except:
                errors.append(url)
            return obj
Пример #2
0
 def __init__(self, dbConfig, host = config.getConfigParameter('host') , port = config.getConfigParameter('port') ):
     # self.client = pymongo.MongoClient(host, port)
     self.client = pymongo.MongoClient(config.getConfigParameter('connectionString'))
     self.setDb(dbConfig)
Пример #3
0
                    print(day)
                    time.sleep(.3)
                else:
                    print('Error for ' + day)

            saveValues(daysRates)
            print('updateting metadata')
            updateMetaData(latestDownloadedDateInfo['_id'],
                           daysRates[-1]['exactDate'])

        try:
            downloadMissingData()
        except:
            errors.append('Error downloading data')

        if len(errors) > 0:
            print('imase greski')
        else:
            print('SUCCESS downloading dates')


# def updateCurrencyData():

print('updateting data')
# go through all suported currencies and download
downloader = CurrencyDownloader()

for currencyConfig in config.getConfigParameter('currencies'):
    print('Downloading for ' + currencyConfig['currency'])
    downloader.downloadMissingDataForCurrency(currencyConfig)
import dbService
import mongoRepo
import config
import calcUtils
from datetime import date, timedelta

currencies = config.getConfigParameter('currencies')
currencyConfig = currencies[0]
repo = mongoRepo.Repo(currencyConfig)
service = dbService.DbService(repo)
"""
Entry points for calculations

"""


def getCurrencyPairData(startDate, endDate, inpCur, outCur):
    setCorrectCurrency(inpCur)

    rates = service.getRatesBetweenDates(startDate, endDate, inpCur)
    deleteId(rates)

    mean = calcUtils.CalcUtils.findMeanForCurrency(rates, outCur[0])
    datasets = []
    for c in outCur:
        dataset = buildDataSetForCurPair(inpCur, c, rates)
        datasets.append(dataset)

    labels = getLabels(rates)

    print("returning dates bettween", startDate, "and", endDate, "for", inpCur)