Cryptocurrency Trading Bot which is buying 🚀 Coins using Python and Binance

Disclaimer: This video is not an investment advice and in specific not a recommendation to trade this strategy. It is simply a transformation from a trading idea to …


  1. Hey I'm Getting RuntimeError: Event loop stopped before Future completed. Error After first loop and my PyLance showing "Code is unreacahble" for await client.close_connection() this line do you have any idea to fix this?

  2. Thanks for the explanation, glad I stumbled upon this, I've come by articles and videos of people that grew a $100K to over $800K in just few months, what do you guys think they invested in and how can one outperform the market and make such profit

  3. I tried this. when I run first script it runs without any error update data base also, but it stop taking data after few min (loop is continuously running since it is while true: ) . I think there is a comment asking same but I couldn't find a solution. can you please help on this

    Thank you for this grate work. it help us to learn and think innovatively.

  4. Thank you very much for the code and the idea. I am trying to do the same thing. I use 1min kline data, which updates current prices every 2 seconds.
    The code presented uses "3 min previous continuous trade data" as base for percentage calculation. Kline data can also be considered continuous (2 sec discrete, and a bit delayed, but ok ) you can identify candle close prices too. I have a question about the strategy. We are trying to catch rapid price increases early, so we can go along with, right? Earlier better but too early might trigger false alarm.
    – 1-2-3 minutes previous continuous data can be used as base for percentage of increase calculation.
    – 1-2-3 minutes ohlc candle close prices can be used.
    – 1-2-3 minutes previous continuous data min-max prices can be used to calculate pct and to open and to close trades.
    – Single price data or average of consecutive few price data (SMA) can be used as base or current price…
    Which one do you think better?

  5. Sorry again, bro. I tried to make it run, first using it as an idea to something new, and after that I tried to make it exactly like you, and it didn't run.
    SQL alchemy don't create the DB, I made the same with sqlite3 and it creates the DB but it never feed it, and never got an error msg.
    It's driving me insane, because I want to learn, but I don't know what am I doing wrong.
    Could it be a failure because the python version?

  6. I was wondering if you'd ever do a video over decision trees? I was thinking how they might be used to create a strategy based on some indicators. Maybe if given some data at a period in time it could decide to buy, sell, or do nothing, it would be better than us simply writing some buy and sell rules. Would like to see what you could do with some decision tree derived strategy

  7. Hallo Algovibes,
    super Kanal und richtig gute und interessante Beiträge. DANKE.

    Considering my question, I will continue in English. In your previous video you have shown how to get minute k-line data of the best performing coins. However, this extraction methods is time consuming and, hence, may cause a lag for the at first extracted prices. Now, in this video you have shown us how to use the asyncio multiplex socket option to "quickly" extract latest live data which you than continuously appended to a local DB.

    I noticed that using the latter method, the live data are not equally distributed, of course. If one plots the data for any coin, it can be easily seen that there are clusters of prices around one second and than again a varying "time gap" to the next cluster. Sometimes there are two or even more price values for an equal timestamp. Thus, the calculation of trends or changes appears misleading. What would you say?

    My idea was to group the live data into minute-intervals and to "generate" k-line data, i.e. to define open, close, low and high in between the interval. This is just a midsize modification of your "qry" function in script 2.

    I than thought that it would be interesting to compare both "k-line creation" methods, i.e. the use of "client.get_historical_klines(…)" and the above described way. Of course, with identical minute interval, start and end time.

    Here I notices, that although the general trend looks – let's say – similar, there is an error. Open, close, low and high are different for each k-line value. I would guess, that this may result from the "speed" of the live data extraction method. There are still not enough data. At least, this clustering of data may cause this error.

    First of all, I would be interested if you also have seen the problem and, ideally, if you have any idea to solve this issue.

    Thanks in advance! Keep on doing this great work.


  8. Can we do something here like buying currency pairs with 4 and 1 hour and 15 minute RSI values below 30 or 35 instead of the minute best values? We can add a possible 3-5 percent drop. Is it possible to write such a bot?

    By the way, thank you for everything. You use a very descriptive and easy-to-understand style, I wish you continued success.

  9. if _name_ == "__main__":

    loop = asyncio.get_event_loop()


    RuntimeError: This event loop is already running

    do you have any idea about the error ?

  10. As a general rule, stop loss should be less than the take profit otherwise you are relying on only your strategy win rate. If you have a 2 to 1 take profit to stop loss you will get positive results even at a 50% strategy win rate. Not only that you really shouldn't take profit if the price is continuing up, you should move your stop loss up with the increasing price and wait for a reversal. I didn't see anything about looking at the cost of the trade which would be max 0.1% on Binance.

  11. Brilliant once more. Thank you.

    It would be interesting to thoroughly test the RSI, stoic, MACD, but adding the EMA 200 to make it more fail proof.
    I have also read about the MTF EMA, where one line is 15 minutes 50, the second line is 60 minutes 50 being a good indicator too.
    Some times, the EMA 200 and EMA 50 act as point of resistance/support, which could actually work as an advantage of predictability.
    Also I have noticed that using the top_symbol is not the most valuable asset. Once it becomes the top, it's because It has gone through the burning period and it has, most of the time little to offer.
    I am currently observing for signs of a better way of selecting a coin.

    If I could code python, this would be my project to perfect.

    Looking forward to your next video.

  12. that minimum lot size explanation makes not sense. if the minimum is 0.01 then 0.198 is well above that and there is no need to round it. If the investment size was 0.009 there would be a problem… am I missing something here?

  13. import math

    from decimal import Decimal
    buy_quantity = float(math.floor(investment_amt/(prize*Lotsize))*Decimal(str(Lotsize)))

    math.floor(investment_amt/(prize*Lotsize)): Integer number that is possible to buy
    Decimal(str(Lotsize)): Precision number of lotsize

  14. Another nice video! But when you put trading script in crontab you have to remove the run_until_complete loop or you will have a new script every second and they all run together. Right?

  15. Hi Mr.
    I get such an error when I try to run the code, where do you think the problem could be? after this line :

    rets = []

    for symbol in symbols:

    prices = qry(symbol,3).Price

    cumret = (prices.pct_change() +1).prod() -1


    Error Code is :

    OperationalError: no such table: name

    The above exception was the direct cause of the following exception:

    OperationalError Traceback (most recent call last)

    <ipython-input-6-58a45d7b15db> in <module>

    1 rets = []

    2 for symbol in symbols:

    —-> 3 prices = qry(symbol,3).Price

    4 cumret = (prices.pct_change() +1).prod() -1

    5 rets.append(cumret)
    <ipython-input-5-5e5d598e4a15> in qry(symbol, lookback)

    4 before = now – dt.timedelta(minutes=lookback)

    5 qry_str = f"""SELECT * FROM '{symbol}' WHERE TIME >= '{before}'"""

    —-> 6 return pd.read_sql(qry_str,engine)

    OperationalError: (sqlite3.OperationalError) no such table: name

    [SQL: SELECT * FROM 'name' WHERE TIME >= '2021-11-15 23:29:53.029782']

    (Background on this error at:

    I would be very happy if you can help 🙂 Many thanks

Leave a Reply

Your email address will not be published.