Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
AMD, buy the dip and sell on price consolidating upwards

AMD, buy the dips and sell on price moving up

9 responses

What is Benchmark?

Emiliano, isn't the default just SPY?

It looks like your max_notational is off by a factor of ten if you're trying to replicate the purpose of it in the sample algo. Fix that and see if you still have astronomical returns.

@Jason I don't know i am a completely newbie, I simply copied a sample algo which was a momentum follower on AAPL, and made some little mods to test the simple idea of "buying the dip" on AMD, a company I am currently LONG.

Jason is correct, the default benchmark is indeed SPY, an ETF that tracks the SP500.

You can use the set_benchmark function to set a custom benchmark to compare your algorithm's performance. I cloned your algo and ran it again AMD. It looks like the algorithm does better than a buy-and-hold strategy for the stock, but you still lose money in the end.

I slightly modified the trading logic to have an order target of 1000 shares when the price is down and close the position when the price is up. Also, I added a trading guard to only go long on the stock. If you're just getting started, take a look at the help documentation to get familiarized with the built-in tools and functions. And post back here to share your progress!

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.

Thanks a lot Alisa! Does this return include real-life transaction costs?

Yes, by default the commissions are $0.03 per share and you can modify this value using the set_commission function in initialize().

While you're in the help doc, take a look at the slippage function, which helps model the impact of your orders on market price. By default, you can transact up to 25% of the stock's trading volume per bar. This parameter is adjustable and if you want a different model, you can create a customized slippage function.

Thanks, trying to define more than one volume-weighted-average-price.

"go long or short [the] security"

added a trading guard to only go long on the stock

Long Only
In the initialize function, specify long_only to prevent the algorithm from taking short positions. It does not apply to existing open orders or positions in your portfolio.
def initialize(context):
# Algorithm will raise an exception if it attempts to place an
# order which would cause [] to hold negative shares of any sid.
set_long_only()

How long has set_long_only() been around? Anyone using it? Happy with it? Any drawbacks? Thx.

Also can someone please explain in simple terms what "go long" and 'go short' mean? I presume different from 'shorting a stock' (betting against, involving the future and a specific time period). And "short positions"? And "hold negative shares"? What are "negative shares"? Is the idea sort of in part to avoid the term 'borrowing' or 'debt' for example? Doesn't "go long" mean optimistic, so buy? Aren't these terms used loosely in many different and vague ways or is that just my lack of understanding? Much appreciated.

Trading guards were introduced in May to help set limits on your algorithm and prevent runaway positions.

The term "go long" means you are holding the stock in expectation that it's price is going to rise, thereby earning a profit.

"Go short" is the opposite, you believe the stock is over-valued and the price is going to fall. If you short a stock, you are borrowing it from your broker to sell - you don't actually have to own the stock. You're hoping to buy the stock back when the price falls, earning a profit. During this window that you're waiting for the stock price to drop, you're paying interest to your broker. When you short a stock you're holding negative shares. You don't own these shares; you borrowed them and need to return them once your position is covered. Hope this helps clarify the terminology!