HUGE SCALE Backtest of Intraday Cryptocurrency Data using Python & SQL

  Рет қаралды 28,534

Algovibes

Algovibes

Күн бұрын

Пікірлер: 124
@christopherchen416
@christopherchen416 2 жыл бұрын
Loving the humour 😂. "Moment of silence" "did I waste your time? Maybe.."
@jodhvirsingh8677
@jodhvirsingh8677 2 жыл бұрын
Let me be very clear....you never waste our time man...u teach us invaluable things👏👏
@Algovibes
@Algovibes 2 жыл бұрын
Thank you so much Jodhvir!
@hoapham7389
@hoapham7389 2 жыл бұрын
it's only matter of time until you get more subscribers, lots of small things gets repeated over the past videos and it gets more familiar. I love it!
@Algovibes
@Algovibes 2 жыл бұрын
Thanks for your motivation and your kind words man :-)
@andreasschulze3563
@andreasschulze3563 2 жыл бұрын
I‘ve been expecting this! Das hab ich mir neulich genauso gedacht! Richtig guter Ansatz! Thx
@Algovibes
@Algovibes 2 жыл бұрын
Thx :-)
@inspiration2292
@inspiration2292 2 жыл бұрын
Recently found your channel, love your down to earth, clear style! big help
@Algovibes
@Algovibes 2 жыл бұрын
Thank you very much my friend. Very happy to read that!
@jancan9168
@jancan9168 2 жыл бұрын
Sehr interessantes Video. Eine coole Idee wäre nun ein Loop über diese Funktion mit unterschiedlichen TimeFames um zu schauen, wo der beste Profit erziel wird und wo der break even liegt. Mach weiter so
@Algovibes
@Algovibes 2 жыл бұрын
Danke dir! Ja, genau das ist der Punkt. Einfach, dass man ein paar Daten hat und mit denen dann n bisschen rumspielen kann. Was du meinst, wäre z.B. eine sehr interessante Frage.
@rraul
@rraul 2 жыл бұрын
This video is unbelivable. Awesome. As always, pure gold content. Thanks
@Algovibes
@Algovibes 2 жыл бұрын
Thank you very much rraul!!
@goodyonsen77
@goodyonsen77 Жыл бұрын
Sounds like a huge meteorite touchdowned in Frankfart @23:27, sorry Frankfurt. Weird.
@user-iy2qo6no2d
@user-iy2qo6no2d 2 жыл бұрын
Superb, the fee is my biggest problem so far. When we talk about the big crypto winners you will find a few lucky miners, early investors but most likely exchange founders and originators of cryptos. (Talking about BIG BIG Money)
@HermanWillems
@HermanWillems 2 жыл бұрын
big crypto winners trough algo's love to hide in the shadows :)
@Algovibes
@Algovibes 2 жыл бұрын
Good point. Thanks for sharing your viewpoint!
@marmalade12319
@marmalade12319 2 жыл бұрын
Super helpful, much appreciated
@Algovibes
@Algovibes 2 жыл бұрын
Happy to read, thanks a lot for watching :-)
@walduss7939
@walduss7939 2 жыл бұрын
Interesting video! Akso, being a newbie in pyrhon, I am impressed how you manage the dataframe. If I try to do the same , my code will be 100x larger!
@Algovibes
@Algovibes 2 жыл бұрын
Thanks mate. You will get there with the time. There is alot of improvement potential for me as well. Don't worry about it.
@willbrenton8482
@willbrenton8482 2 жыл бұрын
Does simply subtracting costs account for the fact trading fees reduce buying power over the backtest period? I feel like this is still overstating? Perhaps this is a log property? Would appriciate any insights or resources. Thanks!
@andrewyoung3135
@andrewyoung3135 2 жыл бұрын
the fact you wrote out coins = (ect) ..... sub on the spot !
@Algovibes
@Algovibes 2 жыл бұрын
Thanks for your support man. Glad it is helpful!
@cryptolicious3738
@cryptolicious3738 2 жыл бұрын
great video ! happy holidays. why did u leave out the trailing stop loss ? thats one of the best features in a strategy imho
@Algovibes
@Algovibes 2 жыл бұрын
Thanks mate. Will covering TSL in one of my future videos surely.
@kia4now
@kia4now 2 жыл бұрын
Hello AlgoVibes, Im a big fan and have watched most your videos. Do you share the code anywhere for this, Im stuck at the part of building the DB and Im getting a lot of errors, do you happen to have a community chat anywhere. That would be super helpful, thanks for all your hard work
@Algovibes
@Algovibes 2 жыл бұрын
Hi man, thanks a lot for your support and your kind words. I am usually sharing the code based on the engagement on a video.
@trader8322
@trader8322 2 жыл бұрын
Thanks for the valuable content. can we run this code 24/7 ? if so how we can do it ? do we need to host it in any server or git hub ?
@Algovibes
@Algovibes 2 жыл бұрын
Welcome man. Can you elaborate on why you would run this 24/7? You mean like regularly updating the Database?
@MrHamish1998
@MrHamish1998 2 жыл бұрын
Love your videos, you've taken me from a noob at coding to fairly good in a year so I can't thank you enough! Just an idea for you: maybe do a back-test but include leveraged tokens/futures could be interesting? I ran through this back-test and made a few changes, adding the ability to short trading leveraged assets with x5 leverage. The returns were enough to absorb the commission but I'm sceptical it's too good to be true.
@Algovibes
@Algovibes 2 жыл бұрын
Hi mate, thanks for your kind words. Love to read that! :-)
@TheLantani
@TheLantani 2 жыл бұрын
Im getting closer and closer!!! Tomorrow is test time
@Algovibes
@Algovibes 2 жыл бұрын
Awesome, let me know how it worked out :-)
@TheLantani
@TheLantani 2 жыл бұрын
@@Algovibes got a rough week but i will give it a try when the planeta alignes
@leventbozkurt9796
@leventbozkurt9796 2 жыл бұрын
Thank you. Well done.
@Algovibes
@Algovibes 2 жыл бұрын
My pleasure! Thanks a lot for watching :-)
@gregd1218
@gregd1218 2 жыл бұрын
What I get from your videos usually is how data manipulation should be done properly. I tend to solve this problem the wrong way because I don't know how to use panda properly. I'm learning a lot thx. One question though, why didn't you do the download with multithreads? Wouldn't it had drastically cut the download and insert time?
@Algovibes
@Algovibes 2 жыл бұрын
If you are getting anything out of the video that's nice! Thanks man. Didn't download with multithreads because of this: www.binance.com/en/support/faq/360004492232 Maybe one is not touching the limits but feel free to test it out yourself!
@gregd1218
@gregd1218 2 жыл бұрын
@@Algovibes yeah that's what I was thinking, API limit. I think I'll give it a try, for the sake of it. Looking forward your next video!!
@thomasniedermayer5956
@thomasniedermayer5956 2 жыл бұрын
Nice Video! Shouldnt the cost be cost = (1-0.00075)^trades? Because if you e.g have 1000 dollars and take away 5 percent 2 times you have 1000*(1-5/100)*(1-5/100) = 1000* (1-5/100)^2
@Algovibes
@Algovibes 2 жыл бұрын
Hi and thanks a lot for your comment. It depends if your investment amount is fixed. If it is not you are right but if it is you are paying steady fees. In your example the amount would shrink to 950 and the next 5% are calculated on the 950.
@anders21karlsson
@anders21karlsson 2 жыл бұрын
Great video, thanx
@Algovibes
@Algovibes 2 жыл бұрын
Thanks for watching Frankenstein :>
@kekotalaverano
@kekotalaverano 2 жыл бұрын
I get that you use sqlite to simplify all, but if you use the stream data I guess you can have problems with concurrence. Awesome video btw. Grettings from Spain
@Algovibes
@Algovibes 2 жыл бұрын
Thank you man! Can you elaborate on concurrence?
@kekotalaverano
@kekotalaverano 2 жыл бұрын
@@Algovibes Yeah as far as i know sqlite its a non threat-safe database, i mean u can only write or read on one threat at a time. So if you are using a datastream to write, the threat writing its blocking the database, so cannot be readed. It´s not concurrence it is concurrency. Sorry for my bad english. xD
@anshmiester78900
@anshmiester78900 2 жыл бұрын
Thank you so much for making these videos
@Algovibes
@Algovibes 2 жыл бұрын
Thank you for checking them out!
@financialblocks
@financialblocks 2 жыл бұрын
Hi, stellt Binance mehr als 500 Werte zur Verfügung? Dachte 500 wären beim Spot Max.
@Algovibes
@Algovibes 2 жыл бұрын
Hi, kurz gesagt: Nein. Binance arbeitet mit gerichteten Requests. Mehr Hintergrund zu limits hier: www.binance.com/en/support/faq/360004492232
@random_birch_forest
@random_birch_forest 2 жыл бұрын
This video is "GODLIKE" (in computer games terms). Well done and thanks a lot!
@Algovibes
@Algovibes 2 жыл бұрын
Haha :D Played a lot of Games in my youth - and still do occasionally. Thanks a bunch for your comment.
@3rdpartylegends
@3rdpartylegends 2 жыл бұрын
Hi Algovibes could you make a video on how to fetch the data from tradingview along with indicators
@Algovibes
@Algovibes 2 жыл бұрын
Not on my list but I just checked, there is a trading view python API, so would be quite interesting. Noted it, but as said, can't promise if I will tackle that.
@3rdpartylegends
@3rdpartylegends 2 жыл бұрын
@@Algovibes ok thnx for info
@johnwarblock9898
@johnwarblock9898 2 жыл бұрын
Hey buddy, i really respect you for your content and your type video with code. Can u share with me, which strategy in trading the best for 30-60 minutes trade with Machine learning, in your opinion?(sorry for my language, English isn’t my nativ language )
@Algovibes
@Algovibes 2 жыл бұрын
Thanks for your kind words man. Well you have everything to test out some stuff 😛
@random_birch_forest
@random_birch_forest 2 жыл бұрын
Why does Binance return the time for the start of the candlestick and not the end of the candlestick? E.g. Closing price of '1m' candle of 18:59 timestamp is equal to the closing price of '15m' candle of 18:45 timestamp. (Hope this explanation does make sense). Is this done to be able to report unclosed candles, e.g. when the request happens in the middle of a '15m' candle, we still get some data from the last candle which has not closed yet?
@Algovibes
@Algovibes 2 жыл бұрын
Can you pass me a timestamp in the video where you see that?
@random_birch_forest
@random_birch_forest 2 жыл бұрын
@@Algovibes at 5:29 if you pass '15m' into getminutedata you will see that the time of the candle is the starting time and not the ending time. This can be found out by comparing the closing prices of 1m and 15m.
@diaboloshots
@diaboloshots 2 жыл бұрын
Hi Algovibes! Firstly, thanks for the amazing content you're putting out. Its great to see a code focus and I absolutely love how you take the time to explain all the detail either here or in a previous video ... much Kudos! My question is, how would you approach developing a backtesting algorithm if the sell condition depended upon the return of that particular trade. So for example lets say I wanted to buy at midnight every day, and then sell when the return of that trade was 1%. In a live trade this isn't too hard to keep track of, but how would you back test it when the sell relies on the return calculation which is then 'reset' after each trade. Also you could end up holding for 3 days or so which means the buys in the middle would not occur. Hopefully an interesting one for you! 😊
@diaboloshots
@diaboloshots 2 жыл бұрын
To slightly add to this. I think the problem lies with, how to determine that we are in a trade if the buy condition is only 'true' for one or two rows. How do we 'latch' this condition with vectorisation? 🙂
@Algovibes
@Algovibes 2 жыл бұрын
Thanks a lot Alex! Appreciate your comment. An interesting question indeed. The more granular your data is, the better you can do this kind of calculation. What you could e.g. do is to take a livestream containing live prices and store them in a DB (I actually did this in a lot of my cryptobot videos - which can be found in the cryptobot playlist). With that you can apply the selling logic better than just take the minute granular data distorting the "real" returns.
@progtuts6071
@progtuts6071 2 жыл бұрын
we are iterating coin dataframes and assume we are taking position for every signal, how can we iterate all dataframes at once and go minute by minute?
@Algovibes
@Algovibes 2 жыл бұрын
Can you elaborate on your question? Been quite some time since I published this video. In the best case provide me some timestamps where you have questions on.
@progtuts6071
@progtuts6071 2 жыл бұрын
@@Algovibes ​here we are going coin for coin, could we somehow go for example 1h for 1h for all coins ? Because in live trading you are looking at the whole market at once . Just asking if you have any ideas?
@Golapeofficiel
@Golapeofficiel 2 жыл бұрын
Hi, I have done some backtest with yfinance library, but when I tried it in real time with binancesocketmanager, it didn't work at all, I suppose that dellay causes too much price divergence (was doing trading on 1m scale) :(
@Golapeofficiel
@Golapeofficiel 2 жыл бұрын
Actually you speak about that at the end
@Algovibes
@Algovibes 2 жыл бұрын
Yep, exactly.
@SaverioZanco
@SaverioZanco 2 жыл бұрын
Always good job, seriously:-) I'm study your video in this day for more concept of stock data, SQL maybe the best and is the "next level", it semmes Timescale DB offrer much power! Anyway it's my opinion just i want shared with you:-) Good jobs and very appreciate for you work:-)
@Algovibes
@Algovibes 2 жыл бұрын
Thanks a lot for your kind words man. And also thanks for the suggestion! Didn't work with Timescale DB yet but have heard good things.
@meetshah4800
@meetshah4800 2 жыл бұрын
Is there any Datafeeds or Library to obtain data of Stock Indices for 1min time interval(Over 5 years)??
@meetshah4800
@meetshah4800 2 жыл бұрын
free
@Algovibes
@Algovibes 2 жыл бұрын
Would be nice :D But I wouldn't know of something like that. Only free data is cryptocurrency price data on that granular timeframe.
@raydan18
@raydan18 2 жыл бұрын
Do you take requests to make robots for money?
@Algovibes
@Algovibes 2 жыл бұрын
I currently don't. Maybe in the future!
@BOSprodz
@BOSprodz 2 жыл бұрын
Could you please explain how to use our 1 minute dataframe to create 15m, 1hr etc dataframes?
@Algovibes
@Algovibes 2 жыл бұрын
Hi mate, correct me if I am wrong but didn't I do that in exactly this video? :D
@BOSprodz
@BOSprodz 2 жыл бұрын
@@Algovibes True, I didn't watch to that part! But doesn't the resample simply skip over the data in between? I was talking about creating a new dataframe with all correct fields for other timeframes (I did manage to do this myself eventually, using the .agg() method to apply sum/min/max etc to the columns). Btw, I think a video where you do a complex strategy (even if it isn't profitable) would be really educational! I'm trying to play around with it myself but I'm not sure how to make the program "consider" much more factors at the same time (and it also has to "forget" them after they are irrelevant) Thanks again for everything you do!
@teenspirit1
@teenspirit1 2 жыл бұрын
What commission and slippage did you apply?
@Algovibes
@Algovibes 2 жыл бұрын
Quite confused with that question as it is exactly discussed in the video...Can you elaborate? Thx in advance!
@Septumsempra8818
@Septumsempra8818 2 жыл бұрын
How do we build a schema for balance sheet data AND price data? s/o from South Africa
@Algovibes
@Algovibes 2 жыл бұрын
Either use MySQL as e.g. in my Stock recommendation playlist or as subtables in a SQLite database.
@somajuice666
@somajuice666 2 жыл бұрын
What if i wanted to use Bollinger Band strategy?? Then i cant just hold?
@Algovibes
@Algovibes 2 жыл бұрын
Exactly. Then you can't use this approach but need to implement a logic that the upper or lower band was hit. I have actually covered that here: kzbin.info/www/bejne/boHdgoadrJWGpq8
@sazamhashmi
@sazamhashmi 2 жыл бұрын
How can i get in contact with you?
@Algovibes
@Algovibes 2 жыл бұрын
Here! How can I help you?
@vijax21
@vijax21 2 жыл бұрын
All your tutorials are LONG --> Buy & Sell. could you please help do a tutorial for short selling backtest? it would be intersting to see what profits can be made on certain strategy. thank you
@Algovibes
@Algovibes 2 жыл бұрын
Maybe I got your wrong but I am actually covering a lot of videos on short strategies (e.g. Momentum, Reversal). Even in the video I am stating how you would design the function when you want to include shorting.
@vijax21
@vijax21 2 жыл бұрын
​@@Algovibes I am sorry! I certainly didn't get to watch all of your tutorials. but thank you for pointing me to topics. I shall check it out now. Thank you again! Cheers!
@chapmansbg
@chapmansbg 2 жыл бұрын
I was of the opinion that binance only gives 7 days for 1 minute data? Am I missing something here?
@tayaamme9954
@tayaamme9954 2 жыл бұрын
With binance you can download 1 minute data from the beginning of the listing (on binance) of a coin.
@chapmansbg
@chapmansbg 2 жыл бұрын
@@tayaamme9954 I have hit limits before
@Algovibes
@Algovibes 2 жыл бұрын
What you are referring to is yfinance. There you can only go back 7 days for intraday.
@chapmansbg
@chapmansbg 2 жыл бұрын
@@Algovibes oh, I rarely use yfinance but probably transferred that thinking from there without testing.
@themechanicaltechnologist6121
@themechanicaltechnologist6121 2 жыл бұрын
Hello! I'm a beginner using the binance API and I'm getting stuck just trying to make a program access my binance account using the API keys. I wrote a test script of a trading strategy that takes live data and then prints buy, sell, wait to buy, or hold. If it decides to sell, it also prints the buy price. I got the program logic to function how I want it to, and now I want to actually connect it to my account and let it start to buy and sell crypto. However, for some reason, I keep getting an error that says either my API keys are wrong, my IP is invalid, or I don't have the required permissions. I've tried multiple API keys, my IP is unrestricted, and I gave the API permissions to do everything it should be able to do. I also get this message same message when I wrote a simple script just to view my basic account info. I'm not sure what I'm doing wrong, any help would be appreciated!
@Algovibes
@Algovibes 2 жыл бұрын
Hi mate, first guess would be: Do you fulfill the requirements of legitimation? Binance is requiring a higher level of authentication for API actions. I needed to go through the KYC process.
@chapmansbg
@chapmansbg 2 жыл бұрын
Shouldn't you only calculate the percentage return on the difference between the buy price and the sell price?
@Algovibes
@Algovibes 2 жыл бұрын
Yes, but the Close price is the best guess. How can we exactly know the buyprice? I have talked about that problem in the very end of the video.
@chapmansbg
@chapmansbg 2 жыл бұрын
@@Algovibes your method is pretty smart. I have also wondered how to separate the close and buy prices in an elegant way. It is always so cumbersome and brute force.
@khawajadanyialahmad45
@khawajadanyialahmad45 2 жыл бұрын
Hi sir I want to make fiver gig for trading bots can you tell me which bots i can make for my client on freelancing platform
@Algovibes
@Algovibes 2 жыл бұрын
Hi man, I don't really get the question. Can you elaborate?
@wethebelievers260
@wethebelievers260 2 жыл бұрын
Sir I want a binance bot can you plz help me with it??
@wethebelievers260
@wethebelievers260 2 жыл бұрын
@Algovibes I am your subscriber sir from past 3 months. Can I get your mail ID so I can send you details?
@Algovibes
@Algovibes 2 жыл бұрын
Thanks a lot for your support man. How can I help?
@wethebelievers260
@wethebelievers260 2 жыл бұрын
@@Algovibes sir I want you to create a bot for me. As I don't know anything about Python or coding. I want your mail ID so I can send you detailed logic of the bot.
@wethebelievers260
@wethebelievers260 2 жыл бұрын
You are ready to pay for the project sir. I have to discuss logics of bot with you
@meetshah4800
@meetshah4800 2 жыл бұрын
Yahoo finance is unable to fetch data of 1min more than 7 days I want solution
@Algovibes
@Algovibes 2 жыл бұрын
Solution is pretty much straightforward: There is not a good datasource for stock data fulfilling your requirements.
@itayhilel2168
@itayhilel2168 2 жыл бұрын
Great video, now let's lose some money!!
@Algovibes
@Algovibes 2 жыл бұрын
Haha :D
@henrifritsmaarseveen6260
@henrifritsmaarseveen6260 2 жыл бұрын
you know what is big tick data from 30 FX pairs from the last 20 years ..
@Algovibes
@Algovibes 2 жыл бұрын
Haha :D I hope you got interesting insights? Anyhow you can scale the crypto data here. You can theoretically go back years.
@JoseAltagracia
@JoseAltagracia 2 жыл бұрын
…………………………………………..…………Maybe 😂
@javierloa9197
@javierloa9197 2 жыл бұрын
Who said Germans ( assumption) don't have a sense of humor. 🤣
@Algovibes
@Algovibes 2 жыл бұрын
Your assumption might be right :P
@meetshah4800
@meetshah4800 2 жыл бұрын
Please Help🥺
@Algovibes
@Algovibes 2 жыл бұрын
Sure, but how? 🥲
@meetshah4800
@meetshah4800 2 жыл бұрын
@@Algovibes I had one data downloaded I just want that into datetime format
@meetshah4800
@meetshah4800 2 жыл бұрын
@@Algovibes Please check comments on crypto video of 1min
А что бы ты сделал? @LimbLossBoss
00:17
История одного вокалиста
Рет қаралды 6 МЛН
Крутой фокус + секрет! #shorts
00:10
Роман Magic
Рет қаралды 37 МЛН
Solving real world data science tasks with Python Pandas!
1:26:07
Keith Galli
Рет қаралды 1,5 МЛН
Stock Price Prediction Using Python & Machine Learning
49:48
Computer Science (compsci112358)
Рет қаралды 1,2 МЛН
А что бы ты сделал? @LimbLossBoss
00:17
История одного вокалиста
Рет қаралды 6 МЛН