Orders and Leverage - Algorithmic Trading with Python and Quantopian p. 2



In this tutorial, we're going to be covering how to actually place an order for stock (buy/sell/short) on Quantopian. https://pythonprogramming.net https://twitter.com/sentdex https://www.facebook.com/pythonprogramming.net/ https://plus.google.com/+sentdex

Comments

  1. great video. thank you. As I'm watching I'm thinking 1 minute updating is way overkill for things I'm thinking about (I'm actually wanting to mix in fundamentals). I'm wondering if there's a way for simulation to simply trade at end of day or open prices, or make order for next day.

    I've worked with end of day data with amibroker and place order the next day, so it'd be nice to understand how to simplify process in quantopian similarly as I have no interest in 1 minute bars at this point, but it sounds like it's inherent in the handle_data method. I'm just learning, so I'll have to read, but the 1m bar seems a bit much for any imaginable trades I'm considering.
  2. You can just delete the date and type in your desired date, no need for that l33t clicking
  3. Hello,
    my code is not running and this is what i'm getting: "SyntaxError: unindent does not match any outer indentation level
    "
    def initialize(context):
    context.aapl = sid(24)

    def handle_data(context, data):
    hist = data.history(context.aapl, 'price', '50', '1d')
    log.info(hist.head())
    sma_50 = hist.mean()
    sma_20 = hist[-20:].mean()

    if sma_20 > sma_50:
    order_target_percent(context.appl, '1.0')
    elif sma_50 > sma_20:
    order_target_percent(context.aapl, '-1.0')
  4. you are a genius! thanks for all your great work!
  5. So handle_data() is just every minute eh?
  6. Love what you are doing keep up the great work!
  7. Hi,

    I am receiving the following error 'Local variable 'sma_20' is assigned to but never used' any suggestions?


Additional Information:

Visibility: 5080

Duration: 16m 12s

Rating: 65