Skip to content

AlexBabescu/freqtrade_3commas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Freqtrade 3commas wrapper

The aim of this project is to provide an easy way to integrate freqtrade with 3commas. The main reason someone would want to do this is to use the auto DCA feature that 3commas provides and unfortunately freqtrade lacks.

DCA can be risky, especially if used on bad/shit/meme coins, so please use responsibly.

Setup in 3commas

Make a 3commas account and bot

First, you'll need to create a 3commas account and connect 3commas to your exchange. Then create a multi-pair long bot with the pairs you want to trade. Here you could actually select all pairs (eg. USDT_ALL) and make the more exact pair selection in freqtrade. Note, if you're going to use VolumePairList, you will need to select all the pairs in 3commas.

create a multi-pair long bot

Next set the Deal start condition to Manual/API

After electing the pairs, set your order amounts, safety orders and take profit settings. There are plenty of YouTube tutorials explaining what these are.

Once you're happy with the settings click Create bot

We will also need to write down the bot_id, this can be found in the API example or URL when looking at the bot.

get the bot id

Now we can start the bot. Since the bot is set to Manual, it won't make any trades.

3commas API

In order to control the 3commas bot with freqtrade we'll need an API key and secret.

You can get these by going to https://3commas.io/api_access_tokens and creating a new API key with BotsRead and BotsWrite

Save the key and secret, we'll need them later.

Freqtrade setup

Freqtrade has excellent documentation available at https://www.freqtrade.io/en/stable/

Follow the tutorial to get started.

Add 3commas credential to config.json

Once you've created a freqtrade configuration, you should have a file called config.json Open it in your favorite editor and add the following in the json root:

"3commas": {
	"key": "3commas_key_goes_here",
	"secret": "3commas_secret_goes_here",
	"bot_ids": [
		123456
	]
},

Fill that with the 3commas credentials and bot_id from the previous steps and your config.json should look something like this:

3commas json config

Add the wrapper

Now you'll need to download the 3commas wrapper in the user_data directory

wget https://raw.githubusercontent.com/AlexBabescu/freqtrade_3commas/master/user_data/freqtrade3cw.py

The wrapper depends on the py3cw package. You will need to install it with:

pip install py3cw

If you are a Docker user, please refer to the freqtrade documentation on how to add additional packages in the freqtrade container - https://www.freqtrade.io/en/stable/docker_quickstart/#additional-dependencies-with-docker-compose

Using the wrapper in a strategy

All you need is to import Freqtrade3cw into your strategy and decorate the populate_buy_trend method.

....
from user_data.freqtrade3cw import Freqtrade3cw

class SampleStrategy(IStrategy):
	....

	@Freqtrade3cw.buy_signal
	def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
		....

Starting freqtrade

Freqtrade should be configured to run in dry-mode on the same exchange as your 3commas bot. If you are going to use VolumePairList then you must set your 3commas bot to use all the pairs.

Limitations and future work

Currently this only supports sending buy signals.

TODO:

  • send sell signals
  • turn this into a python package

If you have any questions you can find me on discord at alb#1349

Have fun!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages