Backtesting.py - Full course in python

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 เม.ย. 2024
  • A full course covering all you need to know about the backtesting.py python library. Backtesting.py is a lightweight backtesting framework in the style of Backtrader which enables us to quickly get up and going.
    Get in touch:
    chad@greyhoundanalytics.com
    Or through my site:
    greyhoundanalytics.com/contact/
    ⭐ You will learn how to:
    ⌨️ Quickly get up and running with your own strategies.
    ⌨️ Run multi timeframe strategies
    ⌨️ Do parameter optimization and find the best parameters for your strategy
    ⌨️ Optimize your strategy to a custom metric
    ⌨️ Use different order types, stop-loss, take-profit, and shorting..
    ⏱️ Timestamps:
    (00:00:00) Course Introduction
    (00:03:21) Quickstart
    (00:16:59) Parameter Optimization
    (00:22:52) Custom optimization metrics
    (00:26:54) Organizing saved backtests
    (00:30:22) Randomized Grid Search
    (00:32:38) Parameter Optimization Heatmaps
    (00:42:48) Multi-timeframe strategies
    (00:49:13) Shorting, stop loss, take profit
    (00:58:42) Order Sizing
    (01:03:17) Extracting Trade Data
    (01:05:23) Bar Since Function
    (01:09:08) Wrapping up
    TA-lib installation:
    Windows:
    • [SOLVED] How to instal...
    Linux (Possibly mac as well):
    • TA-lib Install Guide f...
    📋 Blog Posts (with code):
    greyhoundanalytics.com/blog/b...

