Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
IB relative order not triggered

I have been live trading an algo for a few weeks now. I changed the order style to relative, aka:

order_target_percent(sid, 0.0, style=RelativeOrder(offset=.01))

but during live trade no orders were sent to the broker (IB) while the regular market orders worked. Can someone tell me why?

Thanks

5 responses

Actually just changed to market order and non of the orders were sent in either ! looks like I just have a live trading issue? any ideas? code has wrked in the past week !!!

schedule_function(exit_positions,
date_rule=date_rules.week_start(days_offset = context.days_offset),
time_rule=time_rules.market_close(minutes=12),
half_days=True
)

could someone at Q help!

Hi Kamran,

I'd be happy to look into this. Would you be willing to share your context.days_offset value? Since Monday this week was a market holiday, I'm wondering if the issue might be that the relative offset is scheduling the exit_positions function to run tomorrow.

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.

oh sorry here it is.

context.days_offset = 2 # (0, Monday), (1, Tuesday), etc.

The code was suppose to trigger trades today. The only change I had made was to add the relative style. When it did not fire I thought that was the reason. I stopped the algo and relaunched with market orders at later time. non of my live trades were executed. So I am wondering if these is a relative offset issue as well now. I thought the the offset was day of the week not if we had a holiday etc. I want the algo to re-balance every Wednesday .

Thanks Jamie.

Hi Kamran,

date_rules.week_start offsets from the first trading day of the week. So when the week starts with a holiday like it did this week, your scheduled function will occur on Thursday instead of Wednesday.

If you want to schedule something strictly based on day of the week, it's best to schedule the function for every day and include a check for the day of the week. Here's an example:

def initialize(context):  
    schedule_function(my_function, date_rule=date_rules.every_day(),  
                      time_rule=time_rules.market_open())  
def my_function(context, data):  
    if(get_datetime().weekday() == 2):  
        print('Wednesday')  

.weekday() returns 0 for Monday through 6 for Sunday. Hope this helps.

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.

Thanks Nathan, That clarifies it for me although that is not obvious from the API documentation.

I would like to add that in case at Q you guys are going to launch Futures or FX in later releases, the concept of market holiday becomes confusing as those markets are often open during the US stock market shutdown days. So the .week_start semantics would definitely get confusing.

Thanks again