Last active
August 10, 2020 04:20
-
-
Save flare9x/1f35f9369a6ad9339a575b995a2c1f3d to your computer and use it in GitHub Desktop.
Rolling equity and cash flow all real estate investments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Dates | |
using DataFrames | |
using Gadfly | |
using CSV | |
using Statistics | |
### methodology | |
# 1. amoritzation schedule per property | |
# 2. initial down payment + principal + any estimated equity due to renovations (conservative estimates) | |
# 3. account for any refinances - amooritization schedule for each and join | |
# 4. extend data set out to the mortage with the farthest out expiration date | |
# 5. discoutning any rent raise over time & property appreciation (generally with inflation)(in turn would increase cash flow and property valuations) | |
### | |
# todays data | |
t_date = round(today(), Dates.Month) | |
# Properties | |
high_meadow = "high_meadow" | |
ave_m = "ave_m" | |
ave_m_refi = "yes" # "yes", "no" | |
ave_o = "ave_o" | |
ave_m_half = "ave_m_half" | |
# square footage | |
high_mead_sq_ft = 1631.00 | |
ave_m_sq_ft = 2857.58 | |
ave_o_sq_ft = 2168.1 | |
ave_m_half_sq_ft = 2556 | |
high_mead_newVal = 135 * high_mead_sq_ft | |
ave_m_newVal = 116 * ave_m_sq_ft | |
ave_o_newVal = 110 * ave_o_sq_ft | |
ave_m_half_newVal = 110 * ave_m_half_sq_ft | |
high_mead_equity_raise = high_mead_newVal - 142000 | |
ave_m_equity_raise = ave_m_newVal - 225000 | |
ave_o_equity_raise = ave_o_newVal - 170000 | |
ave_m_half_equity_raise = ave_m_half_newVal - 215000 | |
high_mead_equity_raise + ave_m_equity_raise + ave_o_equity_raise + ave_m_half_equity_raise | |
# renovation dates | |
high_mead_reno_date = Date("2019-01-01", dateformat"y-m-d") | |
ave_m_reno_date = Date("2019-08-01", dateformat"y-m-d") | |
ave_o_reno_date = Date("2020-05-01", dateformat"y-m-d") | |
ave_m_half_reno_date = Date("2020-09-01", dateformat"y-m-d") | |
# purchase dates | |
high_mead_pur = Date("2016-11-04", dateformat"y-m-d") | |
high_mead_round_date = round(high_mead_pur, Dates.Month) | |
ave_m_pur = Date("2019-03-15", dateformat"y-m-d") | |
ave_m_round_date = Date("2019-04-01", dateformat"y-m-d") # pre paid the interest to the nearest date at closing | |
ave_m_refinance_date = Date("2020-05-27", dateformat"y-m-d") | |
ave_m_refinance_round_date = Date("2020-06-01", dateformat"y-m-d") | |
ave_o_pur = Date("2019-12-29", dateformat"y-m-d") | |
ave_o_round_date = Date("2020-01-01", dateformat"y-m-d") | |
ave_m_half_pur = Date("2020-08-25", dateformat"y-m-d") | |
ave_m_half_round_date = Date("2020-09-01", dateformat"y-m-d") | |
# date range | |
# ave_m_dr = collect(ave_m_pur:Month(1):Date(2015,2,3)) | |
# Create amoritzation schedule for each property | |
################################## | |
### 5015 Avenue M | |
################################## | |
## prior to refinance | |
# Step 1 - Gather the information you need to calculate the loan's amortization | |
property_value = 225000 | |
loan_amount = .75 | |
down_payment = property_value-(loan_amount * property_value) | |
debt_borrowed = property_value - down_payment | |
interest_rate = 0.05625 # annual interest rate | |
loan_term = 360 # months | |
ave_m_dr = collect(ave_m_round_date:Month(1):(Date(ave_m_round_date)+Dates.Month(358))) | |
# Calculate the principal / interest over the loan term | |
# Initialize outputs | |
remaining_loan_amount = collect(1.0:1.0:loan_term-1) | |
interest = zeros(size(remaining_loan_amount,1)) | |
principal = zeros(size(remaining_loan_amount,1)) | |
interest_principal = zeros(size(remaining_loan_amount,1)) | |
total_equity = zeros(size(remaining_loan_amount,1)) | |
# for loop to create amortization schedule | |
i=1 | |
for i = 1:size(remaining_loan_amount,1) | |
# set the first row at 1 = 1 - this is the first principal and interest payment | |
if i == 1 | |
I = debt_borrowed *(interest_rate/12) # note converting annual interest to monthly (interest_rate/12) | |
P = (I / (1-(1/(1+interest_rate/12)^(loan_term)))) - I # Calculate the interest + principal then subtract interest | |
IP = I + P | |
interest[i] = I | |
principal[i] = P | |
interest_principal[i] = IP | |
remaining_loan_amount[i] = debt_borrowed - P | |
total_equity[i] = down_payment | |
else | |
# Using the data from the first row - continue to pay down princial and debt | |
I = remaining_loan_amount[i-1] *(interest_rate/12) # note converting annual interest to monthly (interest_rate/12) | |
P = (I / (1-(1/(1+interest_rate/12)^(loan_term-i)))) - I # Calculate the interest + principal then subtract interest also note loan_term-i = reducing the loan term through the course of the loan | |
IP = I + P | |
interest[i] = I | |
principal[i] = P | |
interest_principal[i] = IP | |
remaining_loan_amount[i] = remaining_loan_amount[i-1] - P | |
total_equity[i] = total_equity[i-1] + P | |
print("This is Month",i,"\nAmoritization Schedule\n") | |
end | |
end | |
# rolling sums | |
cumsum_interest = cumsum(interest) | |
cumsum_principal = cumsum(principal) | |
cumsum_interest_principal = cumsum(interest_principal) | |
cumsum_remaining_loan_amount = cumsum(remaining_loan_amount) | |
# build data frames | |
labels = fill(ave_m,size(total_equity,1)) | |
df = hcat(ave_m_dr,interest,principal,interest_principal,remaining_loan_amount,cumsum_interest,cumsum_principal,cumsum_interest_principal,total_equity,labels) | |
names = ["date","interest","principal","interest_principal","remaining_loan_amount","cumulative_interest","cumulative_principal","cumulative_interest_principal","total_equity","labels"] | |
ave_m_df = DataFrame(df) | |
rename!(ave_m_df, names) | |
### refinance | |
# Step 1 - Gather the information you need to calculate the loan's amortization | |
property_value = 225000 | |
loan_amount = .75 | |
down_payment = property_value-(loan_amount * property_value) | |
debt_borrowed = 177616 # per closing dicosure | |
interest_rate = 0.03625 # annual interest rate | |
loan_term = 360 # months | |
ave_m_dr = collect(ave_m_refinance_round_date:Month(1):(Date(ave_m_refinance_round_date)+Dates.Month(358))) | |
# Calculate the principal / interest over the loan term | |
# Initialize outputs | |
remaining_loan_amount = collect(1.0:1.0:loan_term-1) | |
interest = zeros(size(remaining_loan_amount,1)) | |
principal = zeros(size(remaining_loan_amount,1)) | |
interest_principal = zeros(size(remaining_loan_amount,1)) | |
total_equity = zeros(size(remaining_loan_amount,1)) | |
# for loop to create amortization schedule | |
i=1 | |
for i = 1:size(remaining_loan_amount,1) | |
# set the first row at 1 = 1 - this is the first principal and interest payment | |
if i == 1 | |
I = debt_borrowed *(interest_rate/12) # note converting annual interest to monthly (interest_rate/12) | |
P = (I / (1-(1/(1+interest_rate/12)^(loan_term)))) - I # Calculate the interest + principal then subtract interest | |
IP = I + P | |
interest[i] = I | |
principal[i] = P | |
interest_principal[i] = IP | |
remaining_loan_amount[i] = debt_borrowed - P | |
total_equity[i] = down_payment | |
else | |
# Using the data from the first row - continue to pay down princial and debt | |
I = remaining_loan_amount[i-1] *(interest_rate/12) # note converting annual interest to monthly (interest_rate/12) | |
P = (I / (1-(1/(1+interest_rate/12)^(loan_term-i)))) - I # Calculate the interest + principal then subtract interest also note loan_term-i = reducing the loan term through the course of the loan | |
IP = I + P | |
interest[i] = I | |
principal[i] = P | |
interest_principal[i] = IP | |
remaining_loan_amount[i] = remaining_loan_amount[i-1] - P | |
total_equity[i] = total_equity[i-1] + P | |
print("This is Month",i,"\nAmoritization Schedule\n") | |
end | |
end | |
# rolling sums | |
cumsum_interest = cumsum(interest) | |
cumsum_principal = cumsum(principal) | |
cumsum_interest_principal = cumsum(interest_principal) | |
cumsum_remaining_loan_amount = cumsum(remaining_loan_amount) | |
# build data frames | |
labels = fill(ave_m,size(total_equity,1)) | |
df_refi = hcat(ave_m_dr,interest,principal,interest_principal,remaining_loan_amount,cumsum_interest,cumsum_principal,cumsum_interest_principal,total_equity,labels) | |
names = ["date","interest","principal","interest_principal","remaining_loan_amount","cumulative_interest","cumulative_principal","cumulative_interest_principal","total_equity","labels"] | |
ave_m_df_refi = DataFrame(df_refi) | |
rename!(ave_m_df_refi, names) | |
# Split data frames to make one to account for the refinance | |
df_1 = ave_m_df[(ave_m_df[:date].<ave_m_refinance_round_date),:] | |
df_final = append!(df_1,ave_m_df_refi) | |
df_final.cumulative_interest = cumsum(df_final.interest) | |
df_final.cumulative_principal = cumsum(df_final.principal) | |
df_final.cumulative_interest_principal = cumsum(df_final.interest_principal) | |
df_final.total_equity[1] = down_payment | |
for i = 2:size(df_final.total_equity,1) | |
df_final.total_equity[i] = df_final.total_equity[i-1] + df_final.principal[i] | |
end | |
df_final.total_equity_newVal = zeros(size(df_final.total_equity,1)) | |
index_pos = findfirst(isequal(ave_m_reno_date), df_final.date) | |
i=6 | |
for i = 1:size(df_final.total_equity_newVal,1) | |
if i < index_pos | |
df_final.total_equity_newVal[i] = df_final.total_equity[i] | |
else | |
df_final.total_equity_newVal[i] = (ave_m_newVal - property_value) + df_final.total_equity[i] | |
end | |
end | |
# plot data using gadfly | |
plot(x=df_final.date,y=df_final.total_equity,Scale.y_continuous(format=:plain),Geom.line) | |
# obtain ytd total equity | |
index_pos = findfirst(isequal(t_date), df_final.date) | |
ave_m_total_equity = df_final.total_equity[index_pos] | |
################################## | |
### 3719 avenue o | |
################################## | |
# Step 1 - Gather the information you need to calculate the loan's amortization | |
property_value = 170000 | |
loan_amount = .75 | |
down_payment = property_value-(loan_amount * property_value) | |
debt_borrowed = property_value - down_payment | |
interest_rate = 0.05125 # annual interest rate | |
loan_term = 360 # months | |
ave_o_dr = collect(ave_o_round_date:Month(1):(Date(ave_o_round_date)+Dates.Month(358))) | |
# Calculate the principal / interest over the loan term | |
# Initialize outputs | |
remaining_loan_amount = collect(1.0:1.0:loan_term-1) | |
interest = zeros(size(remaining_loan_amount,1)) | |
principal = zeros(size(remaining_loan_amount,1)) | |
interest_principal = zeros(size(remaining_loan_amount,1)) | |
total_equity = zeros(size(remaining_loan_amount,1)) | |
# for loop to create amortization schedule | |
i=1 | |
for i = 1:size(remaining_loan_amount,1) | |
# set the first row at 1 = 1 - this is the first principal and interest payment | |
if i == 1 | |
I = debt_borrowed *(interest_rate/12) # note converting annual interest to monthly (interest_rate/12) | |
P = (I / (1-(1/(1+interest_rate/12)^(loan_term)))) - I # Calculate the interest + principal then subtract interest | |
IP = I + P | |
interest[i] = I | |
principal[i] = P | |
interest_principal[i] = IP | |
remaining_loan_amount[i] = debt_borrowed - P | |
total_equity[i] = down_payment | |
else | |
# Using the data from the first row - continue to pay down princial and debt | |
I = remaining_loan_amount[i-1] *(interest_rate/12) # note converting annual interest to monthly (interest_rate/12) | |
P = (I / (1-(1/(1+interest_rate/12)^(loan_term-i)))) - I # Calculate the interest + principal then subtract interest also note loan_term-i = reducing the loan term through the course of the loan | |
IP = I + P | |
interest[i] = I | |
principal[i] = P | |
interest_principal[i] = IP | |
remaining_loan_amount[i] = remaining_loan_amount[i-1] - P | |
total_equity[i] = total_equity[i-1] + P | |
print("This is Month",i,"\nAmoritization Schedule\n") | |
end | |
end | |
# rolling sums | |
cumsum_interest = cumsum(interest) | |
cumsum_principal = cumsum(principal) | |
cumsum_interest_principal = cumsum(interest_principal) | |
cumsum_remaining_loan_amount = cumsum(remaining_loan_amount) | |
# build data frames | |
labels = fill(ave_o,size(total_equity,1)) | |
df = hcat(ave_o_dr,interest,principal,interest_principal,remaining_loan_amount,cumsum_interest,cumsum_principal,cumsum_interest_principal,total_equity,labels) | |
names = ["date","interest","principal","interest_principal","remaining_loan_amount","cumulative_interest","cumulative_principal","cumulative_interest_principal","total_equity","labels"] | |
ave_o_df = DataFrame(df) | |
rename!(ave_o_df, names) | |
ave_o_df.total_equity[1] = down_payment | |
for i = 2:size(ave_o_df.total_equity,1) | |
ave_o_df.total_equity[i-1] = ave_o_df.total_equity[i-1] + ave_o_df.principal[i] | |
end | |
ave_o_df.total_equity_newVal = zeros(size(ave_o_df.total_equity,1)) | |
index_pos = findfirst(isequal(ave_o_reno_date), ave_o_df.date) | |
for i = 1:size(ave_o_df.total_equity_newVal,1) | |
if i < index_pos | |
ave_o_df.total_equity_newVal[i] = ave_o_df.total_equity[i] | |
else | |
ave_o_df.total_equity_newVal[i] = (ave_o_newVal - property_value) + ave_o_df.total_equity[i] | |
end | |
end | |
# obtain ytd total equity | |
index_pos = findfirst(isequal(t_date), ave_o_df.date) | |
ave_m_total_equity = ave_o_df.total_equity[index_pos] | |
################################## | |
### high meadow | |
################################## | |
# Step 1 - Gather the information you need to calculate the loan's amortization | |
property_value = 142000 | |
loan_amount = .8 | |
down_payment = property_value-(loan_amount * property_value) | |
debt_borrowed = property_value - down_payment | |
interest_rate = 0.0399 # annual interest rate | |
loan_term = 360 # months | |
high_mead_dr = collect(high_mead_round_date:Month(1):(Date(high_mead_round_date)+Dates.Month(358))) | |
# Calculate the principal / interest over the loan term | |
# Initialize outputs | |
remaining_loan_amount = collect(1.0:1.0:loan_term-1) | |
interest = zeros(size(remaining_loan_amount,1)) | |
principal = zeros(size(remaining_loan_amount,1)) | |
interest_principal = zeros(size(remaining_loan_amount,1)) | |
total_equity = zeros(size(remaining_loan_amount,1)) | |
# for loop to create amortization schedule | |
i=1 | |
for i = 1:size(remaining_loan_amount,1) | |
# set the first row at 1 = 1 - this is the first principal and interest payment | |
if i == 1 | |
I = debt_borrowed *(interest_rate/12) # note converting annual interest to monthly (interest_rate/12) | |
P = (I / (1-(1/(1+interest_rate/12)^(loan_term)))) - I # Calculate the interest + principal then subtract interest | |
IP = I + P | |
interest[i] = I | |
principal[i] = P | |
interest_principal[i] = IP | |
remaining_loan_amount[i] = debt_borrowed - P | |
total_equity[i] = down_payment | |
else | |
# Using the data from the first row - continue to pay down princial and debt | |
I = remaining_loan_amount[i-1] *(interest_rate/12) # note converting annual interest to monthly (interest_rate/12) | |
P = (I / (1-(1/(1+interest_rate/12)^(loan_term-i)))) - I # Calculate the interest + principal then subtract interest also note loan_term-i = reducing the loan term through the course of the loan | |
IP = I + P | |
interest[i] = I | |
principal[i] = P | |
interest_principal[i] = IP | |
remaining_loan_amount[i] = remaining_loan_amount[i-1] - P | |
total_equity[i] = total_equity[i-1] + P | |
print("This is Month",i,"\nAmoritization Schedule\n") | |
end | |
end | |
# rolling sums | |
cumsum_interest = cumsum(interest) | |
cumsum_principal = cumsum(principal) | |
cumsum_interest_principal = cumsum(interest_principal) | |
cumsum_remaining_loan_amount = cumsum(remaining_loan_amount) | |
# build data frames | |
labels = fill(high_meadow,size(total_equity,1)) | |
df = hcat(high_mead_dr,interest,principal,interest_principal,remaining_loan_amount,cumsum_interest,cumsum_principal,cumsum_interest_principal,total_equity,labels) | |
names = ["date","interest","principal","interest_principal","remaining_loan_amount","cumulative_interest","cumulative_principal","cumulative_interest_principal","total_equity","labels"] | |
high_mead_df = DataFrame(df) | |
rename!(high_mead_df, names) | |
# calculate final equity inclsuive of princiapl and downpayment | |
high_mead_df.total_equity[1] = down_payment | |
for i = 2:size(high_mead_df.total_equity,1) | |
high_mead_df.total_equity[i-1] = high_mead_df.total_equity[i-1] + high_mead_df.principal[i] | |
end | |
high_mead_df.total_equity_newVal = zeros(size(high_mead_df.total_equity,1)) | |
index_pos = findfirst(isequal(high_mead_reno_date), high_mead_df.date) | |
for i = 1:size(high_mead_df.total_equity_newVal,1) | |
if i < index_pos | |
high_mead_df.total_equity_newVal[i] = high_mead_df.total_equity[i] | |
else | |
high_mead_df.total_equity_newVal[i] = (high_mead_newVal - property_value) + high_mead_df.total_equity[i] | |
end | |
end | |
# obtain ytd total equity | |
index_pos = findfirst(isequal(t_date), high_mead_df.date) | |
high_mead_df_total_equity = high_mead_df.total_equity[index_pos] | |
################################## | |
### 5328 ave m half | |
################################## | |
# Step 1 - Gather the information you need to calculate the loan's amortization | |
property_value = 215000 | |
loan_amount = .75 | |
down_payment = property_value-(loan_amount * property_value) | |
debt_borrowed = property_value - down_payment | |
interest_rate = 0.035 # annual interest rate | |
loan_term = 360 # months | |
ave_m_half_dr = collect(ave_m_half_round_date:Month(1):(Date(ave_m_half_round_date)+Dates.Month(358))) | |
# Calculate the principal / interest over the loan term | |
# Initialize outputs | |
remaining_loan_amount = collect(1.0:1.0:loan_term-1) | |
interest = zeros(size(remaining_loan_amount,1)) | |
principal = zeros(size(remaining_loan_amount,1)) | |
interest_principal = zeros(size(remaining_loan_amount,1)) | |
total_equity = zeros(size(remaining_loan_amount,1)) | |
# for loop to create amortization schedule | |
i=1 | |
for i = 1:size(remaining_loan_amount,1) | |
# set the first row at 1 = 1 - this is the first principal and interest payment | |
if i == 1 | |
I = debt_borrowed *(interest_rate/12) # note converting annual interest to monthly (interest_rate/12) | |
P = (I / (1-(1/(1+interest_rate/12)^(loan_term)))) - I # Calculate the interest + principal then subtract interest | |
IP = I + P | |
interest[i] = I | |
principal[i] = P | |
interest_principal[i] = IP | |
remaining_loan_amount[i] = debt_borrowed - P | |
total_equity[i] = down_payment | |
else | |
# Using the data from the first row - continue to pay down princial and debt | |
I = remaining_loan_amount[i-1] *(interest_rate/12) # note converting annual interest to monthly (interest_rate/12) | |
P = (I / (1-(1/(1+interest_rate/12)^(loan_term-i)))) - I # Calculate the interest + principal then subtract interest also note loan_term-i = reducing the loan term through the course of the loan | |
IP = I + P | |
interest[i] = I | |
principal[i] = P | |
interest_principal[i] = IP | |
remaining_loan_amount[i] = remaining_loan_amount[i-1] - P | |
total_equity[i] = total_equity[i-1] + P | |
print("This is Month",i,"\nAmoritization Schedule\n") | |
end | |
end | |
# rolling sums | |
cumsum_interest = cumsum(interest) | |
cumsum_principal = cumsum(principal) | |
cumsum_interest_principal = cumsum(interest_principal) | |
cumsum_remaining_loan_amount = cumsum(remaining_loan_amount) | |
# build data frames | |
labels = fill(ave_m_half,size(total_equity,1)) | |
df = hcat(ave_m_half_dr,interest,principal,interest_principal,remaining_loan_amount,cumsum_interest,cumsum_principal,cumsum_interest_principal,total_equity,labels) | |
names = ["date","interest","principal","interest_principal","remaining_loan_amount","cumulative_interest","cumulative_principal","cumulative_interest_principal","total_equity","labels"] | |
ave_m_half_df = DataFrame(df) | |
rename!(ave_m_half_df, names) | |
# calculate final equity inclsuive of princiapl and downpayment | |
ave_m_half_df.total_equity[1] = down_payment | |
for i = 2:size(ave_m_half_df.total_equity,1) | |
ave_m_half_df.total_equity[i-1] = ave_m_half_df.total_equity[i-1] + ave_m_half_df.principal[i] | |
end | |
ave_m_half_df.total_equity_newVal = zeros(size(ave_m_half_df.total_equity,1)) | |
index_pos = findfirst(isequal(ave_m_half_reno_date), ave_m_half_df.date) | |
for i = 1:size(ave_m_half_df.total_equity_newVal,1) | |
if i < index_pos | |
ave_m_half_df.total_equity_newVal[i] = ave_m_half_df.total_equity[i] | |
else | |
ave_m_half_df.total_equity_newVal[i] = (ave_m_half_newVal - property_value) + ave_m_half_df.total_equity[i] | |
end | |
end | |
# obtain ytd total equity | |
#index_pos = findfirst(isequal(t_date), ave_m_half_df.date) | |
#ave_m_half_df_total_equity = ave_m_half_df.total_equity[index_pos] | |
################# | |
# join data frames for total rolling equity | |
################# | |
all_df = join(high_mead_df, df_final, on = :date, kind = :outer,makeunique = true) | |
all_df.all_equity = all_df.total_equity .+ all_df.total_equity_1 | |
all_df = join(all_df, ave_o_df, on = :date, kind = :outer,makeunique = true) | |
all_df.all_equity = all_df.all_equity .+ all_df.total_equity_2 | |
all_df = join(all_df, ave_m_half_df, on = :date, kind = :outer,makeunique = true) | |
all_df = coalesce.(all_df, 0.0) | |
# carry forward final equities post mortgage pay off | |
for i = 2:nrow(all_df) | |
if all_df.total_equity[i-1] != 0.0 && all_df.total_equity[i] == 0.0 | |
all_df.total_equity[i] = all_df.total_equity[i-1] | |
end | |
if all_df.total_equity_1[i-1] != 0.0 && all_df.total_equity_1[i] == 0.0 | |
all_df.total_equity_1[i] = all_df.total_equity_1[i-1] | |
end | |
if all_df.total_equity_2[i-1] != 0.0 && all_df.total_equity_2[i] == 0.0 | |
all_df.total_equity_2[i] = all_df.total_equity_2[i-1] | |
end | |
if all_df.total_equity_3[i-1] != 0.0 && all_df.total_equity_3[i] == 0.0 | |
all_df.total_equity_3[i] = all_df.total_equity_3[i-1] | |
end | |
# new vals | |
if all_df.total_equity_newVal[i-1] != 0.0 && all_df.total_equity_newVal[i] == 0.0 | |
all_df.total_equity_newVal[i] = all_df.total_equity_newVal[i-1] | |
end | |
if all_df.total_equity_newVal_1[i-1] != 0.0 && all_df.total_equity_newVal_1[i] == 0.0 | |
all_df.total_equity_newVal_1[i] = all_df.total_equity_newVal_1[i-1] | |
end | |
if all_df.total_equity_newVal_2[i-1] != 0.0 && all_df.total_equity_newVal_2[i] == 0.0 | |
all_df.total_equity_newVal_2[i] = all_df.total_equity_newVal_2[i-1] | |
end | |
if all_df.total_equity_newVal_3[i-1] != 0.0 && all_df.total_equity_newVal_3[i] == 0.0 | |
all_df.total_equity_newVal_3[i] = all_df.total_equity_newVal_3[i-1] | |
end | |
end | |
all_df.all_equity = all_df.total_equity .+ all_df.total_equity_1 .+ all_df.total_equity_2 .+ all_df.total_equity_3 # sum all ending equity | |
all_df.all_equity_newVal = all_df.total_equity_newVal .+ all_df.total_equity_newVal_1 .+ all_df.total_equity_newVal_2 .+ all_df.total_equity_newVal_3 # sum all ending equity | |
# find total equity across all properties YTD | |
index_pos = findfirst(isequal(t_date+Dates.Month(1)), all_df.date) | |
all_df_total_equity = all_df.all_equity[index_pos] | |
line_1 = all_df.all_equity | |
label_1 = fill("all_equity",size(line_1,1)) | |
line_2 = all_df.all_equity_newVal | |
label_2 = fill("all_equity_post_renovation",size(line_2,1)) | |
label_plot = vcat(label_1,label_2) | |
all_plot = vcat(line_1,line_2) | |
plot_df = DataFrame(hcat(label_plot,all_plot)) | |
names = ["data","label"] | |
rename!(plot_df,names) | |
# plot data using gadfly | |
theticks = collect(0:100000:Int64.(round(maximum(all_df.all_equity_newVal),digits=0))) | |
plot(layer(x=all_df.date,y=all_df.all_equity,Geom.line, Theme(default_color=colorant"blue"), | |
xintercept=[high_mead_round_date,ave_m_round_date,ave_o_round_date,ave_m_half_round_date], Geom.vline(color=["red","red","red","red"])), | |
layer(x=all_df.date,y=all_df.all_equity_newVal,Geom.line,Theme(default_color=colorant"green")), | |
Scale.y_continuous(format=:plain), | |
Theme(background_color="white"), | |
Guide.title("Real estate total equity as a function of time"), | |
Guide.xlabel("Time"), | |
Guide.ylabel("Equity"), | |
Guide.yticks(ticks = theticks)) | |
# subset data frame | |
subset_df = all_df[(all_df[:date].< (t_date+Dates.Month(2))),:] | |
theticks = collect(0:100000:Int64.(round(maximum(subset_df.all_equity_newVal)+100000,digits=0))) | |
plot(layer(x=subset_df.date,y=subset_df.all_equity,Geom.line, Theme(default_color=colorant"blue"), | |
xintercept=[high_mead_round_date,ave_m_round_date,ave_o_round_date,ave_m_half_round_date], Geom.vline(color=["red","red","red","red"])), | |
layer(x=subset_df.date,y=subset_df.all_equity_newVal,Geom.line,Theme(default_color=colorant"green")), | |
Scale.y_continuous(format=:plain), | |
Theme(background_color="white"), | |
Guide.title("Real estate total equity as a function of time"), | |
Guide.xlabel("Time"), | |
Guide.ylabel("Equity"), | |
Guide.yticks(ticks = theticks), | |
Guide.manual_color_key("Legend", ["Initial Equity", "Equity Post Renovation"], ["blue", "green"])) | |
# rate of change | |
length_of_time = (subset_df.date[size(subset_df.date,1)] - subset_df.date[1]) | |
monthly_ROC = (subset_df.all_equity_newVal[size(subset_df.all_equity_newVal,1)] - subset_df.all_equity_newVal[1]) / 56.76 # change in $ / time | |
length_of_time = (subset_df.date[size(subset_df.date,1)] - subset_df.date[1]) | |
monthly_ROC = (subset_df.all_equity[size(subset_df.all_equity,1)] - subset_df.all_equity[1]) / 56.76 # change in $ / time | |
#################################### | |
# Cash flow | |
################################### | |
# export to .csv | |
# CSV.write("C:/Users/Andrew.Bannerman/Desktop/Real Estate/All_Properties/all_df.csv", all_df;delim=',') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment