Back

Issues with Alpaca Paper Trading Live

I recent developed a trading stratagy which has performed well within the quantConnect enviornment, and within quantConnect Live Paper trading. A main part of the stratagy requires issueing orders once every couple of seconds or so. So I then went to try running it on alpaca where I plan to actually run the code due to their 0 brokerage fee. However, when running it on alpaca paper account through QuantConnect, after 1 Order I get hit with the error:

Order Error: Insufficient buying power to complete order (Value:89738.84), Reason: Id: 4, Initial Margin: 89738.84, Free Margin: 10258.79

Where the Initial Margin Value is the value traded in the order. Looking on alpaca the first order successfully bought and sold.

It seems to me like that initial margin can't then be touched for a while, I can't trade with it. Any ideas as to why this might be?

I'm current using this as my buy command:

self.SetHoldings(stockToBuy, .9, True) 

Which I believe buys 90% of the selected stock

and this command to sell:

self.Liquidate(stockToSell)

Which I believe sells all stocks and cancels all order.

 

I'm fairly new to algo trading so any advice would be much appriciated.
Thanks!

Update Backtest







0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi Hogan, 

Alpaca only supports cash account, but not a margin account. In a cash account, all transactions must be made with available cash, which takes 3 days to clear after a trade. With a margin account, an investor would be able to borrow against the value of the assets in the account. In this way, an investor can use margin to leverage his/her positions. 

From the Order Error you posted, your strategy doesn't have sufficient available cash to fill the order. 

I hope this helps. 

Xin

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Thanks for your input Xin, and is that an issue on the quantconnect side of things, something which will at somepoint be potentially resolved once it's out of beta?

Because I was concerned something like that was the issue and as such I got in contact with alpaca and they had stated: 
"Alpaca brokerage accounts are Reg T margin accounts, proceeds from sales would be added back to your buying power immediately"

0

Hi Hogan,

Unfortunately, we don't support Alpaca margin account. And, we don't have a plan for that yet.

1

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed