コード例 #1
0
    def test_rollcycle(self):
        data = quandlFuturesContractPriceData()
        ans = data.get_prices_for_instrument_code_and_contract_date(
            "EDOLLAR", "200203")

        self.assertAlmostEqual(ans[ans.index == ans.index[0]].SETTLE[0],
                               92.62,
                               places=2)
def get_and_write_prices_for_contract_list_from_quandl_to_arctic(list_of_contracts):
    quandl_prices_data = quandlFuturesContractPriceData()
    arctic_prices_data = arcticFuturesContractPriceData()

    for contract_object in list_of_contracts:
        print("Processing %s" % contract_object.ident())
        quandl_price = quandl_prices_data.get_prices_for_contract_object(contract_object)

        if quandl_price.empty:
            print("Problem reading price data this contract - skipping")
        else:
            print("Read ok, trying to write to arctic")
            try:
                arctic_prices_data.write_prices_for_contract_object(contract_object, quandl_price)
            except:
                raise Exception("Some kind of issue with arctic - stopping so you can fix it")
コード例 #3
0
def get_vol_atr_compare(list_of_contracts):
    quandl_prices_data = quandlFuturesContractPriceData()

    ratio_list = []
    for contract_object in list_of_contracts:

        price_frame = quandl_prices_data.get_prices_for_contract_object(
            contract_object)
        price_returns = price_frame.SETTLE.diff()
        std_series = price_returns.rolling(20).std()
        atr_series = atr(price_frame)

        ratio_series = std_series / atr_series
        avg_ratio = ratio_series.mean()

        print(avg_ratio)

        ratio_list.append(avg_ratio)

    print("Average ratio DAILY STD DEV /ATR = %.3f" % np.nanmean(ratio_list))
コード例 #4
0
def get_and_write_prices_for_contract_list_from_quandl_to_arctic(
        list_of_contracts):
    quandl_prices_data = quandlFuturesContractPriceData()
    arctic_prices_data = arcticFuturesContractPriceData()

    for contract_object in list_of_contracts:
        print("Processing %s" % contract_object.ident())
        quandl_price = quandl_prices_data.get_prices_for_contract_object(
            contract_object)

        if quandl_price.empty:
            print("Problem reading price data this contract - skipping")
        else:
            print("Read ok, trying to write to arctic")
            try:
                arctic_prices_data.write_prices_for_contract_object(
                    contract_object, quandl_price)
            except:
                raise Exception(
                    "Some kind of issue with arctic - stopping so you can fix it"
                )