示例#1
0
    def __init__(self, amount, interest, date=None, name=None, meta={}):

        self._date_start = validate.valid_date(date)
        self._name = validate.valid_name(name)
        self._meta = meta

        # check for problems
        assert ((isinstance(amount, int) or (isinstance(amount, float))))
        if interest > 1.:
            interest = interest / 100.

        ## generic variables, which are basically used in any class ##
        ## that inherits from account                               ##

        # setting up the report and the semantics
        self._report = Report(name=self._name)

        self._account = int(amount * 100)  # amount of money to start with
        self._interest = interest  # interest rate

        self._current_date = self._date_start  # current date of the simulation
        self._caccount = self._account  # current account, this variable
        # is used in all subclasses

        # sum helper variables for interest calculation and keep
        self._sum_interest = 0
示例#2
0
 def add_unique(self,
                from_acc,
                to_acc,
                payment,
                date,
                name='',
                fixed=False,
                meta={}):
     """ Transfers money from one account to the other """
     from_acc, to_acc = valid_account_type(from_acc, to_acc)
     date = validate.valid_date(date)
     self._payments.add_unique(from_acc, to_acc, payment, date, name, fixed,
                               meta)
     self.update_payment_iterators()
示例#3
0
    def __init__(self,
                 property_value,
                 amount,
                 loan,
                 date=None,
                 name=None,
                 meta={}):
        """
        For a property with a given value (property_value), the current amount
        that is transfered to the owner (amount) is reflected by the amount of
        money that has been transfered to the loan. Loan must here of class
        loan
        property_value : value of the property 
        amount         : amount of money that represents the ownership. if 
                         amount=property_value, the property totally belongs to the owner, if
                         amount<property_value, the property partly belongs to the loan holder
        loan           : object of type loan, that is linked to this property
        date           : date, for which this property starts to exist
        name           : name of this property
        meta           : meta-information        
        """

        assert isinstance(
            loan,
            Loan), 'loan must be of type Loan, but is in fact of type ' + str(
                type(loan))
        assert property_value >= amount, 'property_value must be greater than amount'

        self._name = validate.valid_name(name)
        self._date_start = validate.valid_date(date)
        self._meta = meta

        self._property_value = int(property_value * 100)
        self._account = int(amount * 100)  # amount of money already invested
        self._caccount = self._account
        self._loan = loan

        # setting up the report and the semantics
        self._report = Report(name=self._name)

        self._report.add_semantics('account', 'saving_abs')
        self._report.add_semantics('property_value', 'none')

        self._current_date = self._date_start

        self.make_report()
示例#4
0
    def __init__(self, *accounts, name=None, date=None, meta=None):
        """ Simulations can be initialized with names, to make differentiate
        between different simulations """
        # check for errors in the input of accounts
        for account in accounts:
            if not isinstance(account, Account):
                raise TypeError(
                    str(account) + " is not of type or subtype Account")

        if name is None:
            self._name = 'Simulation ' + str(datetime.now())
        else:
            self._name = name

        # a simuation can also store meta information
        self._meta = meta

        self._report = Report(self._name)
        self._report.add_semantics('from_acc', 'none')
        self._report.add_semantics('to_acc', 'none')
        self._report.add_semantics('value', 'input_cum')
        self._report.add_semantics('kind', 'none')
        self._report.add_semantics('name', 'none')
        self._report.add_semantics('code', 'none')
        self._report.add_semantics('message', 'none')

        self._payments = PaymentList()
        self._payments_iter = None
        self._next_pay = None

        self._date_start = validate.valid_date(date)
        self._day = 0
        self._current_date = self._date_start

        # list of accounts to manage
        self._accounts = list(accounts)

        # list of controller-functions executed before day-simulation.
        # controller functions are executed before the day to check custom
        # states of the accounts and perform actions
        self._controller = []
示例#5
0
 def add_regular(self,
                 from_acc,
                 to_acc,
                 payment,
                 interval,
                 date_start=datetime(1971, 1, 1),
                 day=1,
                 name='',
                 date_stop=None,
                 fixed=False,
                 meta={}):
     """ Transfers money from one account to the other on regular basis
     date_stop can be a function of the form lambda x: x > datetime(...)
     If it returns true, the payment is stopped
     """
     from_acc, to_acc = valid_account_type(from_acc, to_acc)
     date_start = validate.valid_date(date_start)
     if date_stop is not None:
         date_stop = validate.valid_stop_date(date_stop)
     self._payments.add_regular(from_acc, to_acc, payment, interval,
                                date_start, day, name, date_stop, fixed,
                                meta)
     self.update_payment_iterators()