Ejemplo n.º 1
0
    df = market.fetch_market(md_request)

    print(df)

    # We can also download G10 FX from Eikon using shortcuts, without
    # specifying RIC
    # we just need to specify category at 'fx'
    # You can add your own customized tickers by editing the various conf
    # CSV files
    md_request = MarketDataRequest(
        start_date=datetime.datetime.utcnow() - timedelta(days=5),
        # Start date (download data over past decade)
        freq='intraday',
        category='fx',
        cut='NYC',
        data_source='eikon',  # use Eikon as data source
        tickers=['EURUSD', 'GBPUSD'],  # ticker
        fields=['close', 'open', 'high', 'low'],  # which fields to download
        eikon_api_key=eikon_api_key)

    print(df)

    df = market.fetch_market(md_request)

    # Also let's do this for daily data
    md_request.freq = 'daily'

    df = market.fetch_market(md_request)

    print(df)
                                   tickers=['GBPUSD'],
                                   cache_algo='cache_algo_return',
                                   abstract_curve=FXSpotCurve(
                                       construct_via_currency='USD',
                                       depo_tenor='ON'))

    df_tot = market.fetch_market(md_request=md_request)
    df_tot.columns = [x + '-tot-cuemacro' for x in df_tot.columns]
    df_tot = df_tot.tz_localize(pytz.utc)
    df_tot.index = df_tot.index + pd.Timedelta(
        hours=22)  # Roughly NY close 2200 GMT

    md_request.abstract_curve = None

    # Get intraday spot data
    md_request.freq = 'tick'
    md_request.data_source = 'dukascopy'

    df_intraday_spot = market.fetch_market(md_request=md_request)
    df_intraday_spot = pd.DataFrame(
        df_intraday_spot.resample('1min').last().dropna())

    # Get Bloomberg calculated total return indices (for spot)
    md_request.category = 'fx-tot'
    md_request.freq = 'daily'
    md_request.data_source = 'bloomberg'

    df_bbg_tot = market.fetch_market(md_request)
    df_bbg_tot.columns = [x + '-bbg' for x in df_bbg_tot.columns]
    df_bbg_tot = df_bbg_tot.tz_localize(pytz.utc)
    df_bbg_tot.index = df_bbg_tot.index + pd.Timedelta(