For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Daily upper and lower bound of price



  • Hi:
    Is there a native way to incorporate daily upper and lower bound limit into order? What I mean is, for example, in Chinese stock market the price of any stock on any particular date may only go up by 10% or down by 10% based on previous date's close price. So if price go up by 10%, one can no longer buy it(as there will be many buy order but no sell order in the market, which is why the price go up by 10% in the first place).

    I try to take into account of such nature of stockmarket by:

    def next()
        ..... 
        ..... 
        if condition:
            self.order = self.buy(exectype = bt.Order.Limit, price = self.data.close[0] * 1.1)
    

    But what if the condition is examined once n bars and the order need to raise limit each bar until it is executed?


  • administrators

    It doesn't seem a fit for an Order, which is just an information carrier (you say what you want and the exchange/broker tells you what you got)

    You might try things like.

    • Having a custom Sizer (Docs - Sizers) which delivers a 0 size if your limits are met

    • Having a commission scheme (Docs - User Defined Commissions) which would need an infinite amount of cash for an operations, thus preventing that operation



  • Thank you for your reply! I will try both out! It might be a great idea to incorporate this in backtrader, as it is (to my knowledge) very common in some stock market, eg. 10% for Taiwan, 30% for Korea, 21.25% upper and 18.75% lower for France (weird isnt it).