Investment Model

Gloria Serra Coch
Data Mining the City
1 min readNov 3, 2017

Adding the Mortgage Cost

from person import *
import csv
def setup():
size(800,800)

global population, memberStakeAmount, mortgageCosts, individualInvestorSize, imgs, indexNum, mortgageCost

indexNum = 0
imgs = []
for i in xrange(9):
img = loadImage(str(i)+".jpg")
imgs.append(img)

with open("CHITexample.csv") as f:
reader = csv.reader(f)
header = reader.next() # Skip the header row.

mortgageCosts = []

for row in reader:
mortgageCost = float(row[4])
mortgageCosts.append(mortgageCost)


population = []

memberStakeAmount = 2000

individualInvestorSize = round(mortgageCost/memberStakeAmount)+1
for i in xrange(individualInvestorSize):
p = Person(memberStakeAmount)
population.append(p)
def draw():
pass
def keyPressed():
global population, memberStakeAmount, mortgageCosts, individualInvestorSize, imgs, indexNum

background(255)
noStroke()
fill(200,200,200)
ellipse(width/2,height/2,width / 1.5,width / 1.5)

for p in population:
p.draw()

textSize(32)
if indexNum <= 9:
indexNum+=1
print(mortgageCosts[indexNum])
else:
indexNum = 1
text("total mortgage cost: $" + str(mortgageCosts[indexNum]), 20, 30)
fill(0,150,50)
text("number of buyers: " + str(individualInvestorSize) + ' at: $' + str(memberStakeAmount) +' each', 20, height-70)
image(imgs[indexNum],width-100,0, 100,100)

--

--