It only sells one shares: (please see the screenshot via the link) screenshot Could you guys please advise where is wrong with my code? However, I met another problem: if I use above code, it will close out all the positions EVERYDAY and then long/short the same position the day after. Are there subsequent fills that eventually bring the position to zero? You should be able to do something like this: Hi Grant, Thanks so much for your advice.
Do you have any other ordering anywhere in your algo?In the majority of cases, this will deal with problems arising with margin requirements.When you sign up for a margin account with a brokerage firm, that firm obtains the legal right to liquidate your account when you are unable to meet the account's requirements.If an investor or trader holds a long position, the liquidation margin is equal to what the investor or trader would retain if the position was closed.If an investor or trader has a short position, the liquidation margin is equal to what the investor or trader would owe to purchase the stock or other trading instrument.Position liquidations within a cash account generally result from one of the following two situations: 1.
The account incurs a negative, or debit, cash balance due to the assessment of fees for items such as market data subscriptions or monthly minimums.
A margin account, on the other hand, allows investors to borrow money from a brokerage firm on top of the money they have placed in the account, usually up to 50%.
Therefore, if you have $5,000 in the account, you could potentially purchase $10,000 in securities.
Liquidation margin applies to investors or traders who use margin (leverage) to increase the potential profit of a trade.
When the equity of a margin account falls below the liquidation margin level requirement, the broker may automatically close any open positions in the account.
This is not the same as its debts being discharged, as happens when an individual files for Chapter 7.