Hi -  I am new to the platform, and certainly able to do more than i understand so far.

I have an algorithm running live, that works well when it works, but often fails due to the number of shares and the total funds in my account.  I receive the error message back from IB stating that:

Order rejected - reason:YOUR ORDER IS NOT ACCEPTED. IN ORDER TO OBTAIN THE DESIRED POSITION YOUR EQUITY WITH LOAN VALUE [$$$$ USD] MUST EXCEED THE INITIAL MARGIN [$$$$ USD]

My logic for choosing how many shares to purchase is pretty basic and is:

(Portfolio.Cash * AllocationPercent) / SharePrice

This essentially takes a fraction of my available cash (75%) and uses that for the limit order, which is a Short position at the current price. of the stock

Sometimes it works, sometimes it doesn't, it appears that certain stocks may require more available funds, but I am unable to understand how to better calculate how many shares to purchase.  

Help would be very appreciated.  i believe IB gives me 4X leverage, so i would expect to be able to enter these types of orders without problem.