示例#1
0
    def parseInvestment(cls_,
                        chunk,
                        date_format=DEFAULT_DATE_FORMAT,
                        decimal_sep=DEFAULT_DECIMAL_SEP,
                        thousands_sep=DEFAULT_THOUSANDS_SEP):
        """
        """

        curItem = Investment()

        lines = chunk.split('\n')
        for line in lines:
            if not len(line) or line[0] == '\n' or line.startswith('!Type'):
                continue
            elif line[0] == 'D':
                curItem.date = cls_.parseQifDateTime(line[1:], date_format)
            elif line[0] == 'T':
                curItem.amount = cls_.parseQifNumber(
                    line[1:],
                    decimal_sep=decimal_sep,
                    thousands_sep=thousands_sep)
            elif line[0] == 'N':
                curItem.action = line[1:]
            elif line[0] == 'Y':
                curItem.security = line[1:]
            elif line[0] == 'I':
                curItem.price = cls_.parseQifNumber(
                    line[1:],
                    decimal_sep=decimal_sep,
                    thousands_sep=thousands_sep)
            elif line[0] == 'Q':
                curItem.quantity = cls_.parseQifNumber(
                    line[1:],
                    decimal_sep=decimal_sep,
                    thousands_sep=thousands_sep)
            elif line[0] == 'C':
                curItem.cleared = line[1:]
            elif line[0] == 'M':
                curItem.memo = line[1:]
            elif line[0] == 'P':
                curItem.first_line = line[1:]
            elif line[0] == 'L':
                curItem.to_account = line[2:-1]
            elif line[0] == '$':
                curItem.amount_transfer = cls_.parseQifNumber(
                    line[1:],
                    decimal_sep=decimal_sep,
                    thousands_sep=thousands_sep)
            elif line[0] == 'O':
                curItem.commission = cls_.parseQifNumber(
                    line[1:],
                    decimal_sep=decimal_sep,
                    thousands_sep=thousands_sep)
        return curItem
示例#2
0
    def parseInvestment(cls_, chunk,
                        date_format=DEFAULT_DATE_FORMAT,
                        decimal_sep=DEFAULT_DECIMAL_SEP,
                        thousands_sep=DEFAULT_THOUSANDS_SEP):
        """
        """

        curItem = Investment()

        lines = chunk.split('\n')
        for line in lines:
            if not len(line) or line[0] == '\n' or line.startswith('!Type'):
                continue
            elif line[0] == 'D':
                curItem.date = cls_.parseQifDateTime(line[1:], date_format)
            elif line[0] == 'T':
                curItem.amount = cls_.parseQifNumber(line[1:], decimal_sep=decimal_sep, thousands_sep=thousands_sep)
            elif line[0] == 'N':
                curItem.action = line[1:]
            elif line[0] == 'Y':
                curItem.security = line[1:]
            elif line[0] == 'I':
                curItem.price = cls_.parseQifNumber(line[1:], decimal_sep=decimal_sep, thousands_sep=thousands_sep)
            elif line[0] == 'Q':
                curItem.quantity = cls_.parseQifNumber(line[1:], decimal_sep=decimal_sep, thousands_sep=thousands_sep)
            elif line[0] == 'C':
                curItem.cleared = line[1:]
            elif line[0] == 'M':
                curItem.memo = line[1:]
            elif line[0] == 'P':
                curItem.first_line = line[1:]
            elif line[0] == 'L':
                curItem.to_account = line[2:-1]
            elif line[0] == '$':
                curItem.amount_transfer = cls_.parseQifNumber(line[1:], decimal_sep=decimal_sep, thousands_sep=thousands_sep)
            elif line[0] == 'O':
                curItem.commission = cls_.parseQifNumber(line[1:], decimal_sep=decimal_sep, thousands_sep=thousands_sep)
        return curItem
