def _get_instrument_data_without_checking(self, instrument_code):

        result_dict = self._mongo.collection.find_one(dict(instrument_code=instrument_code))
        result_dict.pop(MONGO_ID_KEY)

        instrument_object = futuresInstrument.create_from_dict(result_dict)

        return instrument_object
Esempio n. 2
0
    def create_from_dict(futuresContract, futures_contract_dict):
        """

        :param futures_contract_dict: The result of running .as_dict on a futuresContract.
        :return: futuresContract object
        """

        contract_date_dict = futures_contract_dict['contract_date_dict']
        instrument_dict = futures_contract_dict['instrument_dict']
        contract_params_dict = futures_contract_dict['contract_params']

        contract_date_object = contractDate.create_from_dict(contract_date_dict)
        instrument_object = futuresInstrument.create_from_dict(instrument_dict)

        return futuresContract(instrument_object, contract_date_object, **contract_params_dict)
    def create_from_dict(futuresContract, futures_contract_dict):
        """

        :param futures_contract_dict: The result of running .as_dict on a futuresContract.
        :return: futuresContract object
        """

        contract_date_dict = copy(futures_contract_dict)
        instrument_code = contract_date_dict.pop('instrument_code')

        # We just do a 'bare' instrument with only a code
        instrument_dict = dict(instrument_code = instrument_code)

        contract_date_object = contractDate.create_from_dict(contract_date_dict)
        instrument_object = futuresInstrument.create_from_dict(instrument_dict)

        return futuresContract(instrument_object, contract_date_object)
Esempio n. 4
0
    def create_from_dict(futuresContract, futures_contract_dict):
        """

        :param futures_contract_dict: The result of running .as_dict on a futuresContract.
        :return: futuresContract object
        """

        contract_date_dict = copy(futures_contract_dict)
        instrument_code = contract_date_dict.pop('instrument_code')

        # We just do a 'bare' instrument with only a code
        instrument_dict = dict(instrument_code=instrument_code)

        contract_date_object = contractDate.create_from_dict(
            contract_date_dict)
        instrument_object = futuresInstrument.create_from_dict(instrument_dict)

        return futuresContract(instrument_object, contract_date_object)
    def create_from_dict_with_instrument_dict(futuresContract, instrument_dict, futures_contract_dict):
        """

        :param instrument_dict: The result of running .as_dict on a futuresInstrument
        :param futures_contract_dict: The result of running .as_dict on a futuresContract.
        :return: futuresContract object
        """

        # If we run as_dict on a futuresContract we get the instrument_code
        assert instrument_dict['instrument_code'] == futures_contract_dict['instrument_code']

        contract_date_dict = copy(futures_contract_dict)
        contract_date_dict.pop('instrument_code') # not used

        contract_date_object = contractDate.create_from_dict(contract_date_dict)
        instrument_object = futuresInstrument.create_from_dict(instrument_dict)

        return futuresContract(instrument_object, contract_date_object)
    def create_from_dict_with_rolldata(futuresContract, futures_contract_dict, roll_data_dict):
        """

        :param futures_contract_dict: The result of running .as_dict on a futuresContract.
        :param roll_data_dict: A roll data dict
        :return: futuresContract object
        """

        contract_date_dict = copy(futures_contract_dict)
        instrument_code = contract_date_dict.pop('instrument_code')

        # We just do a 'bare' instrument with only a code
        instrument_dict = dict(instrument_code = instrument_code)

        contract_date_with_rolldata_object = contractDateWithRollParameters.create_from_dict(contract_date_dict, roll_data_dict)
        instrument_object = futuresInstrument.create_from_dict(instrument_dict)

        return futuresContract(instrument_object, contract_date_with_rolldata_object)
Esempio n. 7
0
    def create_from_dict_with_instrument_dict(futuresContract, instrument_dict,
                                              futures_contract_dict):
        """

        :param instrument_dict: The result of running .as_dict on a futuresInstrument
        :param futures_contract_dict: The result of running .as_dict on a futuresContract.
        :return: futuresContract object
        """

        # If we run as_dict on a futuresContract we get the instrument_code
        assert instrument_dict['instrument_code'] == futures_contract_dict[
            'instrument_code']

        contract_date_dict = copy(futures_contract_dict)
        contract_date_dict.pop('instrument_code')  # not used

        contract_date_object = contractDate.create_from_dict(
            contract_date_dict)
        instrument_object = futuresInstrument.create_from_dict(instrument_dict)

        return futuresContract(instrument_object, contract_date_object)
Esempio n. 8
0
    def create_from_dict_with_rolldata(futuresContract, futures_contract_dict,
                                       roll_data_dict):
        """

        :param futures_contract_dict: The result of running .as_dict on a futuresContract.
        :param roll_data_dict: A roll data dict
        :return: futuresContract object
        """

        contract_date_dict = copy(futures_contract_dict)
        instrument_code = contract_date_dict.pop('instrument_code')

        # We just do a 'bare' instrument with only a code
        instrument_dict = dict(instrument_code=instrument_code)

        contract_date_with_rolldata_object = contractDateWithRollParameters.create_from_dict(
            contract_date_dict, roll_data_dict)
        instrument_object = futuresInstrument.create_from_dict(instrument_dict)

        return futuresContract(instrument_object,
                               contract_date_with_rolldata_object)