Partial fills happen with limits on the number of shares that can be traded in a particular minute based on the slippage model in use, in the effort for backtesting to match the real world (to whatever degree possible). They are based on each minute's volume for each stock.
Sometimes when a stock is ordered, its volume throughout that day is so low (and the order so high) that partial fills run all the way to the end of the day. That produces log messages like this, that most are familiar with (from lecture 43, basic pairs):
2014-01-02 13:00 WARN Your order for -346741 shares of ABGB failed to fill by the end of day and was canceled.
2014-01-02 13:00 WARN Your order for 87260 shares of FSLR has been partially filled. 17663 shares were successfully purchased. 69597 shares were not filled by the end of day and were canceled.
2014-01-03 13:00 WARN Your order for -338361 shares of ABGB has been partially filled. 2 shares were successfully sold. 338359 shares were not filled by the end of day and were canceled.
In orders from get_open_orders(), .amount is the total number of shares ordered originally and .filled is the total number of shares filled so far.
Cost basis is updated with each partial fill. context.portfolio.positions[stock].cost_basis
My impression so far is that drawdown (and all metrics) can be improved by handling partial fills. If the price is moving against us while fills are happening, it contributes to drawdowns. When there are a lot of partial fills on opening an order, it's a hint that closing the order can also be difficult, so a cutoff point on opening a position is one route. Many strategies for addressing partial fills can be employed.
This is an invite for ideas because I worry that the majority of us are oblivious to the magnitude of partial fills and just hoping for the best. I'll have more to add to this.