示例#3
0
    def parseInvestment(cls_, chunk):
        """
        """

        curItem = Investment()
        if cls_.date_format:
            curItem.date_format = cls_.date_format
        lines = chunk.splitlines()
        for line in lines:
            if not len(line) or line[0] == '\n' or line.startswith(TYPE_HEADER):
                continue
            elif line[0] == 'D':
                curItem.date = cls_.parseQifDateTime(line[1:])
            elif line[0] == 'T':
                curItem.amount = cls_.parseFloat(line[1:])
            elif line[0] == 'N':
                curItem.action = line[1:]
            elif line[0] == 'Y':
                curItem.security = line[1:]
            elif line[0] == 'I':
                curItem.price = cls_.parseFloat(line[1:])
            elif line[0] == 'Q':
                curItem.quantity = cls_.parseFloat(line[1:])
            elif line[0] == 'C':
                curItem.cleared = line[1:]
            elif line[0] == 'M':
                curItem.memo = line[1:]
            elif line[0] == 'P':
                curItem.first_line = line[1:]
            elif line[0] == 'L':
                curItem.to_account = line[2:-1]
            elif line[0] == '$':
                curItem.amount_transfer = cls_.parseFloat(line[1:])
            elif line[0] == 'O':
                curItem.commission = cls_.parseFloat(line[1:])
        return curItem
示例#4
0
    def parseInvestment(cls_, chunk, date_format=None):
        """
        """

        curItem = Investment()
        if date_format:
            curItem.date_format = date_format
        lines = chunk.split('\n')
        for line in lines:
            if not len(line) or line[0] == '\n' or line.startswith('!Type'):
                continue
            elif line[0] == 'D':
                curItem.date = cls_.parseQifDateTime(line[1:])
            elif line[0] == 'T':
                curItem.amount = Decimal(cleanNumber(line[1:]))
            elif line[0] == 'N':
                curItem.action = line[1:]
            elif line[0] == 'Y':
                curItem.security = line[1:]
            elif line[0] == 'I':
                curItem.price = Decimal(cleanNumber(line[1:]))
            elif line[0] == 'Q':
                curItem.quantity = Decimal(cleanNumber(line[1:]))
            elif line[0] == 'C':
                curItem.cleared = line[1:]
            elif line[0] == 'M':
                curItem.memo = line[1:].rstrip()
            elif line[0] == 'P':
                curItem.first_line = line[1:]
            elif line[0] == 'L':
                curItem.to_account = line[2:-1]
            elif line[0] == '$':
                curItem.amount_transfer = Decimal(cleanNumber(line[1:]))
            elif line[0] == 'O':
                curItem.commission = Decimal(cleanNumber(line[1:]))
        return curItem
示例#5
0
    def parseInvestment(cls_, chunk, date_format=None):
        """
        """

        curItem = Investment()
        if date_format:
            curItem.date_format = date_format
        lines = chunk.split('\n')
        for line in lines:
            if not len(line) or line[0] == '\n' or line.startswith('!Type'):
                continue
            elif line[0] == 'D':
                curItem.date = cls_.parseQifDateTime(line[1:])
            elif line[0] == 'T':
                curItem.amount = float(line[1:].replace(',',''))
            elif line[0] == 'N':
                curItem.action = line[1:]
            elif line[0] == 'Y':
                curItem.security = line[1:]
            elif line[0] == 'I':
                curItem.price = float(line[1:].replace(',',''))
            elif line[0] == 'Q':
                curItem.quantity = float(line[1:].replace(',',''))
            elif line[0] == 'C':
                curItem.cleared = line[1:]
            elif line[0] == 'M':
                curItem.memo = line[1:]
            elif line[0] == 'P':
                curItem.first_line = line[1:]
            elif line[0] == 'L':
                curItem.to_account = line[2:-1]
            elif line[0] == '$':
                curItem.amount_transfer = float(line[1:].replace(',',''))
            elif line[0] == 'O':
                curItem.commission = float(line[1:].replace(',',''))
        return curItem