So admittedly, I have no idea what I'm doing, but I'm messing around with stuff I don't understand and ran into this. Sure I didn't intend for the algo to snowball it's investments into ever increasing order sizes. Sure I didn't intend for it to go almost a billion in debt either, but it ends above 4B in the green!
All that aside, I'm not sure how this is going into debt. Each order it places, it uses order_target_percent and the sum of the orders should never be greater than 1. It also sells of any positions that are not a part of the order. With an initial investment of 100k, how does it go almost a billion in debt?!?