Navigation

    Backtrader Community

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

    NewestTrader

    @NewestTrader

    6
    Reputation
    864
    Profile views
    48
    Posts
    0
    Followers
    1
    Following
    Joined Last Online

    NewestTrader Unfollow Follow

    Best posts made by NewestTrader

    • RE: Is it possible to get the realized PnL from Backtrader?

      Thanks.

      So in the end I was able to get the realized PnL from the analyzer described here: analyzer to calculate and save realized pnl and opened positions for each strategy date to date.

      But your posts were very helpful to direct me in the direction to look more at analyzers in general!

      Thanks again.

      posted in General Code/Help
      NewestTrader
      NewestTrader
    • RE: Trail Orders don't use high and low, is that on purpose?

      Thanks @run-out for your comment.

      As far as I understand the code example given in Below is full code for sample trading system, implementing fixed stop loss and take profit orders., this takes care for adjusting the trailing stop from one next() to another.

      This might be too late, if during one day I have a very big high, as any closing of the trade will come only at the following day, isn't it?

      posted in General Code/Help
      NewestTrader
      NewestTrader
    • RE: Quantopian drops live Brokerage support

      And now they are closing completely:

      https://www.quantopian.com/posts/quantopians-community-services-are-closing

      Hello everyone,

      Since 2012, Quantopian has been a place for people all over the world to learn quantitative finance. Today, I’m sad to say that we will be winding down Quantopian’s free community offering over the next couple of weeks and on November 14th, the community platform will be taken down.

      I love the Quantopian community and I am so grateful that you believed in us and supported us over this long journey. Crowd-sourcing alpha was a moonshot and I’m deeply thankful that we had the opportunity to pursue the dream together for 9 years.

      Our mission was to break open quant finance and make it accessible to everyone. You helped realize this mission and came together to form the biggest community of quants the world has ever seen. For that, I am extremely proud and grateful. I sincerely hope that Quantopian is just one milestone in your journey through quantitative finance. Knowing so many of you and your creative energy, I expect you will use your Quantopian experience to learn and grow, and look for new ways to disrupt the industry.

      In terms of logistics, Research and Backtesting are no longer available. However, you can download your code (algorithms and notebooks) until November 14th, at which point the Quantopian community website will be taken down. There is a “Download Code” button in your account settings that allows you to download all of your code in a zip file. We know this is short notice, so we’re hoping that this helps you get your IP on to your local machine more easily.

      While the Quantopian community platform will no longer be available, Zipline, Alphalens, Pyfolio, Empyrical, Trading Calendars, and our other open source projects will all live on in GitHub. For those of you who used our tools on Quantopian, we hope that you can turn to the code on GitHub to get setup locally. We are also looking to find a home for the YouTube channel so that the lectures and other educational content can continue to exist online.

      We launched the Quantopian community in 2012 with just a simple backtester. You pushed us to keep building and improving, leading us to the high-quality platform that is Quantopian today. Thank you to everyone for making Quantopian so special.

      thanks,
      fawce

      posted in General Discussion
      NewestTrader
      NewestTrader
    • RE: Trail Orders don't use high and low, is that on purpose?

      Hi,

      I find it inconvenient when using daily bars to get the trailing stop calculated by backtrader on the close value of my daily candle, but not on the high value of it (in case of going long).

      I am not yet trading live but I would assume that a broker like Interactive Brokers will adjust the trailing stop on a finer timescale than daily, even if I requested to get daily data from it via backtrader, wouldn`t it? Correct me if I am wrong.

      Is there any workaround during pure backtesting, so that the high value of a daily candle is used for calculation instead of the close?

      If there is a workaround, code examples are welcome. :-)

      Thanks in advance!

      posted in General Code/Help
      NewestTrader
      NewestTrader

    Latest posts made by NewestTrader

    • RE: cerebro.py line 1557 defect has been fixed:ValueError: min() arg is an empty sequence

      Hi @jeff-lee

      I had the issue

      min() arg is an empty sequence

      when I forgot during resampling to specify the format of the original (not resampled) data.

      So I did not write:

      originalData = bt.feeds.PandasData(dataname=df,
       timeframe=bt.TimeFrame.Minutes,
       compression=1,
       datetime='Date',
       fromdate=startDate,
       todate=endDate,
       )
      

      but:

      originalData = bt.feeds.PandasData(dataname=df,
       # timeframe=bt.TimeFrame.Minutes,
       # compression=1,
       datetime='Date',
       fromdate=startDate,
       todate=endDate,
       )
      

      Under which conditions did you get the error that motivated you to do your bug fix?

      posted in General Code/Help
      NewestTrader
      NewestTrader
    • RE: Quantopian drops live Brokerage support

      And now they are closing completely:

      https://www.quantopian.com/posts/quantopians-community-services-are-closing

      Hello everyone,

      Since 2012, Quantopian has been a place for people all over the world to learn quantitative finance. Today, I’m sad to say that we will be winding down Quantopian’s free community offering over the next couple of weeks and on November 14th, the community platform will be taken down.

      I love the Quantopian community and I am so grateful that you believed in us and supported us over this long journey. Crowd-sourcing alpha was a moonshot and I’m deeply thankful that we had the opportunity to pursue the dream together for 9 years.

      Our mission was to break open quant finance and make it accessible to everyone. You helped realize this mission and came together to form the biggest community of quants the world has ever seen. For that, I am extremely proud and grateful. I sincerely hope that Quantopian is just one milestone in your journey through quantitative finance. Knowing so many of you and your creative energy, I expect you will use your Quantopian experience to learn and grow, and look for new ways to disrupt the industry.

      In terms of logistics, Research and Backtesting are no longer available. However, you can download your code (algorithms and notebooks) until November 14th, at which point the Quantopian community website will be taken down. There is a “Download Code” button in your account settings that allows you to download all of your code in a zip file. We know this is short notice, so we’re hoping that this helps you get your IP on to your local machine more easily.

      While the Quantopian community platform will no longer be available, Zipline, Alphalens, Pyfolio, Empyrical, Trading Calendars, and our other open source projects will all live on in GitHub. For those of you who used our tools on Quantopian, we hope that you can turn to the code on GitHub to get setup locally. We are also looking to find a home for the YouTube channel so that the lectures and other educational content can continue to exist online.

      We launched the Quantopian community in 2012 with just a simple backtester. You pushed us to keep building and improving, leading us to the high-quality platform that is Quantopian today. Thank you to everyone for making Quantopian so special.

      thanks,
      fawce

      posted in General Discussion
      NewestTrader
      NewestTrader
    • RE: Trail Orders don't use high and low, is that on purpose?

      Thanks @run-out for your comment.

      As far as I understand the code example given in Below is full code for sample trading system, implementing fixed stop loss and take profit orders., this takes care for adjusting the trailing stop from one next() to another.

      This might be too late, if during one day I have a very big high, as any closing of the trade will come only at the following day, isn't it?

      posted in General Code/Help
      NewestTrader
      NewestTrader
    • RE: Trail Orders don't use high and low, is that on purpose?

      Hi,

      I find it inconvenient when using daily bars to get the trailing stop calculated by backtrader on the close value of my daily candle, but not on the high value of it (in case of going long).

      I am not yet trading live but I would assume that a broker like Interactive Brokers will adjust the trailing stop on a finer timescale than daily, even if I requested to get daily data from it via backtrader, wouldn`t it? Correct me if I am wrong.

      Is there any workaround during pure backtesting, so that the high value of a daily candle is used for calculation instead of the close?

      If there is a workaround, code examples are welcome. :-)

      Thanks in advance!

      posted in General Code/Help
      NewestTrader
      NewestTrader
    • Does new stoptrail order in notify_order() refer to the previous or the coming candle?

      Hi,

      I am presently looking at the stoptrail functionality.

      In my next() method, at time A I generate a buy().
      Afterwards I wait in notifyorder() until this buy was 'Completed'.

      After it got 'Completed', being still in notifyorder(), I generate a subsequent stoptrail sell order:
      self.sell( exectype=bt.Order.StopTrail,trailamount=X)

      My question is:
      does this sell order initially take the close value of the candle A into account or the close value of the coming candle A+1?

      Thanks in advance!

      posted in General Code/Help
      NewestTrader
      NewestTrader
    • Which datetime to take in notify_order()?

      Hi,

      I am building an environment where I do live trading and backtesting within the same python module. I want to store the values that I get from backtrader in my SQL database for both kinds of trading.

      I am presently thinking how I can store the positions that are created / deleted during trading and that I get informed about in the method self.notify_order(self, order) .

      I would like to take the datetime that I possibly could get from backtrader for an order that is in state order.getstatusname() = 'Completed' and use this as part of a compound key that I will store in my database.

      I presently see the following candidates for this, but I am unsure which one to take.

      These are my possible candidates:

      1. self.data.num2date(order.p.data.l.datetime[0])
      2. order.p.owner.datas[0].datetime.datetime(0)
      3. order.params.data.datetime.datetime(0)
      4. datetime.datetime.utcnow() (at least during livetrading), as maybe the moment when notify_order() gets triggered is independant from any candles I get).

      At least during backtesting, 1.-3. contain the datetime that I will receive with the upcoming next(), but I am not sure whether to take 1.-3. is valid anyhow.

      What would you take in my situation / what makes sense from the internal logics point of view of backtrader?

      Thanks in advance!

      posted in General Code/Help
      NewestTrader
      NewestTrader
    • RE: Is it possible to get the realized PnL from Backtrader?

      Thanks.

      So in the end I was able to get the realized PnL from the analyzer described here: analyzer to calculate and save realized pnl and opened positions for each strategy date to date.

      But your posts were very helpful to direct me in the direction to look more at analyzers in general!

      Thanks again.

      posted in General Code/Help
      NewestTrader
      NewestTrader
    • RE: Is it possible to get the realized PnL from Backtrader?

      Hi @run-out ,

      thanks for your very good and concise answer.

      I made a mistake in my question.

      I forgot to mention that I would like to get the realized Profit and Loss at any moment in time and specially also for the case that I have staggered buys and sells.

      E. g.:

      I buy one stock at (1) and another one at (2) for 50 each.
      At (3) the stock price rises from 50 to 75.
      At (4) I sell one stock. The realized PnL should rise accordingly from 0 to 25.
      At (5) I sell the other stock. The realized PnL should rise from 25 to 50.

      My intention is how I could get the realized PnL (in red in the picture) at any point in time directly from Backtrader.

      realizedPnL5.jpg

      posted in General Code/Help
      NewestTrader
      NewestTrader
    • Is it possible to get the realized PnL from Backtrader?

      Hi,

      I would like to ask, whether and how I could retrieve the realized Profit and Loss from Backtrader?

      Thanks in advance!

      posted in General Code/Help
      NewestTrader
      NewestTrader
    • Workaround / Handling for 'Final Delayed Bar'?

      Hi,

      I am totally satisfied with all the functionality that the backtrader framework offers to me but I am just worried about one topic:

      And this is regarding the 'final delayed bar' during live trading (see:

      https://community.backtrader.com/topic/110/anyone-using-backtrader-for-live-trading/37#
      https://community.backtrader.com/topic/970/backtest-vs-live-bars-off-by-1-discrepancy/26# )

      I just wanted to know whether somebody might have found a workaround or handling for this?

      Perhaps @backtrader , @Squirrel-Singing , @dasch :-) ?

      Thanks in advance!

      posted in General Code/Help
      NewestTrader
      NewestTrader