Hello Svenn! Glad you like the site.
I wrote up a short description on how this works in our FAQ.
Our backtester runs an event loop once per historical minute. Every
run of the loop loads the data for that minute and executes your
algorithm. If the algorithm calls for a buy or a sell, that order is
placed. If there are any open orders, the backtester attempts to fill
them. (Note, an order that is placed in one event loop is not filled
in that loop; it is filled in the next loop. That prevents any
look-ahead bias from leaking into your algorithm.)
In your case, you're running "one day" event loops instead of "one minute" event loops, but the same principle applies.
That said, you're running into a gap in our feature set. We let you probe your stock and cash positions and all that, but we don't yet have a way for you to see your open orders. I think what we should be doing is letting you see your order in loop 2, so you know that it might be filled, and then showing you the filled order in loop 3. For now, you might want to build your own order tracking system in your code. The problem will be if the order isn't filled for some reason (like, not enough volume), and then your portfolio and your order tracker will need to resolve it. Really, we need to just fix this for you ;)
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.