I've written an algorithm using SetBrokerageModel(BrokerageName.Alpaca, AccountType.Cash); It runs every market open and uses MACD to decide whether to be in SPY or TLT. I use SetHoldings(...) to accomplish this setting one to 0 and the other to less than 1.0 (I've tried various values). However, when it runs, I routinely get "Insufficient buying power to complete order" for a period of 4 days, then the order is filled. I'm assuming this means the model requires 4 days after a sell for funds to settle before the cash is available for buy? But reading the Alpaca docs, I dont' see where this is the case. My understanding is that the results of a sell should be available as "buying power" immediately after it is filled. What am I missing here? Algorithm below...
https://www.quantconnect.com/terminal/processCache?request=embedded_backtest_fef4081514e053a7fbca784a4133dcc0.html