Skip to content

Instantly share code, notes, and snippets.

@Joshuaek
Created March 4, 2020 21:47
Show Gist options
  • Save Joshuaek/fa5a71dd76b53ff729e3482d39ca9d79 to your computer and use it in GitHub Desktop.
Save Joshuaek/fa5a71dd76b53ff729e3482d39ca9d79 to your computer and use it in GitHub Desktop.
def add_contract(self, contract):
# Adds a new contract to the forecast
self.df[contract.contract_name] = np.zeros(self.number_of_months)
self.contracts.append(contract)
for m in range(contract.start_month, contract.start_month + contract.term, contract.payment_frequency):
try:
increase = (contract.increase_percentage * int(m / contract.increase_period) / 100) * contract.value
self.df.loc[self.months[m]][contract.contract_name] = contract.value + increase
self.df.loc[self.months[m]]['live_contracts'] += 1
except IndexError:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment