Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. skytrading54
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    S
    • Profile
    • Following 0
    • Followers 0
    • Topics 7
    • Posts 30
    • Best 1
    • Groups 0

    skytrading54

    @skytrading54

    1
    Reputation
    968
    Profile views
    30
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    skytrading54 Unfollow Follow

    Best posts made by skytrading54

    • order price modification support ?

      Looking for a use case to be able to modify low / high side of a bracket order once the main order is filled, brokers like IB support modification of existing order price etc.

      Any plans to support order modification on backtrader - ideally price modification on unfilled limit/stop-limit orders.

      While for a single order it would be easier to cancel and replace it with new one, how do we achieve it for bracket orders low and high side once main order is filled, ability to modify the original order seems to be the solution, any thoughts in current backtrader framework.

      posted in General Discussion
      S
      skytrading54

    Latest posts made by skytrading54

    • RE: Update / Amend Existing Orders

      any update on when amend would be available in backtrader.

      posted in General Code/Help
      S
      skytrading54
    • order price modification support ?

      Looking for a use case to be able to modify low / high side of a bracket order once the main order is filled, brokers like IB support modification of existing order price etc.

      Any plans to support order modification on backtrader - ideally price modification on unfilled limit/stop-limit orders.

      While for a single order it would be easier to cancel and replace it with new one, how do we achieve it for bracket orders low and high side once main order is filled, ability to modify the original order seems to be the solution, any thoughts in current backtrader framework.

      posted in General Discussion
      S
      skytrading54
    • RE: Issue with Stop-Loss on Multiple Stock Datas

      @cwse to answer your question -- Will OCO be supported by interactive brokers in the near future if i go down this avenue?

      There is something better available in IB called bracket order which combines OCO , Stop Loss Order and Take Profit Order together with main order.

      It works like this.
      Issue 3 orders in one go,

      1. The main order (Limit)
      2. Take Profit (Limit)
      3. Stop Loss (this could be actual stop loss or trail or trail limit order)

      All of these are in one group (grouped by parent orders id) and when we create the orders one by one; the transmit flag (of IBOrder) is false for first 2 and should be true on last one. So all of them gets into IB system at once based on last orders transmit=true when you submit them one by one.

      From IB side, Only first main order is sent/live at the exchange (rest 2 are not active), Only when first one is filled next 2 are propagated to exchange. Since these 2 (take profit & stop loss) are OCO; whichever gets filled at exchange first, IB cancels the other one.

      Example:

      1. Main Order - Buy @ Limit price 100 - transmit=false
      2. Take Profit - Sell @ Limit price 110 - transmit=false, m_parentId= main order id.
      3. Stop Loss - Sell @ Stop Loss price 98 - transmit=true, m_parentId= main order id.

      submit all 3, they are entered in IB system, however IB will send only parent order to exchange first. Only when that is executed it will send next 2 as OCO. When one of this is filled (resulting in profit or loss) other is cancelled automatically.

      posted in General Code/Help
      S
      skytrading54
    • RE: exception in ibbroker.py

      I tried that (not setting any commission info at all), still the same issue.

      posted in General Code/Help
      S
      skytrading54
    • exception in ibbroker.py

      I am using following methods to set commission in both cases getting following exception, any pointers what's going wrong...
      Product is emini future.

      1. cerebro.broker.setcommission(commission=1.25, margin=2000.0, mult=50.0)

      2. comminfo = CommInfo_FIXED(commission=1.25,stocklike=False) # 1$
        cerebro.broker.addcommissioninfo(comminfo)
        where CommInfo_FIXED is following class.

      class CommInfo_FIXED(bt.CommInfoBase):
      params = (('stocklike', False), ('commtype', bt.CommInfoBase.COMM_FIXED),)
      def _getcommission(self, size, price, pseudoexec):
      return self.p.commission

      both varieties gives following error when trade is executed.

      ERROR Exception in message dispatch. Handler 'commissionReport' for 'commissionReport'
      Traceback (most recent call last):
      File "C:\Python27\lib\site-packages\ib\opt\dispatcher.py", line 44, in call
      results.append(listener(message))
      File "build\bdist.win32\egg\backtrader\stores\ibstore.py", line 1377, in commissionReport
      self.broker.push_commissionreport(msg.commissionReport)
      File "build\bdist.win32\egg\backtrader\brokers\ibbroker.py", line 525, in push_commissionreport
      closedvalue = comminfo.getoperationcost(closed, pprice_orig)
      AttributeError: 'NoneType' object has no attribute 'getoperationcost'

      posted in General Code/Help
      S
      skytrading54
    • indicator using a value from the data other than close

      I believe most of the built in indicators are using close value from the data for computation, for example SMA indicator is using close values of all the bars to derive sma... (is this correct)
      I have following 2 scenarios to build indicators

      1. if I would like to force this to use say high values of the bar to compute the average, what would be the change.
      2. if I would like to use volume from the bar to compute volume average over a period, what would be the change.
        appreciate any example if available.
      posted in Indicators/Strategies/Analyzers
      S
      skytrading54
    • RE: Suggestion: caching

      my 2 cents..
      following approach might work using existing multiprocessing architecture.

      1. since optimization iterations are mainly based on parameters which are passed on as ranges... we might simply consider to compute first, all the indicators which make use of those range based parameters and save all of those to the file, even this could be done by having multiple processes each dedicated to that specific indicator.
      2. Once this computation is done, then actual strategy processing should begin using various combinations of those indicators as applicable. It would only need to read the cached data from file in read only mode for that specific indicator, so no worry about locking, this would as well be multiprocessing as is used today, just that indicators have been computed earlier separately.
      posted in General Discussion
      S
      skytrading54
    • RE: Trailing stop loss

      knowing that IB directly supports trailing order I am also interested in this.

      posted in General Code/Help
      S
      skytrading54
    • RE: Memory error in optimization run.

      well, my data size is not big... its 1 min ohlc bar for 1 year and resampled to 5 mins compression.

      When I ran it with about 50 iteration it works fine. A higher number of iterations (150++) gives this error, which means memory is increasing per iteration.

      I see any point of time 10 process spawned by backtrader for this optimization run, is there a way it can release the memory from some of the previous runs as it progresses into next iterations....

      posted in General Code/Help
      S
      skytrading54
    • Memory error in optimization run.

      Hi, I am getting memory error while running optimization and the run does not continue after that.

      -E--Strategy::init--loop params-- xception in thread Thread-3:
      Traceback (most recent call last):
        File "C:\Python27\lib\threading.py", line 810, in __bootstrap_inner
          self.run()
        File "C:\Python27\lib\threading.py", line 763, in run
          self.__target(*self.__args, **self.__kwargs)
        File "C:\Python27\lib\multiprocessing\pool.py", line 389, in _handle_results
          task = get()
      MemoryError
      

      I am using 4 parameters variations..

      cerebro.optstrategy(TestStrategy,smaperiod_fast=xrange(40,150,15), smaperiod_slow=range(150,300,15), p1=range(25,45,8), p2=range(50,300,15))
      

      However the max memory consumed is 1.7 GB, with 32 bit it should go upto 4GB without any issue. Attached is snapshot of the all the processes spawned for optimization run.

      0_1485307951406_upload-62c09779-24d2-4e82-a67b-c7f1e8e61140

      Any idea what could be wrong here... I am using backtrader Release 1.9.24.105

      posted in General Code/Help
      S
      skytrading54