Backtrader Community

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Richard O'Regan
    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 2
    • Followers 7
    • Topics 11
    • Posts 62
    • Best 11
    • Controversial 0
    • Groups 0

    Richard O'Regan

    @Richard O'Regan

    English, background in trading (Futures, spreads..).
    Studied Computer Science at Manchester University.
    Coded in many languages, currently focusing on Python.

    Interesting fact: First experience in coding was as a ten year old, learning basic for BBC Microcomputer. I wanted to write computer games for a living, later as a teenager I was writing graphics 'demos' for Commodore 64 using 100% assembly language as part of international Public Domain cracking group. It was before days of the internet, we used to post floppy disks to each other and paint stamps with rubber transparent glue so the postage marks would rub off and stamps could be recycled!

    25
    Reputation
    1891
    Profile views
    62
    Posts
    7
    Followers
    2
    Following
    Joined Last Online
    Location London

    Richard O'Regan Unfollow Follow

    Best posts made by Richard O'Regan

    • What is the direction of Backtrader

      Hi (or other BT guys)

      I am a trader looking to code some ideas of mine with a view to running automatically. I'm tired of retail backtesting software (eg Ninja, Tradestation etc) and am experimenting with Python platforms.

      I've tried Quantopean and now trying out QuantConnect (C# & Python).
      Although the documentation is poor currently, they say they are now focusing on it.. apart from documentation their community and and their speedy replies to forum messages is exceptional. They have several people working on code and I feel comfortable QC is likely to stay around for some time.

      I really like what I've seen with Backtrader, the build in graphics is helpful (eg can see trades made on chart), and bonus is doesn't need .NET framework. Though my concerns are that community doesn't yet seem as strong (as say Quantopean or QuantConnect) and looking at Github there is only one main developer, Mementum. If I invest my time and effort learning BT, what if Mementum moves on to another project.. or gets married and change career.. etc. Are there other developers who can step in and maintain code? Fear is platform would fade out and I'd need to start from scratch. Also how are you guys able to make money to support the hard work you do? Just wondering where you see Backtrader in the next 2-3 years and what plans are (e.g. you mention BT in 6 quant firms already, great start). Thank-you very much

      Kind Regards
      Rich

      posted in General Discussion
      Richard O'Regan
      Richard O'Regan
    • RE: I added Kelly Percent to analyzers

      Hi guys, if anyone wants to use this Kelly performance measure, you can get it here;
      https://github.com/rich-oregan/backtrader

      Don't mean to teach you to suck eggs but some newbies here and want to make easy for everyone :)

      There are two files.

      "kelly. py" [main file]

      "init.py" [contains just one small bit of code at the bottom;]

      from .kelly import *

      0_1508369029498_Untitled.png

      I've got a much better set of performance measures I've created. I just need to write some notes/comments for.. stay tuned.

      posted in Indicators/Strategies/Analyzers
      Richard O'Regan
      Richard O'Regan
    • RE: Copyright Abuse?

      @CptanPanic I'm happy to temporarily do this until Daniel is comfortable with his version 2.0 /copyright issues and accepting pull requests.

      My knowledge on BT is not a patch on Daniel's, but we can try stuff out and probably brake stuff, and the best features we can later submit to Daniel for his version 2.0, at least in the meantime the ball is rolling.

      I also had the suggestion from another member for the same idea he wrote 'It might fragment the code base but what alternative do we have?'

      Ok Guys, if anyone wants to submit pull-requests to my fork, then I'll aim to check through and give feedback within 72 hours.

      posted in General Discussion
      Richard O'Regan
      Richard O'Regan
    • I added Kelly Percent to analyzers

      Hi guys,

      As title states, I've created a pull request for the Kelly formula.
      This will let us know the optimal percentage of account to bet for a strategy.

      Although I've been coding for 20 years, I'm relatively new to Python and never used GitHub before, so any suggestions for improvements are gratefully received.

      Cheers guys
      Rich

      The formula:

          K = W - [(1 - W) / R]
      
      K = Kelly optimal percent
      e.g. 0.156 = 15.6 percent of account was optimal bet size
      (based on the historical trades your system generated).
      
      W = Win rate. e.g. 0.6 (= 60%)
      Determined by counting profitable trades made.
      
      R = Win/Loss ratio. e.g. 1.5 = Winners were on average 1.5 x losers
      Determined by taking average of all winners & average of all losers.
      
      Because R and W are determined from trades the strategy generates when
      run, there needs to be at least 1 winner and 1 loser. Otherwise 'None'
      is returned.
      
      Note: A negative Kelly percent e.g. -1.16 or -0.08, means the strategy lost
      money. The sign is important here. The actual value does not give any useful
      information as far as I can see.
      
      posted in Indicators/Strategies/Analyzers
      Richard O'Regan
      Richard O'Regan
    • RE: Help with starting up

      Hi,

      I understand where you are coming from.

      I personally think Daniel has done a thorough job with documentation. Was easier to use than QuantConnect docs (and QC have a bigger team of people).

      At the same time, I find BT docs quite technical and there are many features that I original didn't notice in the documentation that I then read in answers in these forums.

      There is the Quickstart guide, which is a nice help, but I feel like there needs to be like an idiots guide from complete scratch, eg 'Backtrader from beginner to advanced in 101 short source code example exercises'. Something fun and simple and quick and with many many exercises with answers.

      I'm thinking if I get more familiar with BT over next few months I could help out in some way with that.
      I a short video , screencast introduction to the source code, running through the major .py scripts and point out how things fit together.. perhaps some OO diagrams etc

      Maybe overtime the community will evolve and more contributors can help out.

      For now DrHari.. I've coded in many languages for a number of years, and picked up several API's and 3rd party software.. I'm very creative but along with that I'm mildly dyslexic.. I always find learning anything technical confusing at first, but just stick with it, do 90mins a day everyday if you can, and keep with it.. gradually the pieces of the jigsaw will come together and you will get the hang of it mate.. and gain a deep understanding.. it will feel slow at start and at times impossibly hard, but this steep learning curve will flatten, trust me, keep at it brother!!

      posted in General Code/Help
      Richard O'Regan
      Richard O'Regan
    • RE: Copyright Abuse?

      I had two pull requests cancelled. One was small and I had message saying it was fixed in a different way. The other, my Kelly analyzer was cancelled along with copyright notice.

      The Kelly analyser isn't that important but I've spent a couple of weeks writing a nice strategy statistics table output that I think will help community. I was going to upload it this week. Hopefully issue will be sorted soon as I wrote it for community! Would be helpful to see more information.

      posted in General Discussion
      Richard O'Regan
      Richard O'Regan
    • RE: I added Kelly Percent to analyzers

      And here is what it looks like in action.. :)

      0_1505412222718_Untitled.png

      posted in Indicators/Strategies/Analyzers
      Richard O'Regan
      Richard O'Regan
    • RE: Modifying Trade class to include entry and exit price

      @ThatBlokeDave Hey cheers Dave. Another interesting way to solve problem. Yeah I think your method is better actually, I hadn't considered this.

      However since for myself I will likely only ever backtest the simple type of entry/exit, I think its easier to not worry about trying to implement the more complex open ended trade. Though if I wanted to make public I'd definitely reconsider.

      Check this out what I've done so far. Using Plot.ly for convenience as nice interactivity (if anybody knows anything better pls let me know). This is a fictional test system and doesn't actually make money. You can see I can enter multiple trades and see entry, exit and profit. (Green lines = profitable trade, red = loss).

      I also made profit use R-Multiples instead of raw price profit (another hack that probably will crash in complex cases!). I'll prob make a separate post of this plotting another time, I find it really helpful to check my logic is working correctly.

      0_1510639453561_tradePlot2.png

      posted in General Code/Help
      Richard O'Regan
      Richard O'Regan
    • I've just discovered who made copyright violations on Backtrader.

      Hi guys, I found this on Twitter, I think this is the answer to the copyright issue.

      0_1508209297219_trumpFinal.png

      posted in General Discussion
      Richard O'Regan
      Richard O'Regan
    • RE: Modifying Trade class to include entry and exit price

      Yeah I was initially considering Bokeh. It seems the plotting wasn't quite as nice but I think is more flexible. It was 50:50 between them.. if anyone can say for sure pros / cons which is better, I may switch to Bokeh.

      Yes correct, plots after backtest complete.

      Right now my code is spread out in a Jupiter notebook, I can plot trades and also do heatmaps/3d charts of optimisations. I'm looking to make more of a solid environment to test my ideas. Once I set up I can release the code, you should be able to plug into your backtesting easy. It's not too long or complex.

      Here are a couple of screenshots from backtesting another system. Surprisingly quick to do these plots.

      2_1510647970671_heatmap1.png 1_1510647970671_heatmap2.png 0_1510647970670_3dchart.png

      posted in General Code/Help
      Richard O'Regan
      Richard O'Regan

    Latest posts made by Richard O'Regan

    • RE: Wavelet bandpass indicator for backtrader

      Hey thanks very much for that Dave.
      I had a runtime crash. Rather than duplicate code, I sent screenshots. Run in a Jupyter Notebook. instead of importing bbwavelet.py module, i just copied and pasted your forum code into the notebook, so that bbDWT was already defined.

      0_1512214323418_code1BT.png

      0_1512214329656_code2BT.png

      0_1512214338722_errorBT1.png

      posted in Indicators/Strategies/Analyzers
      Richard O'Regan
      Richard O'Regan
    • RE: backtrader_contrib

      @Richard-O'Regan I can't seem to edit my previous post, I wanted to make my question above clearer [has editing been disabled?]. So all our code we submit as pull requests must include a licensing comment right?
      Just thinking of the 'copyright' issues a few weeks ago.
      Thanks

      posted in Announcements
      Richard O'Regan
      Richard O'Regan
    • RE: backtrader_contrib

      Nice one. Just to confirm, we need to add in comments referring to one of the licenses e.g. from https://www.gnu.org/licenses/gpl-howto.en.html

      '''
      NewAnalyzer.py was written by Richard ORegan 2017.
      
      This program is free software: you can redistribute it and/or modify
          it under the terms of the GNU General Public License as published by
          the Free Software Foundation, either version 3 of the License, or
          (at your option) any later version.
      
         This program is distributed in the hope that it will be useful,
          but WITHOUT ANY WARRANTY; without even the implied warranty of
          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
          GNU General Public License for more details.
      
         You should have received a copy of the GNU General Public License
          along with this program.  If not, see <http://www.gnu.org/licenses/>.
      '''
      
      posted in Announcements
      Richard O'Regan
      Richard O'Regan
    • RE: Wavelet bandpass indicator for backtrader

      heya Dave, just invested an hour reading your links. Interesting stuff. I think there is probably a number of people in this forum also interested in this subject. I have a bit of an overview from reading up on this, though I feel it would take me weeks to get up to speed with this subject! I'm wondering how money could be made using these techniques, i.e. where is the edge?

      1. Perhaps I could look for reversions of actual price with the filtered price.. e.g. when filtered price was less than market price sell market etc..
      2. Or perhaps I could use filtered line to do trend calculations in the hope that I could predict trend a bit quicker before others in market did ..catch a move earlier etc.

      You have given some code examples on how to use, if you have time, would you be able to provide a basic visual example e.g. a line of close of a stock and the wavelet filtered line, and what the line means . etc? Would be really helpful to see something visual - aids understanding).

      Cheers mate
      Rich

      posted in Indicators/Strategies/Analyzers
      Richard O'Regan
      Richard O'Regan
    • RE: Backtest with custom columns problem.

      @Ta-Tum Hey mate. Please could you provide your file you read from, then I'll run through it and can probably figure it out quite quickly.

      I noticed your line:

      dataframe = pd.read_csv("model/SET50_H1_2011_2017_Model1_Predicted.csv",names = ["Datetime","Open","High","Low","Close","action"])
      

      Uses 'action' . and yet your dataframe has 'Signal'
      dataframe.head()

      Out[58]: 
                   Datetime    Open    High     Low   Close  Signal
      0 2011-06-13 11:00:00  705.56  705.76  703.67  704.41     0.0
      1 2011-06-13 12:00:00  704.25  704.52  701.51  701.69     1.0
      

      This may not be relevant, my familiarity with pandas loading csv with backtrader is not high enough that I can diagnose just from source, I'd need to run, look at errors in realtime & play around with it to figure it out.

      Send the .csv file (or a shortened version) and should be easy to fix

      posted in General Discussion
      Richard O'Regan
      Richard O'Regan
    • RE: Wavelet bandpass indicator for backtrader

      @bigdavediode hmm..When you saying smoothing of function. Could I use to eg with price as input to look for cycles? Or would I apply this to e.g. an indicator to again look for key frequencies within that. Any chance you could upload a simple example demonstrating? Perhaps with a visulisation/plot before and after? Sounds highly interesting.

      posted in Indicators/Strategies/Analyzers
      Richard O'Regan
      Richard O'Regan
    • RE: Modifying Trade class to include entry and exit price

      Yeah I was initially considering Bokeh. It seems the plotting wasn't quite as nice but I think is more flexible. It was 50:50 between them.. if anyone can say for sure pros / cons which is better, I may switch to Bokeh.

      Yes correct, plots after backtest complete.

      Right now my code is spread out in a Jupiter notebook, I can plot trades and also do heatmaps/3d charts of optimisations. I'm looking to make more of a solid environment to test my ideas. Once I set up I can release the code, you should be able to plug into your backtesting easy. It's not too long or complex.

      Here are a couple of screenshots from backtesting another system. Surprisingly quick to do these plots.

      2_1510647970671_heatmap1.png 1_1510647970671_heatmap2.png 0_1510647970670_3dchart.png

      posted in General Code/Help
      Richard O'Regan
      Richard O'Regan
    • RE: Conspiracy Theory

      Hey I think you may be right :) he couldn't abandon us and couldn't resist sitting there reading our dumb questions and not responding..!

      In hindsight would have been better to create Paska a month or so before the copyright fiasco and start answering questions alongside Backtrader, so appears two separate users.. [less suspicious when he suddenly appears from nowhere, knowing everything!]

      link text]

      posted in General Discussion
      Richard O'Regan
      Richard O'Regan
    • RE: Modifying Trade class to include entry and exit price

      @ThatBlokeDave Hey cheers Dave. Another interesting way to solve problem. Yeah I think your method is better actually, I hadn't considered this.

      However since for myself I will likely only ever backtest the simple type of entry/exit, I think its easier to not worry about trying to implement the more complex open ended trade. Though if I wanted to make public I'd definitely reconsider.

      Check this out what I've done so far. Using Plot.ly for convenience as nice interactivity (if anybody knows anything better pls let me know). This is a fictional test system and doesn't actually make money. You can see I can enter multiple trades and see entry, exit and profit. (Green lines = profitable trade, red = loss).

      I also made profit use R-Multiples instead of raw price profit (another hack that probably will crash in complex cases!). I'll prob make a separate post of this plotting another time, I find it really helpful to check my logic is working correctly.

      0_1510639453561_tradePlot2.png

      posted in General Code/Help
      Richard O'Regan
      Richard O'Regan
    • RE: Modifying Trade class to include entry and exit price

      @Paska-Houso Hey Paska, thanks again. Ok just to clarify what you are saying.

      Understood creating 'old_update(..)' and calling it from my overridden update(..).

      Couple of issues.

      1. If I'm using the first, second heartbeat, is it correct that I will also need to check for tradeid because I often have trades overlapping each other. i.e. I will need to eg put trade in a dict with tradeid as key and count first and 2nd heartbeat associated to that unique id.

      2. What advantage will this give me over what I'm doing now. i.e the simple 2 line code I first posted. Both are incompatible with more complex cases and both will work for simple cases.

      Many thanks

      posted in General Code/Help
      Richard O'Regan
      Richard O'Regan