コード例 #1
0
    market = Market(market_data_generator=MarketDataGenerator())

    # We can grab market data, by using MarketDataRequest objects
    # However, sometimes we might wish to create more freeform requests
    #   eg. if we have tickers stored in a spreadsheet)
    #   eg. from a single string (either for predefined tickers or any tickers/vendor_tickers combinations we want)
    # Here, we show how to this, and also how to call tickers which are already predefined in the CSV config files

    # Now we will try various examples with Bloomberg
    # only works if you have Bloomberg terminal installed and the Python API!

    # In this case, we are using the special 'fx' category
    md_request = MarketDataRequest(start_date='week', category='fx', data_source='bloomberg')

    # Let's try creating a MarketDataRequest overwrites in the tickers field
    md_request.freeform_md_request = [{'tickers' : ['AUDJPY']}, {'tickers' : ['AUDJPY', 'AUDUSD']}]
    md_request_list = market.create_md_request_from_freeform(md_request)

    print(md_request_list)

    # Now, we can do the same thing with a more complicated overwrite
    md_request.freeform_md_request = [{'tickers' : ['AUDJPY'], 'fields' : 'close'},
                                      {'tickers' : ['AUDJPY', 'AUDUSD'], 'fields' : 'close'}]

    md_request_list = market.create_md_request_from_freeform(md_request)

    print(md_request_list)

    # We can also create MarketDataRequest by passing a str that relates to predefined tickers
    md_request = market.create_md_request_from_str('backtest.fx.bloomberg.daily.NYC.EURUSD.close')
コード例 #2
0
    #   tickers/vendor_tickers combinations we want)
    # Here, we show how to this, and also how to call tickers which are
    # already predefined in the CSV config files

    # Now we will try various examples with Bloomberg
    # only works if you have Bloomberg terminal installed and the Python API!

    # In this case, we are using the special "fx" category
    md_request = MarketDataRequest(start_date="week",
                                   category="fx",
                                   data_source="bloomberg")

    # Let"s try creating a MarketDataRequest overwrites in the tickers field
    md_request.freeform_md_request = [{
        "tickers": ["AUDJPY"]
    }, {
        "tickers": ["AUDJPY", "AUDUSD"]
    }]
    md_request_list = market.create_md_request_from_freeform(md_request)

    print(md_request_list)

    # Now, we can do the same thing with a more complicated overwrite
    md_request.freeform_md_request = [{
        "tickers": ["AUDJPY"],
        "fields": "close"
    }, {
        "tickers": ["AUDJPY", "AUDUSD"],
        "fields": "close"
    }]