Jump to content
Sign in to follow this  
Steve Netwriter

Code for Monetary System Models

Recommended Posts

Originally from: http://www.greenenergyinvestors.com/index....ost&p=77645

Now from here: http://www.greenenergyinvestors.com/index....ost&p=77830

By: qwertyuiop

 

Consider the following model - you can run this on any java virtual machine.

 

import java.net.*;

import java.io.*;

import java.text.*;

import java.math.*;

 

public class interest_model

{

// Program Variables

public static double bank_capital = 2000; // shareholders

public static double bank_reserves = 3000; // deposits from customers into vault

public static double money_supply = 3000; // bank liabilities - savers bank balances

public static double money_on_loan = 0; // bank assets

public static double interest_total = 0;

public static double interest_received_period = 0; // Interest payments made in a period

public static double principle_received_period = 0; // Principle payments made in a period

 

public static int current_period = 1; // Period Counter

 

public static double[] loans1 = new double[2000]; // loan principle amount total

public static double[] loans2 = new double[2000]; // loan interest portion total

public static double[] loans3 = new double[2000]; // loan principle amount period

public static double[] loans4 = new double[2000]; // loan interest amount period

public static double[] loans5 = new double[2000]; // loan outstanding

public static String[] loans6 = new String[2000]; // loan retired?

public static int[] loans7 = new int[2000]; // payments left

 

// Constants

public static double interest_percent = 0.04; // 4.5% additional to be paid back

public static int loan_period = 10; // 10 installments for all loans;

public static double reserve_ratio = 0.05; // 5%

 

// Working Variables

public static double amount_to_loan;

public static double payment_amount;

public static double interest_charged;

public static int i;

 

public static double operating_costs;

public static double savers_interest;

public static double bankers_interest;

 

 

// Start Of Program

public static void main(String[] args) throws IOException

{

 

initialize_array();

 

boolean notbored = true;

while (notbored)

{

 

System.out.println("P | Bank Capital | Bank Reserves | Money Supply | Money On Loan");

System.out.println("--------------------------------------------------------------------");

 

DisplayVariables();

MakeNewLoans();

 

current_period++;

 

DisplayVariables();

MakeLoanPayments();

 

// Configurable for different scenarios

 

UpdateBankBalanceSheets();

 

Open_Market_Operations();

 

}

 

DisplayVariables();

}

 

 

public static void MakeNewLoans()

{

amount_to_loan = round((bank_reserves) - (money_supply * reserve_ratio),0);

interest_charged = round((amount_to_loan * interest_percent),0);

 

{

money_on_loan = money_on_loan + amount_to_loan; // Bank Asset

money_supply = money_supply + amount_to_loan; // Bank Liabilites

 

// Signifies removal of money from source bank into target bank - when loan is spent into economy

bank_reserves = bank_reserves - amount_to_loan;

bank_reserves = bank_reserves + amount_to_loan;

 

interest_total = interest_total + interest_charged;

 

i = getFreeElement();

 

loans1 = amount_to_loan;

loans2 = interest_charged;

 

loans3 = amount_to_loan / loan_period;

loans4 = interest_charged / loan_period;

 

loans5 = amount_to_loan + interest_charged;

loans6 = "N";

loans7 = loan_period;

 

System.out.println("--> MAKING LOAN["+i+"] / Principle total: "+ amount_to_loan + "; Interest To Pay Total:" + interest_charged + "; Payments Total: " + loans7);

}

}

 

public static void MakeLoanPayments()

{

 

i=0;

interest_received_period=0;

principle_received_period=0;

while (loans6 != "X")

{

 

if (loans6 == "N")

{

payment_amount = loans3 + loans4;

 

if (loans7 > 0)

{

loans5 = loans5 - payment_amount; // Reduced amount outstanding

loans7--;

}

 

// Retire Loan

if (loans7 == 0 ) { loans6="Y"; System.out.println("--> FINAL PAYMENT COMING["+i+"]"); }

 

// Update period totals

interest_received_period = interest_received_period + loans4; // Interest recevied in period

principle_received_period = principle_received_period + loans3; // Total principle received in period

 

// Reduce interest required from economy variable

interest_total = interest_total - loans4; // Interest required from economy reduced

 

System.out.println("--> MAKING PAYMENT["+i+"] / Principle Period: "+ loans3 + "; Interest Portion Period:" + loans4 + "; Payments Left: " + loans7);

 

}

 

i++;

}

}

 

public static void UpdateBankBalanceSheets()

{

 

// Money Supply

money_supply = money_supply - (interest_received_period + principle_received_period);

 

// Bank Assets

money_on_loan = money_on_loan - principle_received_period;

 

// Signifies movement of money from source bank into target bank - when loan is repaid

bank_reserves = bank_reserves - principle_received_period;

bank_reserves = bank_reserves + principle_received_period;

 

// Signifies removal of Interest paid from source bank - when loan is repaid

bank_reserves = bank_reserves - interest_received_period;

// Interest paid allocated to savers / target bank

savers_interest = round(interest_received_period * 0.90,2);

bankers_interest = round(interest_received_period - savers_interest,2);

 

System.out.println("--> BANKERS INTEREST PORTION: " + bankers_interest);

System.out.println("--> SAVERS' INTEREST PORTION: " + savers_interest);

bank_capital = bank_capital + bankers_interest;

bank_reserves = bank_reserves + savers_interest;

money_supply = money_supply + savers_interest;

 

// Operating Costs, dividends etc

operating_costs = round((bankers_interest * 0.80),2);

System.out.println("--> OPERATING COSTS SPENT INTO ECONOMY: " + operating_costs);

money_supply = money_supply + operating_costs; // Bank operating costs fed into economy...

bank_reserves = bank_reserves + operating_costs; // Customers deposit dividends, rent etc into bank

bank_capital = bank_capital - operating_costs; // Money spent by bank

 

}

 

public static void Open_Market_Operations()

// Open Market Operations by Central Bank

{

bank_reserves = bank_reserves + (bank_reserves * 0.001);

}

 

public static void DisplayVariables()

{

 

System.out.print(current_period);

System.out.print(" | ");

System.out.print(round(bank_capital,2));

System.out.print(" | ");

System.out.print(round(bank_reserves,2));

System.out.print(" | ");

System.out.print(round(money_supply,2));

System.out.print(" | ");

System.out.print(round(money_on_loan,2));

System.out.println("");

//waitSecs(1);

 

if (bank_reserves < 0)

{

System.out.println("**ERROR: NO DEPOSITORS HAVE ANY MONEY **");

System.exit(0);

}

}

 

 

// *************************

// *** Program Functions ***

// *************************

public static int getFreeElement()

{

int x=0;

while ((loans6[x] == "N")) { x++; }

return x--;

}

 

public static void waitSecs(long s) {

try {

Thread.currentThread().sleep(s * 1000);

}

catch (InterruptedException e) {

e.printStackTrace();

}

}

 

public static double round(double d, int decimalPlace)

{

BigDecimal bd = new BigDecimal(Double.toString(d));

bd = bd.setScale(decimalPlace,BigDecimal.ROUND_HALF_UP);

return bd.doubleValue();

}

 

public static void initialize_array()

{

for (i = 0; i<2000; i++)

{

loans1=0;

loans2=0;

loans3=0;

loans4=0;

loans5=0;

loans6="X";

loans7=0;

}

}

}

Share this post


Link to post
Share on other sites

Attached code for model:

 

interest_model1.class [cant upload with this extension - renamed to .txt - needs renaming back once downloaded]

interest_model2.class [cant upload with this extension - renamed to .txt - needs renaming back once downloaded]

interest_model.html

 

To run either download onto desktop or place on webserver. Click or URL to interest_model.html

 

Considerations:

 

1. Model is of the banking system as a whole - not an individual bank.

2. A loan or payment is not a single payment but ALL loans payments made in a period

3. Each loan/payment is given a number [1] to seperate them by period

4. Banks only lend from customer deposits - not from their own capital.

5. The reserve ratio is 5%

6. Interest amount in total on loan is 10% of principle.

7. Interest loan period is 10 period.

8. No defaults.

 

 

 

 

interest_model.html

interest_model1.txt

interest_model2.txt

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×