It spent 1.3 billion and the returns value in the backtester does the calculation with an assumption that no more than the starting capital was utilized, disregards negative cash. I usually record context.portfolio.cash to keep myself in check along that line. Typically the sort of output above can be remedied roughly by skipping any bar/frame where orders are present (that's the line after def handle_data below). This needed more than that, so it has some additional code to help keep you limited to starting capital, and various options that some might find useful. PvR_Ret is a returns calculation based on profit versus risk that aims to provide a returns value only what was spent/risked no matter what the starting capital value is (same as the Quantopian returns below because amount spent close to the 1 million starting capital). Note you can click legend items in the custom chart to toggle them off/on, even here in the forums, to bring into scale whatever you're interested in, nice feature.