Пример #1
0
def label_up_current_contracts(
        current_contracts: setOfNamedContracts
) -> (listOfContractDateStr, list):
    """
    Labels current contracts only

    """
    price_contract_date = current_contracts.price
    forward_contract_date = current_contracts.forward
    carry_contract_date = current_contracts.carry

    labelled_price_contract = "%s%s" % (price_contract_date, PRICE_SUFFIX)
    labelled_forward_contract = "%s%s" % (forward_contract_date,
                                          FORWARD_SUFFIX)
    labelled_carry_contract = "%s%s" % (carry_contract_date, CARRY_SUFFIX)
    contract_names = [
        labelled_carry_contract, labelled_price_contract,
        labelled_forward_contract
    ]
    contract_date_list = [
        carry_contract_date, price_contract_date, forward_contract_date
    ]
    contract_date_list = listOfContractDateStr(contract_date_list)

    return contract_date_list, contract_names
    def sorted_contract_date_str(self):
        """
        Time sorted contract ids
        :return:
        """

        all_contract_date_str = listOfContractDateStr(self.keys())
        all_contract_date_str_sorted = all_contract_date_str.sorted_date_str()

        return all_contract_date_str_sorted
    def contract_dates_with_price_data_for_instrument_code(
            self, instrument_code: str) -> listOfContractDateStr:
        """

        :param instrument_code:
        :return: list of str
        """

        list_of_contracts_with_price_data = (
            self.contracts_with_price_data_for_instrument_code(instrument_code)
        )

        contract_dates = [
            str(contract.date_str)
            for contract in list_of_contracts_with_price_data
        ]
        list_of_contract_date_str = listOfContractDateStr(contract_dates)
        return list_of_contract_date_str
Пример #4
0
def get_dates_to_choose_from(
        data: dataBlob,
        instrument_code: str,
        only_priced_contracts: bool = False) -> listOfContractDateStr:

    diag_contracts = dataContracts(data)
    diag_prices = diagPrices(data)
    if only_priced_contracts:
        dates_to_choose_from = diag_prices.contract_dates_with_price_data_for_instrument_code(
            instrument_code)
    else:
        contract_list = diag_contracts.get_all_contract_objects_for_instrument_code(
            instrument_code)
        dates_to_choose_from = contract_list.list_of_dates()

    dates_to_choose_from = listOfContractDateStr(dates_to_choose_from)
    dates_to_choose_from = dates_to_choose_from.sorted_date_str()

    return dates_to_choose_from
    def _get_and_set_sorted_contract_date_str(self):
        all_contract_date_str = listOfContractDateStr(self.keys())
        all_contract_date_str_sorted = all_contract_date_str.sorted_date_str()
        self._all_contract_date_str_sorted = all_contract_date_str_sorted

        return all_contract_date_str_sorted
    def list_of_date_str(self) -> listOfContractDateStr:
        list_of_date_str = self.values()
        list_of_date_str = listOfContractDateStr(list_of_date_str)

        return list_of_date_str