Crypto signal trading bot

Crypto-signal-trading-bot

Firstly a warning

This project has the ability to spend real money so please ensure you read through the code and understand how it works before committing to running it. We cannot be held responsible for any losses incurred because of its use.

Rationale

As part of our research for creating moonr.app, we wanted to understand just how hard it is to try and time the market when buying cryptocurrencies and how for most people this is not the right strategy. After making a bit of money & losing a lot of money, those lessons have definitely been learned.

If you find this project interesting, please head over to MoonR and enter your details to get regular updates as we get ready to launch.

What Exactly is this project?

This bot was inspired by this python project. However, this is a pure go implementation written from the ground up and with some extra features.

Once deployed, this bot scrapes Coinbase's API and Binance's coin announcement blog on a specified interval to look for newly listed coins. Once it finds a new coin, the bot will make a purchase on gate.io (if you don't have an account please sign up using this link to support this project. You will also get a discount on fees). The goal is to make the purchase at as close to the announcement time as possible. The bot will then check the price of the coin on gate.io at a specified interval, and sell the coins if it goes above a specified threshold.

There is currently no implementation of a stop loss, so you'll need to step in and manually sell the coins if you do not buy at the right time or it never reaches your threshold.

Getting started

To get Started you'll need:

  • A gate.io account
  • An AWS account. If you do everything right, this whole project can be run on the free tier.
  • Some knowledge of AWS/Go. However, we have tried to explain everything in as much detail as possible.

Project Structure

The main binaries in this project are all housed in cmd. These are:

  • coinbasescratch: This is a test project for testing the integration with coinbase. Its meant to be a playground for you to get comfortable with the coinbase integration in isolation.
  • dbscratch: Same as above but for testing integration with Dynamo.
  • gateioscratch: Same as above but for gate.io. Note if it doesn't run in test mode, it really will buy and sell coins.
  • tradebot: This is the real app binary for the trade bot.

Deploying

Two Warnings Before You Start:

  • The amount to buy is specified in the env var USDT_TO_SPEND. If you don't have enough money in your gate.io account, the bot will fail to buy.
  • If you have a clean DB and the last post on binance happens to be a new listing, the bot will buy the coins. We recommend deploying it in test mode the first time you run it to protect against that.

Database

The bot is currently setup to work with Dynamo DB. It uses Dynamo to track the status of the coins it has and has not purchased. To setup a Dynamo DB and learn more about it, you can follow instructions here.

We recommend creating the DB in the region you intend to deploy the bot in. We did some benchmark tests of where we found the best place to run the bot, you can see them here. However, the TLDR is Seoul or Singapore is a good bet.

Once you have created a dynamoDB, create a table called coin_history. If for whatever reason you don't want to call it coin_history, you'll need to edit internal/persistence/dynamodb.go.

gate.io

After that, you need to get API Keys from gate.io. You can find instruction on how to do that here.

Telegram

This bot has the ability to write to telegram each time it buys and sells. To do this you need to simply update the telegram config in internal/notifier/telegram.go. You can find more about writing to telegram here.

Rest of Env Vars

Next, create an env file based on .env.example and fill in the values. Comments below for what each env does

SELL_THRESHOLD_PERCENTAGE= #what percentage increase to sell at. 20 would sell at a 20% increase.
GATE_API_KEY= #obvious
GATE_API_SECRET= #obvious
DISABLE_TELEGRAM=false #if true, the bot won't write to the telegram channel when it buys and sells
ENABLE_TEST_MODE=false # if true, the bot won't actually buy or sell. Will still write to the db as if it did
DYNAMO_ID= #you get this from AWS
DYNAMO_SECRET= #you get this from AWS
DYNAMO_REGION=eu-west-2 #must be correct for where you created your dynamo db. I reccomend putting this in the same region you intend to deploy bot.
BUY_INTERVAL_SECONDS=1 #interval to check whether to buy (in seconds)
SEll_INTERVAL_SECONDS=1 #interval to check whether to sell (in seconds)
BOT_OWNER= #your name
USDT_TO_SPEND= #amount you want to spend each run per coin.
TICKER_CACHE_INTERVAL_SECONDS=#of seconds to cache prices.

EC2

Create an EC2 instance in the AWS console. We don't need anything beefy so whatever is within the free tier is fine. We recommend creating it in the same region as your dynamo DB.

We used Amazon Linux 2 AMI. Once your instance is created, ssh into it.

Once you are sshed, run

sudo yum update -y

then:

sudo amazon-linux-extras install docker

then:

 sudo service docker start

then:

 sudo usermod -a -G docker ec2-user

then:

logout 

ssh back into your terminal (you have to logout for docker change to take effect).

then:

sudo yum install git-all

We now have git and docker installed. Add your ssh-keys to your instance so that you have the right to pull from the git repo.

clone the repo:

git clone [email protected]:moonr-app/crypto-signal-trading-bot.git

copy your env file onto the server. Now run:

 docker build . -t crypto-trade-bot:01-31-2022

and run it in detached mode:

docker run -d -t  --env-file=.env crypto-trade-bot:01-31-2022

to "deploy" a new version, kill the docker container and run the last 2 commands again.

Configuring Cloudwatch Logs:

The following IAM role will need to be added to EC2 instance:

(EC2 Instance dashboard -> Actions -> Security -> Modify IAM Role)

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "logs:CreateLogStream",
                "logs:PutLogEvents",
                "logs:CreateLogGroup"
            ],
            "Effect": "Allow",
            "Resource": "*"
        }
    ]
}

