A Binance and Gate.io crypto trading bot for new coin announcements

If you’ve been following my blog, you probably know that for the past couple of months I’ve been working on an open source crypto trading algorithm that can detect and instantly place trades on Binance new coin listings. The main issue has been speed of execution, or more specifically how long it takes the algorithm to detect a new listing on Binance and place a buy order. So I have decided to remove the speed variable entirely, by going about it a different way – and it involves the Gate.io API.

You can check out the video here or follow along with the article below: 

Before we jump into it, I’m excited to announce that I’m working on an NFT project on the Solana blockchain! Join the Discord here to find out more if you’re into this kind of thing.

Quick breakdown on the Binance new coins trading bot

Before I go explaining the new crypto trading bot that I’ve built. here’s a quick rundown on how this project has evolved:

  • Iteration 1: trading bot can detect new coins on Binance and place trades within 20 seconds
  • Iteration 2: trading bot can detect new coins on Binance and place trades within 5 seconds
  • ….
  • Iteration 4: trading bot can now place trades within 0.1 seconds of a new coin being listed on Binance
  • Iteration 5: trading bot now places sell orders instead of buy orders within 0.1 seconds

Out of all the strategies tested above, Iteration 5 seemed to have the most potential. The trading bot would usually buy at the local peak upon listing (see img below) so in theory it makes sense to place sell orders instead.

polyusdt initial coin listing Binance

Though this proved to be more difficult to transition from a test environment to a live one. The main reason behind this limitation is that Binance doesn’t list new coins for Margin and Futures trading, which means that you can’t borrow the coin in order to short it. Most new coins on Binance will only be available for SPOT trading in the very beginning, so the only way to sell the coin is to….you guessed it….own it!

Assuming you can pre-own the coin on a different exchange it’s not unreasonable to think that you could indeed short it at its peak. So in an attempt to make this strategy work, I built a crypto trading bot that sends notifications on new Binance listings. Essentially this tool will send you an e-mail notification to let you know that Binance will list a new coin soon, giving you some time to buy it on a different exchange – manually. 

I tested the above strategy for a while, but as I’m not a fan of manual work, I had to come up with a way to do this efficiently and automatically. Enter Gate.io – yet another Chinese crypto exchange, one of the very first ones actually.

After speaking with a few of you on Reddit and on here, as well as doing a bit of first hand research myself, it turns out that Gate.io seems to be a bit more relaxed with the coins they list, meaning that many of the coins that Binance WILL list, are already listed on Gate.io. See where I’m going with this?

Using Gate.io and Binance to automate our crypto trading bot

We know that new coins spike in price when they get listed on Binance, but do they spike in price when they get announced for listings? Well they do!

fida usdt Binance annoucement

This is the FIDA/USDT chart on CoinMarketCap. That huge increase coincides perfectly with when Binance made the announcement that they will list FIDA: 

This means many people started speculating and buying up FIDA on different exchanged in anticipation for a Binance pump upon listing, and inadvertently created a pump of themselves in the process.

Ok so we know this works, all we need to do know is create a cryptocurrency trading algorithm that scans the Binance Annoucements page, and once a new coin announcement is detected, it places a Buy order on Gate.io – Should be easy enough. 

I won’t go into the details of how each line of code works in this article, so make sure to subscribe to my mailing list, so you don’t miss out on the step by step guide next week. But I will go over the configuration options and how make this work on your machine.

Gate.io crypto trading bot prerequisites:

  • A gate.io account (duh)
  • Python 3.8+
  • A Raspberry Pi / VPS/ or being ok with your Laptop or PC running 24/7
  • Some knowledge of Python (highly recommended)
  • Basic git skills

Getting the gate.io bot set up

Head over to GitHub and clone the repo:

Alternatively you can just manually download it:

Next you will need to head over to gate.io and create an account (you may need to KYC) and generate some API keys by navigating to your account tab.

gateioapi

Take note of the API key and secret, and give them permissions to read and write SPOT trades – feel free to restrict them to your own IP address for extra security.

Now open cmd/ terminal and navigate to the directory of your bot. You will need to install the requirements in requirements.txt using pip:

Now, inside your gateio trading bot directory, open the auth/auth.example.yml file and paste in your API key and Secret. Save the file as auth.yml (remove .example).

Now open config.example.yml and adjust the configuration options to suit your needs:

QUANTITY – the amount for each trade in PAIRING

PAIRING – the quoted currency of choice

TEST – enable/disable test mode. Setting this to False will use live funds to be particularly careful here and only enable at your own risk.

SL, TP – the initial stop loss an take profit values

ENABLE_TSL – enable trailing stop loss and profit functions

TSL – the trailing stop value

TTP – the trailing profit value

Save the file as config.yml

 

Now simply run the script using main.py and you’re all set.

Did you enjoy this article? Here’s what to do next:

Consider donating at the widget next to the top of the page or via the brave browser. Your donations help keep this content free and open source.
If  you’re looking for a custom-built cryptocurrency trading algorithm, shoot me a message and let’s talk
Subscribe to the newsletter for more awesome content!

57 thoughts on “A Binance and Gate.io crypto trading bot for new coin announcements

  1. Great bot! Just skimmed through the code. Any thoughts on adding another “history file” in the repository that holds the buys and sells? Seems like a better way to see how the boys working in test mode.

  2. I need help building a revolutionary online gambling platform. Decentralized way.

    There are two ways for businesses to thrive. 1 help people save money 2 help people make money. My idea does both.

    Email me back please

  3. hi
    not sure I understand. You buy the coin on gate.io (so you’ll need some USDT ther) and then sell on binance ?
    thanks

  4. Hi and thank you very much for the interesting project!

    I followed your instructions but when I run the main.py script I get this error:
    File “”, line 1
    (last_price=)
    ^
    SyntaxError: invalid syntax

    I’m working on RHEL 8.4, do you have any idea what I’m doing wrong?

    Thanks

      1. I had that problem runnin on ubuntu 18 on a vps serv, i had to remove = from the logger.info lines, i believe is some kind of doble quotes issue

  5. I am very much interested in your gate.io solution, Andrei, and will definitely give it a shot. I’ve been trying the same on gate.io manually over the past month, but I am always too late to place a buy order. Today CHESS listing was announced on Binance and the price immediately spiked from 2.7 to 10 USDT within a couple of minutes if not seconds, so I‘m wondering if this occurred because of bots similar to your’s or very quick humans. I am not as quick though subscribed to coin listing alerts that wake me up at night. My goal is to always get a good night sleep and let a bot make the buy order for me. I promise to donate, if your solution works out 🙂

    1. If you buy it why dont u get the order on gate.io it takes so long to get an order, Can you explain me why?

  6. Doesn’t binance announce that they have added a new listing at the same time they list it? How does placing the order on gate.io differ from placing it on binance?

  7. Hi and thank you very much for the interesting project!

    I followed your instructions but when I run the main.py script I get this error:

    File “”, line 1
    (last_price=)
    ^
    SyntaxError: invalid syntax

    can you help me please

  8. {noformat}

    pi@raspberrypi:~/gateio-crypto-trading-bot-binance-announcements-new-coins $ ./main.py
    from: can’t read /var/mail/trade_client
    from: can’t read /var/mail/store_order
    from: can’t read /var/mail/logger
    from: can’t read /var/mail/load_config
    from: can’t read /var/mail/new_listings_scraper
    from: can’t read /var/mail/collections
    from: can’t read /var/mail/datetime
    ./main.py: line 9: import: command not found
    ./main.py: line 10: import: command not found
    ./main.py: line 12: import: command not found
    ./main.py: line 13: import: command not found
    ./main.py: line 15: old_coins: command not found
    ./main.py: line 18: syntax error near unexpected token `(‘
    ./main.py: line 18: `config = load_config(‘config.yml’)’

    {noformat}

  9. Perfect !!
    I studied every line of code, your code worked fine, let’s see how it works in true mode, I’m making some adjustments from my perspective.

    Thanks

  10. Thanks for sharing this.
    I’m not a programmer so I’m not 100% sure what I’m looking at. From what I can understand it looks like an orders.json will get created if an order is placed? I’m assuming that’s even a test order?
    I’ve been running this in the mornings for a few hours the last 4 days. I’m not seeing that it’s found anything, but I’m also not sure what to look for to tell that it’s done anything.

    Is there any logging that I can see it’s actually hitting the locations it is supposed to? I can see the script running in Git, but I don’t know if it is successfully doing anything.
    Thanks!

    1. Thanks for the sahre! Can this code be applied in other platforms? Kukoin/Coinbase? ( Obviously with the relevant api’s)

  11. The errors above looks like old Python versions. Try to run python -V and verify it is minimum 3.8.

    In the config example the SL and TSL is negative, but in above it is positive.

  12. Very appreciated the idea and sharing this with everyone. I am not very familiar with the Python or coding. I assume I have followed every step you told. But I am not able to see anything as I try to run main.py . What would be the problem?

    Thank you very much for this informative guide and super bot!

      1. I managed to do it by installing yaml, gate-api, requests. In test version it is controlling if any coin listed or not every minute. I think It is working now. Many thanks!

  13. Just nothing. A black window appears just in a second it’s gone. Nothing happens. I tried to run it by cmd.exe, it responds as “ModuleNotFoundError: No module named ‘yaml'”.

    1. Make sure all modules are installed via pip. Specifically for YAML try;

      Pip install pyyaml

      On your Python command line.

  14. announcement_coin=False is not supported on gate io

    Is this ok? it displays immediately after
    New announcement detected: False
    every time

    1. 2021-11-04 14:52:13,920 INFO: New annoucement detected: False
      2021-11-04 14:52:13,921 WARNING: announcement_coin=False is not supported on gate io
      2021-11-04 14:52:14,169 INFO: Checking for coin announcements every 1 minute (in a separate thread)
      2021-11-04 14:52:16,925 INFO: New annoucement detected: False
      2021-11-04 14:52:16,927 WARNING: announcement_coin=False is not supported on gate io
      2021-11-04 14:52:17,506 INFO: Checking for coin announcements every 1 minute (in a separate thread)

  15. Is this ok?

    2021-11-04 14:52:13,920 INFO: New annoucement detected: False
    2021-11-04 14:52:13,921 WARNING: announcement_coin=False is not supported on gate io
    2021-11-04 14:52:14,169 INFO: Checking for coin announcements every 1 minute (in a separate thread)
    2021-11-04 14:52:16,925 INFO: New annoucement detected: False
    2021-11-04 14:52:16,927 WARNING: announcement_coin=False is not supported on gate io
    2021-11-04 14:52:17,506 INFO: Checking for coin announcements every 1 minute (in a separate thread)

  16. Have you sent out the line by line guide yet? I’m able to get the bot running on my computer but would like to be able to figure out what each line in these files is doing.

  17. gate.io gives you a fake price of the new coin at the moment of listing announcement which causes a great loss coz u get to buy the new coin at a fake high price and then it dumps…plz get back to me to work on this trouble there could be a better solution making a bot on uniswap??

  18. I had it running for two announcements now in real mode with one + and one -, but information must leak somewhere else as the announcement seems to be to later.

    With BNX my bot got in at 252. 1 minute before it was at 105. Forutunately in continued to raise to 378 and my bot sold at trailing stop loss at 351.

    With RGT my bot registered new coin at 2:09:51. At 2:09:00 it was at 44 but my purchase came 2:09:55 at 90 so most fun was over. It raised to 98 but not enough to tricker my trailing SL and it tried to sell at SL at 86, but the selling alg did not take a fee into the calculation so the sell was rejected and when i fixed the code for that my bot sold at 50% loss back at 44.

    I have made 2 adjustments now – one to fix traling SL which did not update and one to include fee if it apply in the traiding currency.

    I will let it run for a few more announcings as it look stable, but risk is when the limit sale order is placed it is to late and if it just drop from there the sell order will never be executed.

    My PL is now exactly 0.

    1. Indeed, the information leaked beyond binance announcement. better to do shorts 30 minutes in advance binance listing the coin.

  19. I think that when selling, one should amout minus the rate divided by last_price, otherwise it will lead to failure to sell,And
    Please tell me how to find the bapi/composite/v1/public/cms/article/catalog/list/query, Thanks!!!

  20. The TSL issue is fixed in the most resent code. In main.py the error was:
    stored_price * sl / 100) or float(last_price) > stored_price + (
    which should be and is now corrected to:
    stored_price * coin_sl / 100) or float(last_price) > stored_price + (

    To overcome the fee issue I have added a check on how much is on the coin in the wallet. Around line 80 in main.py – after symbol = order[coin][‘_fee_currency’]

    # Check funds are correct

    spot_fund = get_available_spot(coin)
    logger.info(f'{spot_fund=}’)
    if volume > float(spot_fund) and float(spot_fund) > 0 :
    logger.info(f’Adjusting volume to: {spot_fund}’)
    volume=float(spot_fund)

    And I have then added to the bottom of trade_client.py:
    def get_available_spot(currency):
    “””
    Args:
    ‘MOVR’
    “””
    try:
    api_response = spot_api.list_spot_accounts(currency=currency)
    except Exception as e:
    logger.error(e)
    raise

    else:
    return api_response[0].available

  21. It looks like gate.io is not able to be used by WA residents. Is there another exchange that you all know of that would have these tokens that’s legal here?

  22. First of all, thank you for sharing your work.
    However its not working for me.
    When I start main.py I get the following:

    Traceback (most recent call last):
    File “/home/pi/gateio-crypto-trading-bot-binance-announcements-new-coins/main.py”, line 1, in
    from trade_client import *
    File “/home/pi/gateio-crypto-trading-bot-binance-announcements-new-coins/trade_client.py”, line 2, in
    from logger import logger
    File “/home/pi/gateio-crypto-trading-bot-binance-announcements-new-coins/logger.py”, line 3, in
    from load_config import *
    File “/home/pi/gateio-crypto-trading-bot-binance-announcements-new-coins/load_config.py”, line 2, in
    import yaml
    ModuleNotFoundError: No module named ‘yaml’

    Does anyone had this problem befor?

  23. Hello, thanks for the great work!

    I’m trying to get the bot work but keep having an error.
    Can someone help me ?

    This is the error :

    \…\….\load_config.py”, line 4, in load_config
    with open(file) as file:
    FileNotFoundError: [Errno 2] No such file or directory: ‘config.yml’

    My main.py don’t seem to find the directory for the yaml files I don’t understand why..

  24. Hi all,

    Amazing work, by the way, have done an amazing job so far on this!

    I noticed that there is a piece of regex in the code, new_listings.py file. If the regex doesn’t match (ie. if there is not a listing with (XXX) – XXX being the new coin, then the code will fail as found_coin is empty. This is on the first run of the script. Have found a workaround if people have ran into the same issue.

    This issue wouldn’t exist if the newest announcements meets the regex in question (ie. Binance Will List Highstreet (HIGH)). This on the other hand: Binance Futures Will List USDⓈ-M BTC & ETH Quarterly 0325 Futures Contracts; will cause a failiure.

    Thanks!

    Jack

  25. Got some errors on the SSL Version, any clues from you guys?
    ‘[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1131)

    1. This issue seems to be isolated to Raspberry Pi. While there is no known fix at the moment, running it from a different device will fix this issue.

  26. Upon running I am getting an error:
    Traceback (most recent call last):
    File “…/src/main.py”, line 1, in
    from trade_client import *
    File “…/src/trade_client.py”, line 4, in
    from auth.gateio_auth import *
    File “…/src/auth/gateio_auth.py”, line 2, in
    from gate_api import ApiClient, Configuration, Order, SpotApi
    ModuleNotFoundError: No module named ‘gate_api’

    I have run the pip3 install -r requirements.txt command and the right version of gate_api is installed.

    Any solution to get rid of this error?

  27. Hi!

    Is this bot still working? I get “Error pulling binance annoucement page 400” notice every time I run the script? Kucoin works fine.

Leave a Reply

Your email address will not be published. Required fields are marked *