Hi there,
Needs some help with this kind of cording.
This is what I want to do.
- Buy 1000 AAPL at market price.
- Sell 1000 AAPL at market price + .25
I should not buy another 1000 AAPL unless I sell the existing 1000.
Currently the software keeps buying 1000 APPL without checking if there is any sell order or not.
Thank you for your help
# Put any initialization logic here. The context object will be passed to
# the other methods in your algorithm.
def initialize(context):
pass
# Will be called on every trade event for the securities you specify.
def handle_data(context, data):
# Implement your algorithm logic here.
# data[sid(X)] holds the trade event data for that security.
# context.portfolio holds the current portfolio state.
# Place orders with the order(SID, amount) method.
# TODO: implement your own logic here.
order(sid(24), 1000)
filled_price = context.portfolio.positions[sid(24)].cost_basis
log.info(str(filled_price))
order(sid(24), -1000, style=LimitOrder(filled_price+ .25))