To run docker image and export logs to cloudwatch run:

docker run -it --log-driver=awslogs --log-opt awslogs-region=ap-northeast-1  --log-opt awslogs-group=cryptoBotGroup --log-opt awslogs-create-group=true -d -t --env-file=.env crypto-trade-bot:01-31-2022

(replace ap-northeast-1 with relevant region)

This will create a log group called cryptoBotGroup in the same region.

Similar Resources

Tripwire is trading platform interface

Tripwire A Golang SDK for binance API. All the REST APIs listed in binance API document are implemented, as well as the websocket APIs. For best compa

Nov 28, 2021

A trading robot, that can submit basic orders in an automated fashion.

A trading robot, that can submit basic orders in an automated fashion.

Source: https://github.com/harunnryd/btrade Issues: https://github.com/harunnryd/btrade/issues Twitter: @harunnryd LinkedIn: @harunnryd btrade is a ro

Jan 26, 2022

Buy crypto low/Sell high on Binance. Simple, powerful configuration, trade multiple assets simultaneously, single binary deployment with no external dependencies!

bnc-trading-bot Download the latest release for your OS This bot automatically trades crypto / fiat assets on Binance.com according to simple, configu

Dec 14, 2022

A bot based on Telegram Bot API written in Golang allows users to download public Instagram photos, videos, and albums without receiving the user's credentials.

InstagramRobot InstagramRobot is a bot based on Telegram Bot API written in Golang that allows users to download public Instagram photos, videos, and

Dec 16, 2021

Dlercloud-telegram-bot - A Telegram bot for managing your Dler Cloud account

Dler Cloud Telegram Bot A Telegram bot for managing your Dler Cloud account. Usa

Dec 30, 2021

Quote-bot - Un bot utilisant l'API Twitter pour tweeter une citation par jour sur la programmation et les mathématiques.

Description Ceci est un simple bot programmé en Golang qui tweet une citation sur la programmation tout les jours. Ce bot est host sur le compte Twitt

Jan 1, 2022

Discord-bot - A Discord bot with golang

JS discord bots Install Clone repo git clone https://github.com/fu-js/discord-bo

Aug 2, 2022

Bot - Telegram Music Bot in Go

Telegram Music Bot in Go An example bot using gotgcalls. Setup Install the serve

Jun 28, 2022

Pro-bot - A telegram bot to play around with the community telegram channels

pro-bot 🤖 Pro Bot A Telegram Bot to Play Around With The Community Telegram Cha

Jan 24, 2022
Kelp is a free and open-source trading bot for the Stellar DEX and 100+ centralized exchanges
Kelp is a free and open-source trading bot for the Stellar DEX and 100+ centralized exchanges

Kelp Kelp is a free and open-source trading bot for the Stellar universal marketplace and for centralized exchanges such as Binance, Kraken, CoinbaseP

Jan 6, 2023
The modern cryptocurrency trading bot written in Go.

bbgo A trading bot framework written in Go. The name bbgo comes from the BB8 bot in the Star Wars movie. aka Buy BitCoin Go! Current Status Features E

Jan 2, 2023
A fast cryptocurrency trading bot implemented in Go
A fast cryptocurrency trading bot implemented in Go

A fast cryptocurrency bot framework implemented in Go. Ninjabot permits users to create and test custom strategies for spot markets. ⚠️ Caution: Worki

Jan 1, 2023
BlueBot is an open-source trading bot that can be customized to handle specific investment strategies.

BlueBot Quick Note BlueBot and all mentioned services are free to use, including supported financial APIs. Overview BlueBot is a self-healing trading

Sep 7, 2022
CryptoPump is a cryptocurrency trading bot that focuses on high speed and flexibility
CryptoPump is a cryptocurrency trading bot that focuses on high speed and flexibility

CryptoPump is a cryptocurrency trading bot that focuses on high speed and flexibility. The algorithms utilize Go Language and WebSockets to react in real-time to market movements based on Bollinger statistical analysis and pre-defined profit margins.

Nov 24, 2022
A golang implementation of a console-based trading bot for cryptocurrency exchanges
A golang implementation of a console-based trading bot for cryptocurrency exchanges

Golang Crypto Trading Bot A golang implementation of a console-based trading bot for cryptocurrency exchanges. Usage Download a release or directly bu

Jun 4, 2022
This bot keeps information about your crypto wallet.

Telegram bot @crypto_wallet_gobot This bot writes to database information about your cryptocurrencies. Functions: add currency(example: btc) amount(ex

Jan 12, 2022
Crypto Telegram Bot For Golang

BITCOIN-TELEGRAM-BOT Table of Contents Getting Started What you will need Installation Add BTB to your Telegram Channel Usage Getting started What you

Jun 6, 2022
Bot-template - A simple bot template for creating a bot which includes a config, postgresql database

bot-template This is a simple bot template for creating a bot which includes a c

Sep 9, 2022
Automated Trader (at). Framework for building trading bots.
Automated Trader (at). Framework for building trading bots.

Automated Trader (at) Purpose: Framework for building automated trading strategies in three steps: Build your own strategy. Verify it with the backtes

Dec 14, 2022