Profile Picture

Not enough cash to fill order

Posted By Freolad 9 Years Ago
Message
Posted Thursday November 06 2008
I'm running a backtest simulation over some small value stocks. I have plenty of capital assigned to the backtest ($500k) and am attempting to purchase 100,000 shares in a stock that has a share price of $0.0258. So total value of the order is $2,580. The order is placed ok however it gets cancelled on the next bar with the error message "Not enough cash to fill order".

What settings can make the PositionManager / Paper Broker decide not to fill the order like this?
Posted Thursday November 06 2008
Some additional data:
I've configured the position manager to allocate 20% by default. Normally I specify the size myself. But if I don't do this and instead let the position manager do it for me then it calculates that 20% of my starting capital ($500,000) is equivalent to 10,000 shares. So some part of the system thinks each share is valued at $10 when in fact each share is valued at $0.0258 (which is the limit price and also happens to be the open at the next day).
Posted Thursday November 06 2008
Replying to myself again:
The initial margin for the symbol is set to 10. I thought, from reading the documentation, that this was the percentage of the total position that must be paid from starting capital. But it seems that it is a fixed dollar amount. ie, for every share bought, this amount in dollars is paid to the broker. This doesn't make sense to me. If I'm buying a $0.50 share why should I pay $10 to the broker? A percentage makes more sense to me.

Can someone confirm the correct behaviour?
Posted Thursday November 06 2008
This is the correct behavior.  This is designed for futures where typically the initial margin is a fixed dollar amount.

Freolad (11/6/2008)
Replying to myself again:
The initial margin for the symbol is set to 10. I thought, from reading the documentation, that this was the percentage of the total position that must be paid from starting capital. But it seems that it is a fixed dollar amount. ie, for every share bought, this amount in dollars is paid to the broker. This doesn't make sense to me. If I'm buying a $0.50 share why should I pay $10 to the broker? A percentage makes more sense to me.

Can someone confirm the correct behaviour?
Posted Thursday November 06 2008
billb (11/6/2008)
This is the correct behavior. This is designed for futures where typically the initial margin is a fixed dollar amount.


I understand it might be the correct behaviour for futures but it doesn't make any sense for equities or fx. Why should the system require me to pay $10 to the broker - per share - if I'm buying a $0.0258 share? If my margin is 10%, then I should only be required to pay $0.00258 per share to the broker. Of course, I can manually adjust this margin before running the backtest simulation but then its fixed for the life of simulation and won't reflect an accurate percentage margin over the life of the backtest.
Posted Thursday November 06 2008
Wait a second, are we talking about margin or commissions?

Freolad (11/6/2008)
billb (11/6/2008)
This is the correct behavior. This is designed for futures where typically the initial margin is a fixed dollar amount.


I understand it might be the correct behaviour for futures but it doesn't make any sense for equities or fx. Why should the system require me to pay $10 to the broker - per share - if I'm buying a $0.0258 share? If my margin is 10%, then I should only be required to pay $0.00258 per share to the broker. Of course, I can manually adjust this margin before running the backtest simulation but then its fixed for the life of simulation and won't reflect an accurate percentage margin over the life of the backtest.
Posted Thursday November 06 2008
billb (11/6/2008)
Wait a second, are we talking about margin or commissions?


Initial margin.

Here's some extra data. I've bumped my starting capital up to $6,000,000. The initial margin for the equity symbol is set to 10.0. I placed a limit order for 65,104 shares with a limit price of $0.0256. The next day, in the simulation, the order was filled at my limit price. However, my current capital (SystemData.CurrentCapital) is now down to $5,348,960. ie, its down $651,040 when I've purchased shares worth a total of $1,666.66. Strangely my current equity (SystemData.CurrentEquity) says it is $651,040.

If I now change the initial capital setting for this symbol to 1.0 (instead of 10.0) then when I place the same trade my starting capital drops to $5,934,896 and my current equity is $65,064.

So my share portfolio seems to be valued at quantity * initial margin rather than quantity * share price.
Posted Thursday November 06 2008
We don't currently support a percentage-based margin.  Set the initial margin to zero in your symbol setup, and the cost to open a long position will be the price times the number of shares.

If you want to approximate the margin, you can multiply your starting capital by the margin factor.  So if you want to simulate a $500K account with a 10:1 margin, you would set the system starting capital to $5M.

Does this help?

Thanks,
Daniel

Posted Friday November 07 2008
Ah, it didn't even occur to me that I could set it to 0. I've done it now and it works fine.

Thanks for the work around and quick responses.


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems