Stop-Loss in our trading strategy - Python for Finance with Quantopian and Zipline 7



In this tutorial, we add a stop-loss to our trading strategy. The idea of a stop-loss is to exit a position that is turning out to go in a direction that is opposite to what is expected. When you enter a stop loss, you have purchased an instrument, and then you set a price where, if the market price falls to hit or go below it, you will sell that instrument off. This is a way to automatically get out of a losing strategy. sample code: http://pythonprogramming.net http://hkinsley.com https://twitter.com/sentdex http://sentdex.com http://seaofbtc.com

Comments

  1. It keeps giving me the error NameError: global name 'fundamentels' is not defined
  2. I admire you sooo much for the videos!!
    I have a question here: why will you use 'try' in this algorithm? what about the error?ignore them?
    I've also typed the code like you did. it can run but when i open the log output. it prints lots of error.I'm so confused about it!
  3. Great videos! 2 Questions:
    1. Is there a way to run the Quantopian-style environment (backtests, easy setup) in an offline IDE?
    2. Is there a good book that covers a lot of the built-in functionality and definitions? The quantopian and Zipline documentation seems somewhat sparse.
  4. I'm like 95% sure that the StopOrder in this video does NOT do what you think it does. What it will NOT do is sell any stock. That is to say, it is NOT a Stop Loss order. Rather what it will do, is BUY the stock when its price falls to your "stop_price". Am I wrong?

    I think what you wanted to do was to enter two orders... the first one to buy at market (so leave that line of code alone) and then immediately add a Stop Loss order for the negative amount of shares at your stop_price. But you also need to be careful, because your rebalance function could sell the stock before the Stop Loss gets triggered, leaving you in a situation where you'd be going short!
  5. Thank you for the metrics discussion.
  6. Hi, sentdex. I just found out about your channel and I'm so happy that I find it this early in my learning journey! 
    The thing is, you've got a looooooot of videos out there and I'm really confused. So I was wondering if you could make a map or something like a guide.
    You seem an amazing teacher can't wait to start learning from you!
  7. What better Python 3 or 2 and where to start


Additional Information:

Visibility: 10185

Duration: 12m 22s

Rating: 64