Пример #1
1
  /**
   * Calculates losses for the given credit portfolio using Monte-Carlo Simulation. Simulates
   * probability of default only.
   *
   * @param portfolio Credit portfolio.
   * @param horizon Forecast horizon.
   * @param num Number of Monte-Carlo iterations.
   * @return Losses array simulated by Monte Carlo method.
   */
  private double[] calculateLosses(Credit[] portfolio, int horizon, int num) {
    double[] losses = new double[num];

    // Count losses using Monte-Carlo method. We generate random probability of default,
    // if it exceeds certain credit default value we count losses - otherwise count income.
    for (int i = 0; i < num; i++)
      for (Credit crd : portfolio) {
        int remDays = Math.min(crd.getRemainingTerm(), horizon);

        if (rndGen.nextDouble() >= 1 - crd.getDefaultProbability(remDays))
          // (1 + 'r' * min(H, W) / 365) * S.
          // Where W is a horizon, H is a remaining crediting term, 'r' is an annual credit rate,
          // S is a remaining credit amount.
          losses[i] +=
              (1 + crd.getAnnualRate() * Math.min(horizon, crd.getRemainingTerm()) / 365)
                  * crd.getRemainingAmount();
        else
          // - 'r' * min(H,W) / 365 * S
          // Where W is a horizon, H is a remaining crediting term, 'r' is a annual credit rate,
          // S is a remaining credit amount.
          losses[i] -=
              crd.getAnnualRate()
                  * Math.min(horizon, crd.getRemainingTerm())
                  / 365
                  * crd.getRemainingAmount();
      }

    return losses;
  }
Пример #2
1
  protected Object handleDownMessage(final Event evt, final Message msg, Address dest, int length) {
    if (dest == null) { // 2nd line of defense, not really needed
      log.error(
          getClass().getSimpleName() + " doesn't handle multicast messages; passing message down");
      return down_prot.down(evt);
    }

    Credit cred = sent.get(dest);
    if (cred == null) return down_prot.down(evt);

    long block_time = max_block_times != null ? getMaxBlockTime(length) : max_block_time;

    while (running && sent.containsKey(dest)) {
      boolean rc = cred.decrementIfEnoughCredits(length, block_time);
      if (rc || !running || max_block_times != null) break;

      if (cred.needToSendCreditRequest())
        sendCreditRequest(dest, Math.max(0, max_credits - cred.get()));
    }

    // send message - either after regular processing, or after blocking (when enough credits
    // available again)
    return down_prot.down(evt);
  }
Пример #3
0
 boolean creditStatus() {
   double montlyFees = 0;
   for (Iterator<Credit> it = this.myCredits.iterator(); it.hasNext(); ) {
     Credit element = it.next();
     montlyFees += element.getMonthlyFee();
   }
   if (this.getSalary() / montlyFees < 2) {
     return false;
   } else {
     return true;
   }
 }
Пример #4
0
  public void giveCredit(Client client, Credit credit) {
    if (reserv - credit.getAmount() - calculateMonthlyDepositAccumulations() > 0) {
      if (client.askForCredit(credit)) {
        bankProducts.add(credit);

        reserv -= credit.getAmount();
        capital -= credit.getAmount();
      }

    } else {
      System.out.println(
          "Bank doesn't have enough money in reserve to give " + credit.getAmount() + " as credit");
    }
  }
    public MyJObject(int i) {
      CourseCheckBox = new JCheckBox(DataTransfer.Courses.elementAt(i));
      CourseCheckBox.setForeground(Color.WHITE);
      CourseCheckBox.setFont(new Font("SERRIF", Font.BOLD + Font.ITALIC, 13));
      CourseCheckBox.setHorizontalAlignment(SwingConstants.LEFT);
      CourseCheckBox.setOpaque(false);
      CourseCheckBox.setSelected(true);

      TotalMarks =
          new JLabel(
              Float.toString(
                  Float.valueOf(
                      TwoDecimal.format(Float.parseFloat(DataTransfer.Total.elementAt(i))))),
              SwingConstants.CENTER);
      TotalMarks.setForeground(Color.WHITE);
      TotalMarks.setFont(new Font("SERRIF", Font.BOLD + Font.ITALIC, 13));

      GradePoint = new JLabel(DataTransfer.GradePoint.elementAt(i), SwingConstants.LEFT);
      GradePoint.setForeground(Color.WHITE);
      GradePoint.setFont(new Font("SERRIF", Font.ITALIC, 13));

      LetterGrade = new JLabel(DataTransfer.LetterGrade.elementAt(i), SwingConstants.LEFT);
      LetterGrade.setForeground(Color.WHITE);
      LetterGrade.setFont(new Font("SERRIF", Font.PLAIN, 13));

      CreditLabel = new JLabel(Credit.elementAt(i), SwingConstants.LEFT);
      CreditLabel.setForeground(Color.WHITE);
      CreditLabel.setFont(new Font("SERRIF", Font.PLAIN, 13));

      ExamTypeLabel = new JLabel(DataTransfer.ExamType.elementAt(i), SwingConstants.LEFT);
      ExamTypeLabel.setForeground(Color.WHITE);
      ExamTypeLabel.setFont(new Font("SERRIF", Font.PLAIN, 12));
    }
