Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
questions re: VWAPBestEffort

Some questions regarding VWAPBestEffort ( https://www.quantopian.com/help#api-VWAPBestEffort ):

  • Do VWAPBestEffort orders get cancelled at the close of the market?
  • If not, then how is the order executed when the market opens again? The VWAP calculation just starts over when the market opens?
  • On the Quantopian help page, it says "The BestEffort order will be submitted to IB in the next minute bar." But I thought orders are sent to IB asysynchronously/immediately as they are encountered in the code. Is VWAPBestEffort different?
  • Has IB published the details of their execution algorithm?
  • Does IB support VWAPBestEffort for their paper trading?
  • Any plans to emulate IB VWAPBestEffort for backtesting and paper trading?
1 response

We explicitly set the end_date of VWAPBestEffort orders to the close.

The internal code that handles the start/end dates is roughly as follows:

    def _adjust_date_bounds(start_date, end_date):  
        """  
        Helper method for adjusting start and end time bounds.  
        """  
        current_time = get_datetime()  
        _, todays_close = (  
            trading_environment.get_open_and_close(current_time)  
        )

        if current_time >= todays_close - timedelta(minutes=1):  
            raise UnsupportedOrderParameters(  
                msg="Can't place a VWAP order in the last minute of the day."  
            )

        # Validate start date  
        if start_date and start_date < current_time + timedelta(minutes=1):  
            raise UnsupportedOrderParameters(  
                msg="start_date must be at least one minute "  
                "later than the current algo time."  
            )  
        start_date = start_date or (current_time + timedelta(minutes=1))

        # Validate end date  
        if end_date and end_date > todays_close:  
            raise UnsupportedOrderParameters(  
                msg="end_date must be <= market close for current day"  
            )  
        end_date = end_date or todays_close

        if start_date >= end_date:  
            raise UnsupportedOrderParameters(  
                msg="start_date must be before end_date"  
            )

        return start_date, end_date  

But I thought orders are sent to IB asysynchronously/immediately as they are encountered in the code. Is VWAPBestEffort different?

Orders are sent asynchronously, but as you can see in the above, we shift the start_date of the order forward to the next minute. I think this is because IB will reject the VWAP order if the start date is before the current real time, but I'm not 100% sure.

Does IB support VWAPBestEffort for their paper trading?

VWAP orders won't be rejected by IB, but I don't know how well they're able to simulate actual behavior or how hard they try to do so.

Has IB published the details of their execution algorithm?

The general gist seems to be to buy a percentage of the full order on each bar between the start and end dates of the order, but I don't believe the're a formal publication of the details anywhere.

Any plans to emulate IB VWAPBestEffort for backtesting and paper trading?

Probably someday, but also probably not soon. The machinery to make this work lives in Zipline though, so contributions welcome!

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.