How To Build a Cryptocurrency Live Trading Bot with Python using the Binance API [SMA Crossover]

Поділитися
Вставка
  • Опубліковано 11 вер 2024

КОМЕНТАРІ • 111

  • @360turns2
    @360turns2 2 роки тому +2

    Great content, I like your explanations are very clear and coding style is neat.

    • @Algovibes
      @Algovibes  2 роки тому

      Thanks a lot for your feedback.

  • @eduardob5463
    @eduardob5463 2 роки тому +2

    Execellent video!!! Thanks for all your work and you detailed explanations, really appreciated.

    • @Algovibes
      @Algovibes  2 роки тому +1

      Awesome to read. Thank you very much :-)

    • @wethebelievers260
      @wethebelievers260 2 роки тому

      @@Algovibes sir how to contact you I want a crypto bot, can you help me?

  • @vijax21
    @vijax21 2 роки тому +4

    Absolutely loving your content.. I have learned so much... Really appreciate all the hard work that goes in making these videos.. keep up good work.

    • @Algovibes
      @Algovibes  2 роки тому

      Thank you very much for your kind words mate.

  • @walduss7939
    @walduss7939 2 роки тому +3

    Thanks for another great video.
    Just starting with python a few days ago I have been able to follow your binace crypto BOT videos.
    But these BOTs are getting more and more complicated. I am understanding them but for sure I will not able to do improvements easily by my own.
    Waiting for new ones to continue learning.

    • @Algovibes
      @Algovibes  2 роки тому +1

      Thanks man. There will be coming new ones for sure :-)

  • @suthantech7389
    @suthantech7389 2 роки тому +6

    Great work. Can you make a video on Telegram api and binance api ?
    Whenever a trade gets execetuted or triggered we should get notifications in Telegram bot. I haven't found any related videos.

    • @Algovibes
      @Algovibes  2 роки тому +1

      Nice suggestion. I actually did something similar in my stock recommendation series:
      ua-cam.com/play/PL9ATnizYJ7f9sW_mdY3071dS8mMwBGu2S.html

  • @frankvitetta
    @frankvitetta 2 роки тому +1

    Thanks so much for the educational video. Keep uploading

    • @Algovibes
      @Algovibes  2 роки тому

      Thank you mate, I'll try my best.

  • @MaxPorPanne
    @MaxPorPanne 2 роки тому +1

    Great vids be the way. Really informativ

  • @erwinwimmer2456
    @erwinwimmer2456 2 роки тому +1

    Deine Videos sind wirklich super! Hab sehr viel gelernt und freu mich auch schon mein Wissen, so wie du, weiter zugeben. Ich setzte mich gerade mit dem Thema qty auseinander und es ist tatsächlich gar nicht so einfach, den Maximalbetrag in % zu kaufen und verkaufen. Da gibt es verschiedene Herangehensweisen aber nicht wirkliche Lösungen. Welche Möglichkeiten würdest du in Betracht ziehen oder könntest du dazu mal ein Video machen? Allgemein, vielen vielen Dank :) lg

    • @Algovibes
      @Algovibes  2 роки тому +1

      Freut mich sehr zu hören, danke dir :-)
      Was meinst du genau mit Maximalbetrag?

    • @erwinwimmer2456
      @erwinwimmer2456 2 роки тому

      @@Algovibes Nichts zu danken, Ehre dem, dem auch Ehre gebührt und dir maximal!!! Ich kann dich aktuell leider nur unterstützen, indem ich regelmäßig auf die Werbung klicke und was da für ein Zeug daherkommt... haha, zum schreien :). Mit Maximalbetrag meinte ich, den gesamten Kontostand seitens USDT oder Coin. Kaufe ich für 100USDT Bitcoin, verkauft er es nicht mehr ab, da ja dann zu wenig im Wallet ist. Zb. ich habe 100€ in der Wallet und will aber nur 90% von den 100€ kaufen zb ADA. Danach will ich aber das er mir den gesamten Betrag wieder abverkauft. Ich habe zwar eine solche Lösung gefunden: buy_amount = int(0.80 * (float(balance["free"]))) die funktioniert aber mehr schlecht als recht. Kennst du eine andere Lösung dazu? glg

  • @taichannelus
    @taichannelus 2 роки тому +1

    First of all, thank you very much for producing such valuable content. The videos have been very helpful to me. I just want to ask a question. I want to trade with all the money in my wallet instead of entering the quantity when buying and selling. How do you think we can achieve this? Thank you in advance. Kind regards.

    • @Algovibes
      @Algovibes  2 роки тому

      Welcome mate! Thanks for watching my stuff. Yes, that's indeed possible. You can request a certain balance (e.g. USDT) per api call. I think I actually demonstrated that in the introductory video:
      ua-cam.com/video/_IV1qfSPPwI/v-deo.html
      Other than that be invited to check out my videos in the cryptobot playlist. I have covered tons of concepts there.

  • @Anzeljaeg
    @Anzeljaeg 2 роки тому +2

    love so much this kind of content, thanks buddy , im running my own version , and its doing quite good , 10-15 usd in a week , but today i just finished the versión will run for 1 month non stop, hope it works fine and se whats happend

    • @deusex1104
      @deusex1104 2 роки тому +2

      If your balance is 100 usd then 15 usd per week is pretty good. I was getting 6-8 per week with a similar bot then i shutted it down :) I will try this one for a month as well, best of luck to both of us then.

    • @mujahidazam8212
      @mujahidazam8212 2 роки тому +2

      Hello.. would u be able to share ur code?

    • @Anzeljaeg
      @Anzeljaeg 2 роки тому +1

      @@mujahidazam8212 ###.ua-cam.com/video/D6ETXConbaY/v-deo.html### I love that logic and made a bot using Algovibes coding and the other video logic, and boom you have a Nice bot

    • @mujahidazam8212
      @mujahidazam8212 2 роки тому

      @@Anzeljaeg - thanks..
      I checked out video.. with subtitles on.. so basically he is talking about the settings on RoyalQ bot and DCA.
      I am still learning to code.. so it would be quite some time that I would be able to apply the above logic.. would u be able to share the code that u have implemented so far if u have a repo?

    • @Anzeljaeg
      @Anzeljaeg 2 роки тому

      @@mujahidazam8212 yes sir, the strategy is quite good and well noting is 100% but this hits the 80% and is quite good, you can see, the robot kinda HOLDS and seee, what is going on, and using the step rule , increase the amount invested so when you earn proffit is kinda big, one time it made like 20usd in one move, and i have like i said 150usd in the account for testing, im still runing tests and like i said, it will be in a github opensource, hope it will help others ,

  • @blackrachmaninov
    @blackrachmaninov 2 роки тому +1

    Super interesting ! Will you do a video on how to trade binance futures with the API?

    • @Algovibes
      @Algovibes  2 роки тому

      Thanks for your feedback mate :-)
      I will cover Binance futures but probably beginning of next year rather than in this.

  • @jamescaleb9676
    @jamescaleb9676 6 місяців тому +1

    would be a lot better if it was done outside the jupyter notebook. not everybody uses it but everyone knows basic python and could adapt to whatever IDE they use.

    • @Algovibes
      @Algovibes  6 місяців тому

      Hi mate, I think Jupyter notebook tends to be the best platform to present code as you can go through it structurally. I did some videos with other IDEs and will do some in the future but tend to stick to Jupyter.

  • @Ruborubor1
    @Ruborubor1 2 роки тому +2

    why you don't use a binance testnet?

    • @Algovibes
      @Algovibes  2 роки тому +3

      Also possible. But didn't have any exposure yet.
      And I like the thrill of wasting my money :-)

  • @capture-everything54
    @capture-everything54 2 роки тому +1

    Hi there. Can you make a futures bot? Species are like this. 10x leverage, %1 profit and close trade, and %2 stop loss, and it has to work short and long. Can you do this?

  • @taylordearmond4585
    @taylordearmond4585 2 роки тому +1

    No idea if you'll check this since this video is almost 10 months old... but I'll ask a few questions anyway. For this strategy, you buy when ST crosses LT, but sell only for a stop loss limit. Would it make more since to get rid of the stop loss limit and sell when LT crosses ST? This cross location is always at a higher price than what you bought in at right?
    Could you also set the kline intervals to 1 hour instead of 1 day? That way you get more frequent crossovers between the ST and LT SMA?
    Again, I'm new to this and learning solely off these videos. Any help is appreciated!

    • @Algovibes
      @Algovibes  2 роки тому

      Hi Taylor, thanks a lot for your comment.
      Well, you need to backtest that. I actually have done both approaches. Be invited to check out the cryptobot playlist.
      You can change the time interval (also did that in other videos :P)
      Just check out both the Python for Finance and cryptobot playlist. I have a ton of videos on different strategies / approaches.

    • @taylordearmond4585
      @taylordearmond4585 2 роки тому +1

      @@Algovibes appreciate the response! I'll visit the playlist and give the videos a watch 👍

  • @mujahidazam8212
    @mujahidazam8212 2 роки тому +1

    Hi Algovibes - Great video..
    Had a doubt.. instead of 1D.. if we would like to do it every 15min.. should we call "gethistoricals" everytime when passing to "liveSMA"?

    • @Algovibes
      @Algovibes  2 роки тому

      Hi mate, thanks a lot. Well, I would be careful with that as everytime you are getting data from the socket you would make an API call. I would rather use a DB (e.g. SQL) here as in one of my first videos. So just call the DB which is being updated with new 15 min data.

    • @draugh1r219
      @draugh1r219 2 роки тому

      @@Algovibes Filling the db is not an api call? Or there are free db already pulled with data?

    • @harrisonw4559
      @harrisonw4559 2 роки тому

      @@draugh1r219 I think Algovibes point is that using SQL and a local DB (on your machine) to store the data would mean that you would fetch it from your own DB rather than call Binance everytime.
      You would add data to the DB as part of the async socket message process, and then just call that DB to get the data.

  • @rafaelar8472
    @rafaelar8472 2 роки тому +2

    Hello again! Sorry to bother you, but your videos have been of incredible help to me! But I have a question and I can't find the answer anywhere. On my robot I'm using the macd_diff indicator and it works pretty well, but for my strategy I need a robot with an error rate close to almost zero. Could you please advise me which indicators in your opinion are the best so that the robot can know when the chart will rise (when I say rise, it just needs to be a rise of 0.3 percent).

    • @Algovibes
      @Algovibes  2 роки тому

      No worries :-) Thanks a lot for your comment!
      Well that is dependent on a lot of factors. Why not play a bit around and see which would have worked on which asset?

  • @olafk8232
    @olafk8232 2 роки тому +1

    It can be done, but is this strategy actually useful/profitable? Did you backtest the strategy? I would be interested in the result.

    • @Algovibes
      @Algovibes  2 роки тому

      Good question. I have a lot of resources for Backtesting on my channel. Be invited to check it out and maybe give it a shot yourself? ;-)

  • @TheDolbyNR
    @TheDolbyNR 2 роки тому +1

    How much data will you need to pull on a daily basis when monitoring (let's say about) 10 cryptos? (I don't mean the historical data wich only needs to be pulled once a day, but the current data). Would it be ok to loop it only once every hour or so?

    • @Algovibes
      @Algovibes  2 роки тому +1

      Well it depends what you want to monitor. An hourly pull could be fine on the one hand but it could also be quite bad on the other hand. Say you buy the asset and set an e.g. stop loss at a certain price. If you would check if this threshold is crossed every hour you could end up in big losses while having avoided that checking every e.g. minute.

    • @TheDolbyNR
      @TheDolbyNR 2 роки тому +1

      @@Algovibes that does sounds plausible. I'll run some tests in the next days. Script looks awesome btw!

  • @bollusuresh7043
    @bollusuresh7043 2 роки тому +1

    Great video. Could you please help me in calculating EMA for 7 & 30 days in 15mins timeframe in Binance, pls help!!
    Or Guide me if you have already done in any video.

    • @Algovibes
      @Algovibes  2 роки тому

      Thanks mate! Sure, I already did it here:
      ua-cam.com/video/lJlkMXxsuZk/v-deo.html

  • @DrR0bot
    @DrR0bot 2 роки тому +2

    Awesome video again! really helpful with this content. Wanted to ask you how can you solve this problem in python "ConnectionClosedError: code = 1006 (connection closed abnormally [internal]), no reason" it seems the websocket disconnects. How can I make it to reconnect again within the while loop
    async with stream as receiver:
    while True:
    Thanks again!

    • @Algovibes
      @Algovibes  2 роки тому

      Thanks mate. When do you get this error? The socket disconnects after 24h. If that's not the reason you could implement exception handling.

  • @LH-si9ir
    @LH-si9ir 2 роки тому +1

    Benutzt du deine Bots auch oder macht es dir nur Spaß sie zu erstellen

    • @Algovibes
      @Algovibes  2 роки тому

      Dat name :D
      Ich nutze bots - ja. Nicht systematisch und nicht genau den, sondern etwas mehr Sachen, die da einfließen.
      Aber eher just for fun.

  • @johnyanastacio1107
    @johnyanastacio1107 2 роки тому

    Nice video!!

    • @Algovibes
      @Algovibes  2 роки тому

      Thank you very much Johny

  • @MrKferi
    @MrKferi 2 роки тому +1

    Hi! when you are selling the asset, in the condition should not be frame.price[-1] instead of frame.price[0]? am i wrong?
    Thanks for the videos i am learning a lot!

    • @Algovibes
      @Algovibes  2 роки тому

      Welcome mate,
      frame has only one row so I am just indexing for the value.

  • @dDoOyYoOuUtTuUbBeE
    @dDoOyYoOuUtTuUbBeE 2 роки тому +1

    But contrary to stocks, crypto is a continuous market, there is no "close" per se with a gap between close time at 17:00 of the place and the open time the next day morning at 9:00, even if all is IT now.

    • @Algovibes
      @Algovibes  2 роки тому

      Good point but doesn't have an effect on the applied concepts.

  • @bigqclasses3542
    @bigqclasses3542 2 роки тому +1

    Sir which software are using for python ?

    • @Algovibes
      @Algovibes  2 роки тому

      Jupyter Notebook

    • @bigqclasses3542
      @bigqclasses3542 2 роки тому +1

      @@Algovibes thanks sir

    • @bigqclasses3542
      @bigqclasses3542 2 роки тому +1

      Sir can you make a trading bot based on moving average=5 & moving average =20 cross over strategy + previous candle high breakout ? That's a profitable strategy

  • @TaiNguyen-xl5sq
    @TaiNguyen-xl5sq 2 роки тому +1

    Hello, can you tell me how to keep the loop run forever, even after selling?

    • @Algovibes
      @Algovibes  2 роки тому

      Hi mate,
      I have covered deploying a bot in this video here:
      ua-cam.com/video/mDNIAkEZChg/v-deo.html
      You don't necessarily need the cloud platform and can use the logic on your local system.

  • @JazeraCS
    @JazeraCS 2 роки тому +1

    I was wondering, since you are using the ST and LT from a day average, could you change this to being lets say 15min average? and what would have to change in the code for it to do so?

    • @Algovibes
      @Algovibes  2 роки тому +2

      Would be a bit different, as the part of the script wouldn't be static anymore and would have to be pulled every 15 min. Ad hoc I would probably just use a DB where I am storing the 15 min timeframe and update it frequently and grab the data from there.
      But there will be better ways for sure. Didn't think about it yet.

    • @JazeraCS
      @JazeraCS 2 роки тому

      @@Algovibes Yea, I'm even doing it on a one minute basis at the moment where I have my historical function running as async aswell and having it async sleep for 60 seconds every time so that the API gets to publish their new minute values before I pick them up. I must tell you it is very ugly but it works haha. Thanks so much for the video's tho, you've learned me so much in programming in python overall!!!💯💯❤‍🔥

    • @johannesschmidtdelaunay9340
      @johannesschmidtdelaunay9340 2 роки тому

      I think this depends on which interval you use when calling get_historical_klines. Binance Python API Documentation gives you better insights

  • @suryadesings4486
    @suryadesings4486 2 роки тому +1

    it is very easy and easy to understand but the last if function is not working by showing the loop.run_until_complete(main('ADAUSDT', 100, 0.999)) line
    please solve this problem

    • @Algovibes
      @Algovibes  2 роки тому

      Thanks for your feedback man, can you elaborate what exactly is not working?

    • @suryadesings4486
      @suryadesings4486 2 роки тому

      The last line of the program i.e loop.run_until_complete(main('ADAUSDT', 100, 0.999))

    • @TheDolbyNR
      @TheDolbyNR 2 роки тому

      @@suryadesings4486 I'm having the same issue. I think I solved it by enabling the API Spot & Margin Trading but use client.create_test_order instead of client.create_order

  • @chapmansbg
    @chapmansbg 2 роки тому +1

    If you wanted to display the script in action why don't you change the time frame to 1 minute or something like that?

    • @Algovibes
      @Algovibes  2 роки тому

      Just because the historical series is based on daily data. It wouldn't make sense to take the 1 minute data.

  • @samb23692
    @samb23692 2 роки тому +1

    Hi, any tips to code price action? Thanks for this video. 🙏

    • @Algovibes
      @Algovibes  2 роки тому

      Welcome mate. I have it on my list!

  • @wethebelievers260
    @wethebelievers260 2 роки тому +1

    Sir how to get connected with you? I want to create a binance bot

    • @Algovibes
      @Algovibes  2 роки тому

      What's stopping you? 😛

    • @wethebelievers260
      @wethebelievers260 2 роки тому

      @@Algovibes I want your mail id or telegram so I can send you detailed project. So we can discuss further about..

  • @hammerjoe2008
    @hammerjoe2008 2 роки тому +1

    how many bots can you run without getting into issues with the API calls?

    • @Algovibes
      @Algovibes  2 роки тому

      There are API limits. You can find them in the API docs. Don't have them in my head right now.

    • @hammerjoe2008
      @hammerjoe2008 2 роки тому +1

      @@Algovibes maybe a suggestion for a future video, how to adapt this code to run several pairs at the same time without hitting the API limits.
      I mean it must be possible to get the prices for all the tokens listed on the exchange instead of just one!

    • @estebansantamaria8729
      @estebansantamaria8729 2 роки тому

      I can run up to 7 bots based in the bot of this video..

  • @walduss7939
    @walduss7939 2 роки тому +1

    I am not sure if I have something wrong, when I print historicals, I get two lines (23 and 24). But in your video you get only one line.
    I am checking but didn’t see any mistake in my code.
    Some tips?

    • @walduss7939
      @walduss7939 2 роки тому +1

      Even if I change the line to receive until 5 days ago I still getting 24 lines
      this is the line that I am using (change '5 days ago' to '1 day ago' , but still having the same result
      df = pd.DataFrame(client.get_historical_klines(symbol, '1d',
      str(LT) + 'days ago UTC','5 days ago UTC'))

    • @Algovibes
      @Algovibes  2 роки тому

      Just checked that. If you take 1 day ago this won't happen.

  • @eliemaalouf5852
    @eliemaalouf5852 Рік тому

    can you do one for heiken ashi candles sma crossover plz?

  • @MaxPorPanne
    @MaxPorPanne 2 роки тому +1

    Hallo do you know if there is a working Trade Republic api ?

    • @Algovibes
      @Algovibes  2 роки тому

      As a TR user myself I was taking a look at and played around with this one here:
      github.com/Zarathustra2/TradeRepublicApi
      and
      pypi.org/project/pytr/
      Ofc this is not official and not recommended to use.

    • @MaxPorPanne
      @MaxPorPanne 2 роки тому +1

      @@Algovibes Thanks for the quick answer.

  • @janandersen2695
    @janandersen2695 2 роки тому +1

    That is quite some work, when this can be done by one mouse click on a no-code platform. Then of cause, that is not programming.

    • @Algovibes
      @Algovibes  2 роки тому

      True!

    • @parmenides2576
      @parmenides2576 2 роки тому +1

      Coding it yourself allows you to ensure it does what you want it to do, can defend against front running, and allows you to tweak it however you want. For example I used to auto buy crypto once per week through coinbase, but realized I had no control, so I coded a bot to auto buy the dip once per week through coinbase API.

    • @janandersen2695
      @janandersen2695 2 роки тому

      Do you consider make a section with no-code development ? Think it is an inevitable future at some point.

    • @draugh1r219
      @draugh1r219 2 роки тому

      @@parmenides2576 Can i ask you if it works and what % daily is it? I know a lot python so making a bot is not difficult but i was studying the right strategy and maybe the right indicators.

    • @janandersen2695
      @janandersen2695 2 роки тому

      @@parmenides2576 Front running is the most typical bug when programming, does not exist in non-programming. Precompiled code is reproducible, a coded strategy is changed many times, and you need to make sure no bugs at every adjustment. Quantopian had to close cause users could not produce anything useful (SaaS + Python), what makes you think YOU can succeed what 10.000 user at Quantopian couldnt do ? It is a complete waste of time to try develop algo in Python. So go home and be something for your friends and family, instead of wasting many years of your life in this.

  • @ludwigmatheus762
    @ludwigmatheus762 2 роки тому +1

    Hello professor, look, is there any way to test this algorithm without having to do the buy-sell operation? Because I still don't have a balance in binance. Can it be through a SQLlite database?

    • @Algovibes
      @Algovibes  2 роки тому

      Hi buddy,
      Yes. You could e.g. just create a list / an array and store the prices there and see how much you made/lost.
      I also heard about the Binance testnet but didn't use it yet.

    • @SiHodgy
      @SiHodgy 2 роки тому

      # place a test market buy order, to place an actual order use the create_order function
      order = client.create_test_order(

  • @cryptotaxi2184
    @cryptotaxi2184 2 роки тому +1

    Ein Discord Server wäre super! / A discord server would be awesome

    • @Algovibes
      @Algovibes  2 роки тому +1

      Kommt sicher im Verlauf des nächsten Jahres.

  • @loteronloteron3410
    @loteronloteron3410 2 роки тому +1

    i want coded with you)))

  • @carlosprieto2554
    @carlosprieto2554 2 роки тому +2

    No entendi un sevillo pero gracias

    • @Algovibes
      @Algovibes  2 роки тому

      My translator said you didn't understand anything but failed on translating "Sevillo". Can you help me out? :D

  • @ofirtzabari
    @ofirtzabari 2 роки тому +1

    looking great !!!
    i have ptoblem the metod get_historical_klines not return the correct num of row
    i write the same and its return only 5 rows

    • @Algovibes
      @Algovibes  2 роки тому

      Thanks mate, can you elaborate on your problem?