Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
All orders fail to fill

First off, great community. Love how helpful this forum is.

This is perhaps a dumb question but all of my orders fail to fill by the end of the day.

2016-02-04 WARN Your order for 100 shares of WMB failed to fill by the end of day and was canceled.
2016-02-11 WARN Your order for -251 shares of BETR failed to fill by the end of day and was canceled.
2016-02-16 WARN Your order for -4 shares of MTD failed to fill by the end of day and was canceled.
2016-02-24 WARN Your order for -62 shares of MRKT failed to fill by the end of day and was canceled.
2016-02-26 WARN Your order for -55 shares of XON failed to fill by the end of day and was canceled.
2016-03-01 WARN Your order for 17 shares of SFG failed to fill by the end of day and was canceled.

Below is my handle_data function which does all of my ordering.
I am really at a loss for why this is, I've set a filter for high volume stocks when setting up my pipe so I don't think it has to do with lack of volume (4 shares...).

Is there some check that I am missing before placing an order?

Grateful for any and all help as well as criticism.

def handle_data(context,data):  
    leverage = context.account.leverage

    for stock in context.security_set:  
        if data.can_trade(stock) & not get_open_orders(stock) & (context.portfolio.positions[stock].amount == 0):  
            closes = data.history(stock, 'close', 10, '1d')  
            lows = data.history(stock, 'low', 10, '1d')  
            highs = data.history(stock, 'high', 10, '1d')  
            volumes = data.history(stock, 'volume', 10, '1d')  
            if leverage >= context.leverage_buffer:  
                return  
            elif stock in context.long_set:  
                if talib.ADOSC(highs, lows, closes, volumes, fastperiod=3, slowperiod=10)[-1] > 0:  
                    order_target_percent(stock, 1. / context.num_securities)  
            elif stock in context.short_set:  
                if talib.ADOSC(highs, lows, closes, volumes, fastperiod=3, slowperiod=10)[-1] < 0:  
                    order_target_percent(stock, -1. / context.num_securities)  
    for stock in context.portfolio.positions:  
        closes = data.history(stock, 'close', 10, '1d')  
        lows = data.history(stock, 'low', 10, '1d')  
        highs = data.history(stock, 'high', 10, '1d')  
        volumes = data.history(stock, 'volume', 10, '1d')  
        if leverage >= context.leverage_buffer:  
                order_target_percent(stock, 0)  
        elif context.portfolio.positions[stock].amount < 0 & data.can_trade(stock) & not get_open_orders(stock):  
            if talib.ADOSC(highs, lows, closes, volumes, fastperiod=3, slowperiod=10)[-1] > 0:  
                order_target_percent(stock, 0)  
        elif context.portfolio.positions[stock].amount > 0 & data.can_trade(stock) & not get_open_orders(stock):  
            if talib.ADOSC(highs, lows, closes, volumes, fastperiod=3, slowperiod=10)[-1] < 0:  
                order_target_percent(stock, 0)  
3 responses

Same problem, any answers?

Hi Christopher, sorry to be slow on this. Is it all orders failing to fill, or are some orders going through? And do you know what time of day these orders are being placed? If they're placed at the very end of the day there's a high chance they won't be filled. You can log the time of day when you place each order by doing something like log.info(get_datetime(), stock) before every order.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

I figured it out, silly mistake. I wasn't using my high volume pipeline as a mask for custom factor! Thanks for the reply.