Пример #6
0
  protected void handleCredit(Address sender, long increase) {
    Credit cred;
    if (sender == null || (cred = sent.get(sender)) == null || increase <= 0) return;

    long new_credit = Math.min(max_credits, cred.get() + increase);
    if (log.isTraceEnabled()) {
      StringBuilder sb = new StringBuilder();
      sb.append("received " + increase + " credits from ")
          .append(sender)
          .append(", old credits: ")
          .append(cred)
          .append(", new credits: ")
          .append(new_credit);
      log.trace(sb);
    }
    cred.increment(increase);
  }
Пример #7
0
 public void evaluateCredit(
     Client client, double creditMoney, Credit.CreditType creditType, int period) {
   double allMonthlyPayments = 0;
   for (Credit credits : client.getCredits()) {
     allMonthlyPayments += credits.getMonthlyPayment();
   }
   if (allMonthlyPayments < client.getSalary() / 2) {
     if (this.reserve - creditMoney > this.getAllDepositMoney() * 0.1) {
       this.createCredit(client, creditMoney, creditType, period);
       System.out.println(this.name + " gave " + client.getName() + " a credit of " + creditMoney);
       this.allDepositMoney -= creditMoney;
     } else {
       System.out.println("The bank cannot afford to give this credit.");
     }
   } else {
     System.out.println(client.getName() + " cannot afford to pay this credit.");
   }
 }
Пример #8
0
  /**
   * Method used to access credit account. Allows the ability to check account balance. Allows the
   * ability to pay bills and balance.
   */
  public void creditMenu() {
    try {
      Credit cr = new Credit();
      int selection;
      int amount;
      System.out.println("\nCredit menu");
      System.out.println("1 - View account balance:");
      System.out.println("2 - Pay Balance:");
      System.out.println("3 - Pay Bills:");
      System.out.println("4 - Back to Account Menu:");
      System.out.println("5 - Terminate transaction:");
      System.out.print("Choice: ");
      Scanner input = new Scanner(System.in);
      selection = input.nextInt();

      switch (selection) {
        case 1:
          cr.getCrBal();
          System.out.println("Your balance is:" + current_user.balance);
          break;
        case 2:
          System.out.println("\nEnter amount:");
          Scanner input2 = new Scanner(System.in);
          amount = input2.nextInt();
          current_user.credit.pay_balance(amount);
          current_user.updateProperties(current_user.idNum);
          break;
        case 3:
          System.out.println("\nEnter amount:");
          Scanner input3 = new Scanner(System.in);
          amount = input3.nextInt();
          current_user.credit.bill_payment(amount);
          current_user.updateProperties(current_user.idNum);
          break;
        case 4:
          selectAccount();
          break;
        case 5:
          System.out.println("\nThank you for using our online banking service");
          System.exit(0);
      }
    } catch (IOException ex) {
    }
  }
Пример #9
0
 protected void setHeaderData() {
   headerData = getHeaderData(type, id);
   setInfo();
   setAddress();
   setContact();
   creditData = Credit.getData(id);
   routeData = Route.getData(id);
   discountData = PartnerDiscount.getData(id);
   channels = new String[] {channel};
   provinces = new String[] {province};
   cities = new String[] {city};
   districts = new String[] {district};
 }
Пример #10
0
 public Credit Calculate(Credit credit) {
   return new Credit(credit.getValue() * this.multiplicator);
 }
Пример #11
0
 public void stop() {
   super.stop();
   for (Credit cred : sent.values()) cred.set(max_credits);
 }
Пример #12
0
 @ManagedAttribute(description = "Total time (ms) spent in flow control block")
 public long getTotalTimeBlocked() {
   long retval = 0;
   for (Credit cred : sent.values()) retval += cred.getTotalBlockingTime();
   return retval;
 }
Пример #13
0
 @ManagedAttribute(description = "Number of times flow control blocks sender")
 public int getNumberOfBlockings() {
   int retval = 0;
   for (Credit cred : sent.values()) retval += cred.getNumBlockings();
   return retval;
 }
Пример #14
0
 public int getMinMonthsWithoutPenalty() {
   int result = credits.get(0).getMonthsWithoutPenalty();
   for (Credit credit : credits)
     if (credit.getMonthsWithoutPenalty() < result) result = credit.getMonthsWithoutPenalty();
   return result;
 }
Пример #15
0
  void collectCredit(Credit credit) {

    reserv += credit.getMonthlyCreditInstallment();
    capital += credit.getMonthlyCreditInstallment();
  }
Пример #16
-1
  static double calculateCreditMontlyPayment(Credit credit) {

    return credit.getAmount() + credit.getAmount() * credit.getInterest();
  }
Пример #17
-2
 @Override
 public void askForCredit(String typeOfCredit, double amount, int period, Bank myBank)
     throws NotEnoughMoneyException {
   if (creditStatus() && myBank.creditCheck(amount)) {
     Credit newCredit = Credit.makeNewCredit(typeOfCredit, period, amount);
     this.myCredits.add(newCredit);
     myBank.transferAccountToDataBase(newCredit);
   }
 }