Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Portfolio cash and capital_used suggestion

Hello,

Please consider updating the portfolio's cash and capital_used right after any order.

Thanks,

JM

6 responses

Hello JM,

The problem with updating the cash is that orders don't always go through, and you have the cash until they do. It's a tricky place if we "take away" cash that you actually have.

I agree that we need to give you easier tools to understand your current position, which is a combination of cash, stock, and open orders. Today you have to access them all separately. I have a little side project going where we can put it all together.

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.

Hello,

Ok, I understand, then it would be very important to update both of those everytime an order goes through.
In the case of backtesting (not real trading) I think it's easier.

Thanks,

JM

The backtester (and live trading) is "event driven" based on either daily or minute events.

Once your order is filled (or partially filled) the change will be reflected in the next event.

https://www.quantopian.com/faq#backtester
https://www.quantopian.com/help#ide-ordering

Joao, one of the neat things about Quantopian is that the algo you write for backtesting is the algo you use for live trading. There are a lot of systems out there where you do a bunch of coding for your backtest, then you have to do a bunch more coding for your live algo. It's a lot of extra work, and leaves room for many errors.

Our goal is to make it easy to code your algo, including cash and position management, and then use that algo in live trading.

Dan,

If the portfolio.cash and portfolio. capital_used is updated right after the order the money would set apart even if it doesn't get used that day, kinda of like a (unsettled_cash). Please forgive my newbie mindset.

The value of capital_used was changed to capital made, current cash compared to starting capital, or perhaps what some might call cash flow, I guess. I would ask that it be renamed as its moniker doesn't reflect what it actually is. Unfortunately right now, anyone using it in code would be well-advised to take time to write comments/explanations about it to try to avert confusion, for maintainable code. However it is likely no one is using it in its awkward state (when its function changed, no one complained because no one is using it) so it would seem any backward compatibility concerns would only apply to in-house tests or something.