Back to Community
Non-Trading (Do Not Trade) option

Hello,
I have a simple yet annoying problem:
When I choose not to trade (no buy/sell orders), the context.portfolio.portfolio_value always keeps changing like I was trading for real.
Is there a way not to trade so as the context.portfolio.portfolio_value will not update itself?

Also the cost_basis per stock changes as well.

Thank you very much

5 responses

Hi Tirath,

Your portfolio value can change if you are currently holding any positions, as the value of those positions can change. Is it possible that this is what's causing the updates that you're seeing?

The cost_basis will change if you place a new order for a position you already held. We don't currently have a good way of storing the cost_basis of positions that were established over multiple orders, it's something that's on our list to improve.

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.

@Jamie: So how exactly is cost_basis calculated?

@ André, cost_basis is calculated as "The volume-weighted average price paid (price and commission) per share in this position." (https://www.quantopian.com/help#api-position)

@Jamie: Then how is .vwap calculated? Suppose my buy order for 500 shares was filled with 100 shares at $50.01 and 400 at $50.05. Another order for 500 shares was filled at $50.00. Then I sold 50 shares. What was the volume-weighted average price, as calculated by Quantopian, after each of these operations?

@André, the .vwap() function doesn't include commission costs and uses pricing data instead of fill prices. In your example, I would expect the cost_basis to be $50.021 which comes from:

($50.01*100/1000) + ($50.05*400/1000) + ($50.00*500/1000)