Exemplo n.º 1
0
import requests
import zipfile
import io
from os.path import expanduser, join
from os import remove
from datetime import datetime, timedelta

import pandas as pd
from arctic.date import DateRange

from adagio.utils.date import date_shift
from adagio.utils.logging import get_logger
from adagio.utils.mongo import get_library

logger = get_logger(__name__)
library = get_library('truefx_fx_rates')

ccy_pairs = [
    'AUDJPY', 'AUDNZD', 'AUDUSD', 'CADJPY', 'CHFJPY', 'EURCHF', 'EURGBP',
    'EURJPY', 'EURUSD', 'GBPJPY', 'GBPUSD', 'NZDUSD', 'USDCAD', 'USDCHF',
    'USDJPY'
]

start_date = datetime(2009, 5, 1)
url_change_date = datetime(2017, 4, 1)
root_url = r'https://www.truefx.com/dev/data'
download_to = expanduser('~')
data_frequency = '1min'


def get_last_update(symbol):
Exemplo n.º 2
0
import adagio
from adagio import keys
from adagio.data.cash import get_cash_rate, to_cash_returns
from adagio.utils.logging import get_logger
from adagio.utils.mongo import get_library

from config import QUANDL_TOKEN

logger = get_logger(name=__name__)
adagio.AdagioConfig.quandl_token = QUANDL_TOKEN

if __name__ == '__main__':
    library = get_library(keys.cash_returns)

    currencies = ['USD', 'EUR', 'JPY', 'GBP']

    for ccy in currencies:
        logger.info('Saving cash returns for {}'.format(ccy))

        # get cash rates
        cash_rate = get_cash_rate(ccy)
        symbol = cash_rate.name
        library.write(symbol, cash_rate)

        # get cash returns
        cash_return = to_cash_returns(cash_rate, ccy)
        symbol = cash_return.name
        library.write(symbol, cash_return)