ความคิดเห็น • 232

  • @ChadThackray
    @ChadThackray  2 ปีที่แล้ว +6

    Consulting available at:
    greyhoundanalytics.com/contact/

    • @user-yt7wr2de7s
      @user-yt7wr2de7s 8 หลายเดือนก่อน

      I have metadata error when doing pip install backtesting

  • @ishaangupta3471
    @ishaangupta3471 ปีที่แล้ว +1

    Thanks a lot for this! Found exactly what I was looking for to run optimization.

  • @samueltamayogaviria3377
    @samueltamayogaviria3377 2 ปีที่แล้ว

    Holy ...!! I've been waiting for a course for this library, thanks!!

  • @danchatka8613
    @danchatka8613 ปีที่แล้ว +25

    This is an amazingly good tutorial and you, Chad, are an amazingly good teacher/guide. You don't make things more complicated than they are. You stay on track.

  • @naelshichida7940
    @naelshichida7940 ปีที่แล้ว +2

    Absoultely love the content, thanks for your hard work and grit.

  • @dilip.rajkumar
    @dilip.rajkumar 2 ปีที่แล้ว +12

    Thank you for another Great video. I really do Love your video and channel, so much information on topics where there is hardly any information elsewhere ✌️. BTW, could you post in the description a pros and cons table comparing VectorBT vs. Backtesting.py or perhaps you can make a short 5 min video comparing the differences and highlighting the use cases.

  • @stansuen8072
    @stansuen8072 ปีที่แล้ว +3

    Awesome tutorial! Learnt a lot! Thanks a lot.

  • @oliverSaquarema
    @oliverSaquarema 11 หลายเดือนก่อน +1

    Chad, I really appreciate your content, very well explained, you are an excellent teacher and your content is incredible! thanks again! I will study all the content on your channel!

  • @aingo6521
    @aingo6521 ปีที่แล้ว +1

    Thank you for sharing this. I learn a lot from you ! much respect !

  • @TundraKaffe1
    @TundraKaffe1 ปีที่แล้ว +2

    Perfect course! The best out there by far.
    What I still don't get is how to replace a sl or tp if a certain event happens.
    For example I would like to move my stop loss up if a take profit of another order was hit.

  • @andhikaseptiawan8036
    @andhikaseptiawan8036 ปีที่แล้ว +1

    Very Informative, helpful and Educational video! Thx for the tutorial man!

  • @simulateworld3198
    @simulateworld3198 2 หลายเดือนก่อน +1

    I was looking for this type of tutorial you are the man❤❤

  • @flydr2
    @flydr2 2 ปีที่แล้ว

    Thank you for taking the time to do this... Very helpfull to me.

  • @syng9596
    @syng9596 ปีที่แล้ว

    thx for the very detailed tutorial! appreciate it!

  • @glenrichzuso9076
    @glenrichzuso9076 11 หลายเดือนก่อน +1

    I am watching your tutorial over the others because your using VIM as your editor :)
    This shows the commitment of a person to learn beyond what is required
    Awesome work and thank you for the wonderful tutorial !

  • @virtuallore
    @virtuallore 6 หลายเดือนก่อน

    Brilliant. Very high quality work ❤

  • @transcendmoney
    @transcendmoney ปีที่แล้ว +1

    Best tutorial of backtesting.py on youtube !, thanks

  • @MrWittzHD
    @MrWittzHD ปีที่แล้ว +1

    this was wonderful, thank you very much

  • @deviatewithDarrell
    @deviatewithDarrell 4 หลายเดือนก่อน

    Great video Chad. I really appreciate you taking the time. I'm three months into learning Python and stock investing and I was able to follow along this entire video.

    • @ChadThackray
      @ChadThackray  4 หลายเดือนก่อน

      Good luck Darrell!

  • @nicolasepalaciosm8072
    @nicolasepalaciosm8072 ปีที่แล้ว +1

    Thanks for the video, awesome explanations! New subscription ;)
    I'm left thinking if it's possible to use some of the functions of the library in a different code which is mean to do trades and not only backtesting? Specifically, the bars since function.
    I ask because as I understand it as of now (after watching the video), you only seem to be able to use it inside a class which is extending the Strategy class imported also from this specific library, your RsiOscillator in this case.

  • @jungkyunyang5184
    @jungkyunyang5184 ปีที่แล้ว +1

    Hi Chad, Thank you for the good video. If I had known this video first, I could have saved a lot of time. But I was able to get a lot of ideas from watching this video. Thanks once again.

  • @jordansoftware5941
    @jordansoftware5941 ปีที่แล้ว

    Thanks for sharing your wealth of knowledge in this excellent series Chad. I love your name by the way.

  • @jontycraine4903
    @jontycraine4903 2 ปีที่แล้ว

    Another great Backtesting video Chad

  • @JurinoJr
    @JurinoJr 4 หลายเดือนก่อน

    That was an awesome tutorial, thanks a lot!

  • @SOMEONE-eq5bu
    @SOMEONE-eq5bu ปีที่แล้ว

    that was an excellent tutorial, thanks for sharing, liked and subbed.

  • @10milesfromnowhere
    @10milesfromnowhere ปีที่แล้ว

    Thanks! Great tutorial.

  • @samueltamayogaviria3377
    @samueltamayogaviria3377 2 ปีที่แล้ว +2

    could you make more in depth explanations for each action you can make with this library?

  • @behradio
    @behradio ปีที่แล้ว

    Awesome Tutorial, Thanks a lot.

  • @ramanuj_g
    @ramanuj_g 2 หลายเดือนก่อน

    dude this was fantastic... helped a ton..thx...

  • @GEORGESDominique
    @GEORGESDominique 2 ปีที่แล้ว +2

    Very interresting and clever explanation about backtesting. I'm looking since a few months for readable and understandable content about backtesting, and .. I just found it now :) Thanks for that.
    I'm more "crypto market" oriented, and more scalping strategy interrested (I don't have so much time to trade :'( )
    Thanks for this video, and waiting for the next ones.
    PS : I modified this message and deleted my "request" about developping a BOT, it is in your blog ;)

  • @trilokyadav4159
    @trilokyadav4159 หลายเดือนก่อน

    Hi Chad, thanks for the detailed tutorial! Is it possible to backtest mulit-asset strategies using this API i.e. say option straddle strategy, or say buying a stock and shorting an index at the same time if a signal is generated? Otherwise this would be really limited long/short strategies only and not dollar/delta neutral strategies.

  • @tradewithaakash2939
    @tradewithaakash2939 8 หลายเดือนก่อน

    You are just amazing !! thankyou so much for sharing your knowledge

  • @gkr7078
    @gkr7078 ปีที่แล้ว

    This is the best tutorial on backtesting iN TH-cam.. a quick question. How do I for loop through different strategy classes for running tests in backtesting.py

  • @richardchu1593
    @richardchu1593 8 หลายเดือนก่อน

    In the tutorial, there is example to resample from daily to weekly data such as:
    self.weekly_rsi = resample_apply("W-FRI", talib.RSI, self.data.Close, self.rsi_window).
    However for future contract such as MNQ, its session opening time is not exactly in the same day (using Eastern Time as base). For example MNQ's monday session starts trading from Sunday 6PM ET until Monday 5PM ET.
    Than for the above case, how do you define "session", "daily" and "weekly" resample?
    Thank you so much!

  • @brianrowe1152
    @brianrowe1152 ปีที่แล้ว +1

    Maybe cover trailing stop in a future video? Or can you replace an open order to sell with a new order that you want instead? For example a trailing stop % from the average price, not the close?

  • @naveenkumar-mh6zf
    @naveenkumar-mh6zf ปีที่แล้ว

    Enjoyable and informative video.

  • @chimgaebu8419
    @chimgaebu8419 6 หลายเดือนก่อน

    thank you very much. this is very gorgeous video !!!! . It is very helpful.

  • @ArneGockeln
    @ArneGockeln หลายเดือนก่อน

    Good tutorial and introduction of this backtest library! Thanks. One last question: Would you bet your real money on strategies that you have tested with this library?

  • @mehmetemin9598
    @mehmetemin9598 ปีที่แล้ว

    good tutorial, one question about soft recording. How do you do it? lol

  • @Machiuka
    @Machiuka หลายเดือนก่อน

    Very good tutorial. I have some problems to install TA-LIB on my Win11 computer, because of the Python version that I have (3.11). I solved this by creating an environment with Python 3.10.

  • @davidhazle3234
    @davidhazle3234 หลายเดือนก่อน

    Chad, another really good training tutorial . Are you able to share the python code with each of your tutorialss pls?

  • @masoud603
    @masoud603 ปีที่แล้ว

    thanks alot. it was very useful

  • @GascanNBK
    @GascanNBK 10 หลายเดือนก่อน

    nice video, what about extending the Stats with CAGR/MaxDD?

  • @kadermoossa
    @kadermoossa 2 ปีที่แล้ว

    Thank u… By the way, I like your contents a lot because of your exclusive content, as well as your deep and soothing voice,
    With that British accent :)
    so because of that, I can normally watch an hour-long video with no boring

  • @mohamedhicham6298
    @mohamedhicham6298 หลายเดือนก่อน

    Hey Chad great work, i have a question. If i have a dictionary of dataframes for 50 stocks. All of the dataframes have the same start and end date. So how can i run a backtest over all of them instead of running the backtest only one a single dataframe?

  • @220SouthlandAve
    @220SouthlandAve หลายเดือนก่อน

    Hey, great content! I'm wondering how your init function is working properly without a double underscore..isn't init usually a dunder method?
    Thanks.

    • @ChadThackray
      @ChadThackray  หลายเดือนก่อน

      It's not a real __init__ function. We're just overriding a function from the parent class

  • @karthickb1973
    @karthickb1973 2 หลายเดือนก่อน

    i needed this today. chad sent

  • @user-uc6wo1lc7t
    @user-uc6wo1lc7t ปีที่แล้ว +1

    There is df.droplevel(axis=0, level=2) to drop "rsi_window" index level. That would be more reasonable to use instead of grouping and using meaningless .mean method.

  • @surprise7917
    @surprise7917 ปีที่แล้ว

    Amazing video!

  • @HarpreetSingh-ps9rx
    @HarpreetSingh-ps9rx ปีที่แล้ว

    Brilliant video

  • @protopan7722
    @protopan7722 4 หลายเดือนก่อน

    Hey what do you think of quant connect?

  • @vivekghule5601
    @vivekghule5601 8 หลายเดือนก่อน

    How to write a strategy in backteting like : input data to backtest is one-minute chart, logic : get High and Low of 2 PM (5 minute candle), and then if current close > high buy order with target 20points , if current close < low sell with tartget of 20 points.
    Thanks

  • @timjx3675
    @timjx3675 ปีที่แล้ว

    Great channel - I wonder if you have come across Empyrial portfolio analysis
    And if so what do you think of it

  • @V3ritas1989
    @V3ritas1989 10 หลายเดือนก่อน

    hey, nice intro. Waht about position sizing with futures or CFDs ? With margins, over night margins, what about slippage, broker costs as well as spreads?

  • @trollrequiem0444
    @trollrequiem0444 ปีที่แล้ว +1

    Thank you! Nice video! Is there any way to save the equity line data, so that you can, for example, draw it with matplotlib?

    • @ChadThackray
      @ChadThackray  ปีที่แล้ว

      Yep! You can get it from the stats. So you have something like:
      output = bt.run()
      curve = output._equity_curve
      If you look it's just under all the other stats like sharpe, etc. You get a nice pandas df you can plot to your heart's content

  • @jroche1832
    @jroche1832 ปีที่แล้ว +1

    great video however I have a complex indicator which I am struggling to backtest. Do you have any strategies that you have built which are complex for example VIX/VVIX correlation?

  • @raphaelarguello5020
    @raphaelarguello5020 22 วันที่ผ่านมา

    Great content, thanks for your work!
    I am struggling with the size of the position for the backtesting. I am trying to risk 1% of the available cash per position so I enter the sl and size = 0.01. However, the risk is completely off and it only risk 0.014%
    I am also confused because in the video you just enter size without stop loss, but risk is normally calculated in function of the sl
    Would you maybe have a solution please?
    Thanks for your help!

  • @brich8110
    @brich8110 ปีที่แล้ว

    Very nice video thank you

  • @transcendmoney
    @transcendmoney ปีที่แล้ว +1

    Hello, by default is doing size of units, how will be possible to make sizes with decimals, for example always enter with 0.95 of equity in ethereum, should be units with decimals

  • @studiox_ui
    @studiox_ui 2 ปีที่แล้ว

    dude you're the fucking best please post more about algotrading thanks

  • @TheRealEstatePerson
    @TheRealEstatePerson 7 หลายเดือนก่อน

    how do I pull data of crytocurrencies?

  • @Luca-wg4cv
    @Luca-wg4cv 8 หลายเดือนก่อน

    hi i have a huge problem, if i fix the quantity 1 i don’t work the code regarding the peack and the final how can i fix it?

  • @fauxz3782
    @fauxz3782 9 หลายเดือนก่อน

    Excellent video

  • @nukewares
    @nukewares 4 หลายเดือนก่อน

    great work, this is excellent. I also appreciate the northern accent. It's been a while since I've heard a proper one.

  • @supertamtamtom
    @supertamtamtom 9 หลายเดือนก่อน

    Can we put constraints on more than 1 parameter, and maximize/minimize several (more than 1) parameters?

  • @randb9378
    @randb9378 8 หลายเดือนก่อน

    Can you use a ML algorithm as part of your strategy? (ML algorithm will be trained on data to say buy, sell, or hold?) Thanks for the video! You're awesome

  • @cosmicblack
    @cosmicblack ปีที่แล้ว

    I justo hace a question
    When i'm un the next method
    To use the actual data and the before injusto need yo use (for ex) self.rsi[-1] and [-2].?

  • @andreagiunta168
    @andreagiunta168 ปีที่แล้ว

    hi there. I would like use Bollinger Bands and consider "lenght" and "stdev" as variables to be used within the optimization function. have you got some solving answer?!??!?! pllsssssss

  • @ghazanferali366
    @ghazanferali366 ปีที่แล้ว +1

    Great video, very informative.
    I am just having one problem while applying the multitimeframe strategy. If resample_apply is done on an indicator which takes more than one inputs, it is giving all sorts of errors.

    • @ghazanferali366
      @ghazanferali366 ปีที่แล้ว +1

      self.tf2MDI = resample_apply(
      '3T',ta.MINUS_DI(high,low,price,self.n) As an example is not working

  • @hourglass9
    @hourglass9 ปีที่แล้ว

    Great Video! Can you simultaneously do a backtesting on all symbols
    like for example EURUSD and SPUSD
    so if I buy on SP500 on 2011-01-07 and sell on 2011-01- 10 then in the next buy this program will recheck the opportunity in EURUSD and SPUSD and automatically matches the buying signal and then buy that stock after 2011-01-10
    in this way we can have a full return on investment
    😀

  • @VidyabhushanUpadhye
    @VidyabhushanUpadhye ปีที่แล้ว +2

    Hi Chad, this is a wonderful tutorial. Very well explained with the right context.I need help with the date column from a CSV file. python is not reading it as DateTime format but instead, it is reading it as an object. Not able to solve it, and because which not getting Sharpe and other ratios.

    • @ChadThackray
      @ChadThackray  ปีที่แล้ว

      I would look into the pd.to_datetime function from pandas, that will help you convert the date column from a string into datetime format

    • @VidyabhushanUpadhye
      @VidyabhushanUpadhye ปีที่แล้ว

      @@ChadThackray Thanks a lot. It worked. not the ratios are being calculated.😊👍

    • @VidyabhushanUpadhye
      @VidyabhushanUpadhye ปีที่แล้ว

      Hi @@ChadThackray, I am observing that my entries and exits are delayed by two candles not sure why it is happening. Send you an email with the python code and data file. Thanks

  • @DigitalTrading
    @DigitalTrading ปีที่แล้ว

    great course

  • @zeus_2001
    @zeus_2001 ปีที่แล้ว +2

    Excellent tutorial. I like the simplicity of this library. It's too bad it can't test and aggregate results for multiple tickers.

    • @damienong1462
      @damienong1462 ปีที่แล้ว

      There is a way to do it. By using for loop, where you will be able to test multiple tickers and even multiple timeframe. (if this is what you mean, it's easy to do it especially with this library, compare to freqTrade)

    • @zeus_2001
      @zeus_2001 ปีที่แล้ว +1

      @@damienong1462 No, that's not what I meant. Looping just runs a sequential series of separate tests. What I'm talking about involves trading multiple instruments as a single strategy.

  • @scripthunter3738
    @scripthunter3738 ปีที่แล้ว

    Great tutorial yar

  • @juanbatista6075
    @juanbatista6075 ปีที่แล้ว

    Super.Great

  • @priyankamore1458
    @priyankamore1458 ปีที่แล้ว

    is there any other forex backtesting library, because I am having an issue regarding order size, leverage, lot size which are bit different than stock or crypto market...It would be very helpful. Thank you

  • @K_line_sorter
    @K_line_sorter ปีที่แล้ว

    How to set the transaction time? For example, trading is only done between 8-12 New York time.

  • @mrrrokas
    @mrrrokas 11 หลายเดือนก่อน

    You an absolute chad

  • @timonfranz4996
    @timonfranz4996 4 หลายเดือนก่อน

    Hi Chad, is there any possibility to extend the _trades dataframe with for example the stop loss and take profit? Or any other trade attribute like a specific trade enty criteria? This would be very helpful to analyse which trades working and which are not working.

    • @ChadThackray
      @ChadThackray  4 หลายเดือนก่อน

      It's open source so anything is possible. I would just build my own logger though in the main logic and use that to analyse

  • @kvekka9300
    @kvekka9300 ปีที่แล้ว

    @chad...how can it be run to test bracket orders

  • @fiftyghoststrading8500
    @fiftyghoststrading8500 ปีที่แล้ว

    Thank you for the vid! Did you leave the TA-lib installation link anywhere? I'm not seeing it

    • @ChadThackray
      @ChadThackray  ปีที่แล้ว +1

      Just updated the description

    • @fiftyghoststrading8500
      @fiftyghoststrading8500 ปีที่แล้ว

      @@ChadThackray Cool, thank you! Great video, by the way.. it got me up and running!

  • @Cavz001
    @Cavz001 6 หลายเดือนก่อน

    Great video sir. Quick question. Delving deeper into algorithmic trading, I’ve found that mere backtesting isn’t sufficient and processes like out-of-sample backtesting, Sample parameter optimization, walk-forward optimization and Monte Carlo Simulation are viltal to creating a solid system. Question is: how do you conduct these tests with Python?

    • @ChadThackray
      @ChadThackray  6 หลายเดือนก่อน

      You are correct. There are many videos here on youtube that will teach you how to do these other tests. Some of those topics I've covered myself on this channel

    • @Cavz001
      @Cavz001 6 หลายเดือนก่อน

      @@ChadThackray cool. I’ll check them out. Thank you

  • @LucasMoreira-gz6xg
    @LucasMoreira-gz6xg ปีที่แล้ว

    great content

  • @blasdelezo8396
    @blasdelezo8396 2 ปีที่แล้ว

    Thanks for the video. Many questions and queries come to me.
    How to code a stop loss and take profit as a percentage of the purchasing power?
    Is there bibliography of online courses regarding this backtesting library?

    • @ChadThackray
      @ChadThackray  2 ปีที่แล้ว

      It's a relatively niche library so there's not much content out there. Hence this video

    • @ChadThackray
      @ChadThackray  2 ปีที่แล้ว

      It's a relatively niche library so there's not much content out there. Hence this video

  • @fabriciofiel
    @fabriciofiel 2 ปีที่แล้ว

    Congratulations on the content, very good!
    I would like to suggest a video with backtesting in renko with wick.

  • @GD-bx5pk
    @GD-bx5pk ปีที่แล้ว

    Hi Chad @ 1:15 you said it doesn’t try to integrate with a broker does that mean i can only backtest and optimise i cant trade with it via api or whatever. I’m a python beginner

    • @ChadThackray
      @ChadThackray  ปีที่แล้ว +1

      Yes, there are no live trading functionalities. You could probably modify it to do that if you wanted, but it wouldn't be too easy

  • @Thegiant4296
    @Thegiant4296 ปีที่แล้ว +1

    I am new to python and was just curious what you're using to write your code in? I couldn't make it out when you said it in the beginning but would like to use the same platform

    • @ChadThackray
      @ChadThackray  ปีที่แล้ว +1

      I'm using Vim, a command line based text editor

    • @Thegiant4296
      @Thegiant4296 ปีที่แล้ว

      @@ChadThackray Thank you!

  • @drcesarvarela
    @drcesarvarela ปีที่แล้ว

    Hello Chad, thanks for the video. It's really useful. I wonder if this library can be used in intraday backtesting strategies. I'm asking because the format date in intraday data includes %D%H%S format and since the data retrieved from the library itself includes just %Y%M%D only I'm not sure if it can handle intraday data. Can you please provide more information about this query, thank you in advance.

    • @ChadThackray
      @ChadThackray  ปีที่แล้ว +1

      Yeah you can use whatever timeframe you want. In this instance it's formatted like that because it's daily data from yfinance. But it works exactly the same with intra-day data

    • @drcesarvarela
      @drcesarvarela ปีที่แล้ว

      @@ChadThackray Thanks for the prompt reply, you have a new subscriber.

  • @purasuerte1.0
    @purasuerte1.0 2 หลายเดือนก่อน

    please could anyone provide an example of a simple macd strategy. I've got:
    class RsiOscillator(Strategy):
    def init(self):
    self.macd = self.I(ta.macd, pd.Series(self.data.Close))
    But I don't know how to refer to the signal & the macd column in def next(self):

  • @garyin5
    @garyin5 ปีที่แล้ว +1

    Hi Chad, I am interested in running the backtesting with multiple threads in gpu-process. Could you please help to talk more about how to run it with GPU?

    • @daxj9133
      @daxj9133 ปีที่แล้ว

      You can use CUDA

    • @FilSerge
      @FilSerge ปีที่แล้ว

      Have you succeeded in that?

  • @RobbiLian
    @RobbiLian ปีที่แล้ว

    Hi Chad, thanks for your video, it's helping me very much.
    Here I have a question when following your video finish the first step(backtesting sell when rsi>70 and buy at rsi < 30)
    pf.stats show Duration is 3116 days, but raw data GOOG only has 2148 rows.
    Is it right?

    • @jungkyunyang5184
      @jungkyunyang5184 ปีที่แล้ว +1

      Hello. the source code is like that trades_df['Duration'] = trades_df['ExitTime'] - trades_df['EntryTime']
      just between entry time and exit time

    • @RobbiLian
      @RobbiLian ปีที่แล้ว

      @@jungkyunyang5184 Thanks😀

  • @mustafasoeminabdullah3613
    @mustafasoeminabdullah3613 3 หลายเดือนก่อน

    You're pretty good.

  • @canea4637
    @canea4637 ปีที่แล้ว

    If you are on Mac OS and use home brew just do brew install ta-lib

  • @astrojes849
    @astrojes849 ปีที่แล้ว +1

    You really are a Chad. Fr

  • @guidomarquez8973
    @guidomarquez8973 ปีที่แล้ว

    Hello!! Excellent video. I am exactly the code shown in the video, however I get the following error: "TypeError: Can't instantiate abstract class GoldenCross with abstract method init". What can it be, the version of python (I use 3.8.0)?

    • @user-yx1fy7sn5z
      @user-yx1fy7sn5z ปีที่แล้ว

      Type def init(self) instead of def __init__(self) . It was my mistake too

  • @vinnyvidivici5930
    @vinnyvidivici5930 ปีที่แล้ว

    noob question here, what is that screen at 5:10 when you type "from backtesting import Backtest, Strategy" ? i successfully downloaded python, and my 'pip install backtest' in the CMD window worked, but where do i go to get what you have at 5:10? what screen is that? thx!

    • @ChadThackray
      @ChadThackray  ปีที่แล้ว

      I'm using vim here as my text editor on the command line. You might want to use something like visual studio code or pycharm or similar program, which will do the same thing

  • @cosmicblack
    @cosmicblack ปีที่แล้ว

    nice video, i just have a question. im looking into de the documentation how i can set the data to the strategy instead of using GOOG or EURUSD. Buy i still not able to find it. Do you know how to feed the data to the strategy from a csv file?

    • @cosmicblack
      @cosmicblack ปีที่แล้ว

      i'm just guessing, but i dont know if i just need to set self.data = my_data, where my_data is a pd.DataFrame with my data. but i'm looking if its correct and the structure fo the datafram because what i read in the doc seems to be de open_time as index. am i correct?

    • @ChadThackray
      @ChadThackray  ปีที่แล้ว

      @@cosmicblack Just load in the CSV as a pandas dataframe. Then feed it in the same as we do for GOOG

    • @cosmicblack
      @cosmicblack ปีที่แล้ว

      @@ChadThackray thanks a lot. Im creating an indicator, the SSL because i didnt found it in talib library to test it. But i still have the problem with my dta. With GOOG its not issue but with my data it is. It has the Open High Low Close columns but im using 5m timeframe and my open_time colmn i setted as the index. is that correct? the Documentation doesnt says much about the topic

  • @transcendmoney
    @transcendmoney ปีที่แล้ว +1

    so seems backtesting.py can't trade with fractional sizes (fractional ethereum for example 0.99 have to be 1 or 2 ethereum)

  • @gurkanozturk4620
    @gurkanozturk4620 ปีที่แล้ว

    this is a very good video thanks for the information u gave but I have a problem. when I optimize my variables I can see the variables for example length_of_ema = 24,std_of_bbands = 2 but when I use same variables(24,2) as bt.run() in my code I don't get the same output as bt.optimize() gave me. also I don't have other variables

  • @HeroeJarrot
    @HeroeJarrot ปีที่แล้ว

    It's amazing the plot function, there is a way to export it?

    • @ChadThackray
      @ChadThackray  ปีที่แล้ว +1

      The plot is saved as a html file in the folder you run the script from, so you can re-use that.
      Alternatively you can just screenshot it

    • @HeroeJarrot
      @HeroeJarrot ปีที่แล้ว

      @@ChadThackray thanks! I was thinking in deploying it with mljar-Mercury. By the way, would you recieve my personal resume please? I'm looking for job :)