Github diff showing addition of code: def _get_change()-> Decimal: daily_volume = current_session().query(func.sum(Trade.size * Trade.price)).filter( Trade.created_at > datetime.now() - timedelta(days=1)).scalar() or Decimal() return f2d(numpy.random.normal(7500, 3000))* daily_volume / Decimal('1e9') @always_run_in_transaction(ro=False) def update_public_insurance_fund(): change = _get_change() sess = current_session() + public_insurance_fund = Public InsuranceFund.get(sess) sess.add(Public InsuranceFundChange(public_insurance_fund-public_insurance_fund, size-change)) public_insurance_fund.size += change sess.commit()
https://media.hachyderm.io/media_attachments/files/111/195/065/415/152/843/original/c05e502153767407.png