@MNH, it seems like the order is going through to me. One point of clarification, if you place an order in the current day, the simulation won't fill it until the next trading day, and it doesn't reach your portfolio positions until the day after that. I just re-ran your algorithm, with logging for the current cash and positions at the top of the method. Here is the first few lines of the logs:
2012-01-04handle_data:14INFOcurrent cash: 1000000.0
2012-01-04handle_data:15INFOcurrent holdings: ndict({8554: ndict({'amount': 0, 'last_sale_price': 127.68, 'cost_basis': 0.0, 'sid': 8554})})
2012-01-04handle_data:19INFOFirst day price is 127.68
2012-01-04handle_data:21INFOStarting with 1000000.0
2012-01-04handle_data:23INFOFirst Order Value: 500000
2012-01-04handle_data:26INFOFirst Order Size: 3916
2012-01-04handle_data:28INFOStock is: Security(8554)
2012-01-04handle_data:36INFONext Buy Price: 126.4032
2012-01-04handle_data:37INFONext Sell Price: 128.9568
2012-01-05handle_data:14INFOcurrent cash: 1000000.0
2012-01-05handle_data:15INFOcurrent holdings: ndict({8554: ndict({'amount': 0, 'last_sale_price': 128.06, 'cost_basis': 0.0, 'sid': 8554})})
2012-01-06handle_data:14INFOcurrent cash: 499574.359947
2012-01-06handle_data:15INFOcurrent holdings: ndict({8554: ndict({'amount': 3916, 'last_sale_price': 127.79, 'cost_basis': 127.79000001364061, 'sid': 8554})})
You can see that you are placing an order for 3916 shares on 1/4, and then when you print the portfolio positions (last line) on 1/06.
That's the current intended behavior, but typing it out here, I think we may be too conservative in our assumptions about placing and filling orders. We are using the same approach with minute bar simulations. Maybe we should consider reporting the order's fill in the same bar as when we calculate the transaction. Today we do that after giving the event to your algorithm. Any thoughts?
Disclaimer
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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.