Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Hey im new to this

uhhh so, I'm new here and i tried to write my first code lol. I wrote something, can you tell me why it is wrong? I am trying to put a trailing stop loss .10 points behind the day open, and then put a limit order back at the stop loss.

Here is the code:
def initialize(context):
context.stocks = symbols('AMZN')
context.bet_amount = 100000
open_price= "n"
def handle_data(context, data):
order('AMZN',50,style=StopLimitOrder("n", "n"))

2 responses

Seems u have problem with >> open_price="n" it should be context.open_price="n"

open_price isn't passed to handle_data, by making it an attribute to the context object, handle_data can now 'see' it.