Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    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

    General Code/Help
    2
    3
    662
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Y
      Yi Fang last edited by Yi Fang

      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?

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        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

        1 Reply Last reply Reply Quote 0
        • Y
          Yi Fang last edited by

          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).

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors