During Alpaca live paper trading I received the following messages:

2019-09-10 13:41:59 New Order Event: Time: 9/10/2019 1:41:59 PM OrderID: 2 Symbol: ERIE Status: PartiallyFilled Quantity: 17 FillPrice: 210.84 USD Message: Alpaca Fill Event
2019-09-10 13:41:59 New Order Event: Time: 9/10/2019 1:41:59 PM OrderID: 2 Symbol: ERIE Status: Filled Quantity: 23 FillPrice: 210.84 USD Message: Alpaca Fill Event
2019-09-10 13:42:00 New Order Event: Time: 9/10/2019 1:42:00 PM OrderID: 4 Symbol: ERIE Status: Invalid Message: Error placing order: insufficient qty (23 < 40)
 

My interpretation: LEAN engine assumes that I own 40 shares, and my algo is trying to sell them.

Alpaca knows that I own 23 shares, and rejects the sell order.

It looks like LEAN engine interprets Alpaca partial fills incorrectly.