Navigation

    Backtrader Community

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

    adrianyuen

    @adrianyuen

    1
    Reputation
    5
    Profile views
    8
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    adrianyuen Unfollow Follow

    Best posts made by adrianyuen

    • RE: Does BackTrader support the "Adaptive" order of IB?

      @vladisld Thanks a lot!

      posted in General Code/Help
      A
      adrianyuen

    Latest posts made by adrianyuen

    • RE: Does BackTrader support the "Adaptive" order of IB?

      @vladisld Thanks a lot!

      posted in General Code/Help
      A
      adrianyuen
    • Does BackTrader support the "Adaptive" order of IB?

      Placing an order at market price sometimes get a very poor price. However, limited price order may not be executed. The IB "Adaptive" order at market price maybe a good balance between market and limited price order. However, I can't find any information from online document nor forum. Does BackTrader support such order type? Thank you.

      posted in General Code/Help
      A
      adrianyuen
    • Can get live data from IB but can't trade or get position

      By referencing the sample code ibtest.py, I can get live data from IB. However, I try to place a buy order throught the paper account, but can't make the trade successfully. I also can't get the position.

      I got the following order information. It's ordered with market price. However, I tried other limited price order but failed as well. Could anyone give me some hints/suggestions? Thank you.


      -------------------------------------------------- ORDER BEGIN 2021-02-10 23:15:15.729882
      Ref: 28
      OrdType: 0
      OrdType: Buy
      Status: 1
      Status: Submitted
      Size: 1
      Price: None
      Price Limit: None
      TrailAmount: None
      TrailPercent: None
      ExecType: 0
      ExecType: Market
      CommInfo: None
      End of Session: 737831.6666666665
      Info: AutoOrderedDict()
      Broker: None
      Alive: True
      -------------------------------------------------- ORDER END
      -------------------------------------------------- ORDER BEGIN 2021-02-10 23:15:15.732300
      Ref: 28
      OrdType: 0
      OrdType: Buy
      Status: 7
      Status: Margin
      Size: 1
      Price: None
      Price Limit: None
      TrailAmount: None
      TrailPercent: None
      ExecType: 0
      ExecType: Market
      CommInfo: None
      End of Session: 737831.6666666665
      Info: AutoOrderedDict()
      Broker: None
      Alive: False
      -------------------------------------------------- ORDER END

      posted in General Code/Help
      A
      adrianyuen
    • RE: Question on live data update

      @rajanprabu Can I understand the mechanism as: the SMA indicator can be put in init section of the ibtest.py example because the build-in SMA indicator implemented the "next" method. When live data fits in, Cerebro calls the next() method of the SMA indicator to update the indicator value. Is it correct?

      posted in General Code/Help
      A
      adrianyuen
    • RE: Question on live data update

      Thanks rajanprabu and vladisld. That means, if live data is involved, and I want my backtesting strategy to be reusable in live data environment, I can't put my indicator calculations (usually in the form of array operations) in init. I must rewrite those indicators as methods, which accepts data feeds in each iteration of "next"

      posted in General Code/Help
      A
      adrianyuen
    • Question on live data update

      I'm going to add live data fetching to my code. I read the example "sample\ibtest\ibtest.py" and have a question:

      In the class: TestStrategy of the sample code, it contain a SMA calculation in the init of the TestStrategy class:

      self.sma = bt.indicators.MovAv.SMA(self.data, period=self.p.smaperiod)

      Because the init run once only (during the TestStrategy class instance creation). However, the real time data (i.e. self.data) updates continuously, how can the "self.sma" be reflected, as init run once only?

      posted in General Code/Help
      A
      adrianyuen
    • RE: Read the customer indicator value

      Thank you, rajanprabu. You're right, I'm using a wrong bracket...

      posted in General Code/Help
      A
      adrianyuen
    • Read the customer indicator value

      I'm a newbie to Backtrader and just developed my first custom indicator (I mainly follow the samples at https://community.backtrader.com/topic/2145/full-example-of-custom-indicator/5)

      However, when I try to compare indicator values, e.g. lazy is my custom indicator, and I try to compare the values of itself one units ago, i.e.

          self.lazy(-1)>self.lazy(0)
      

      I got the following error message:

      bool should return bool, returned LineOwnOperation

      I know the custom indicator is actually a line object. How can I get the value of it?

      posted in General Code/Help
      A
      adrianyuen