I'm trying to limit a trade to only once a day but I'm having trouble using datetime to do it. Would anyone mind giving me a hand?
# Put any initialization logic here. The context object will be passed to
# the other methods in your algorithm.
def initialize(context):
context.nvda = sid(24)
context.max_notional = 1000000.1
context.min_notional = -1000000.0
# Will be called on every trade event for the securities you specify.
def handle_data(context, data):
# Implement your algorithm logic here.
theOpen = data[context.nvda].open_price
curPrice = data[context.nvda].price
#amount = 2000/curPrice
if curPrice > (theOpen + .08) and curPrice < (theOpen + 1.2):
#order(sid(19725),amount, theOpen * 1.02, (theOpen*.98))
order(context.nvda, 100, data[context.nvda].close_price)
# data[sid(X)] holds the trade event data for that security.
# data.portfolio holds the current portfolio state.
# Place orders with the order(SID, amount) method.
# TODO: implement your own logic here.
#order(sid(24), 50)
I'm getting a ridiculous return (22,000%) but it's way too volatile for my liking at the moment.