It’s been more than a year since my first post on my journey to create a passive income source that generates a 1% daily return. After spending months testing various bot settings and trigger conditions, I’ve finally achieved a system that is truly hands-off, profitable, automatic trading. I promised to document it on this site, so here it is. Free for you to use.
To be totally transparent, when I say 3,000%, this is APY, which is about a 365% APR, or 1% per day. I know the title is a bit clickbait-ish, but it got your attention, right?
Over the past year and a bit I’ve been struggling to come up with a system that is truly passive. Of course, it doesn’t exist, you always need to be checking and adjusting your bots’ parameters for maximum returns. This system gets as close as you can to being completely passive, with only a few minor adjustments every few weeks. And seriously, as I’m typing this post my Telegram notifications keep going off, letting me know deals are closing constantly. It’s incredible, and a constant reminder the system is working.
So, What Are The Best 3Commas Bot Settings to Use?
The reality is it’s much less about the bot parameters. The most important part is the trigger. Most bot settings will work if you have the right triggers to start a deal. Having said that, I do have some preferred settings I like to use, but these depend on whether the market is ranging (going sideways), or trending (up or down). I will cover these in some later posts, and this post will give you some initial settings to work with. If you don’t want to miss those upcoming posts, make sure you’ve signed up to receive new post notifications to your email if you’re not already.
For the system to work we need a few things first. An FTX.com account. FTX is by far the best exchange in my opinion. Great liquidity, an amazing team, and some of the fairest trading I’ve seen. For example, if you trade leverage, you don’t get instantly liquidated if the price exceeds your margin. Binance and others will instantly just take all your money and leave you broke. FTX will slowly sell off part of your bags to cover your margin, so if your position improves, you’re left with some money to keep trading. Anyways, I digress.
You’re also going to need a Pro plan at 3Commas.io. This system uses two bots per trading pair. One for longs, and one for shorts. You can only run this many on the Pro plan.
Next, you’re going to need Python installed on your machine to run the code. Most computers already have Python installed, so I’m not going to cover how to install it, or anything related to the use of Python. I learned Python through google, so can you. To get up and running fast though, you can download and install the Python IDLE (Integrated Development and Learning Environment) software to make getting started a bit easier.
How The Bot Trading System Works
I had initially come up with a system where I would look for coins or tokens that were breaking out of the pack, and try to start a deal to catch the momentum. The bot would only open and close one deal. I used a comparison chart like this to look for those:
However, this meant I would have to sit and watch the chart all day, all night. Impossible when you have a full-time job and a family. So I sought out a way to automate this. Thanks to the magic of Python and API’s, it’s totally possible.
So, here’s the details.
First we need to connect 3Commas to FTX. This post describes how to make the API connection from 3Commas to FTX. You’ll also need to grab a separate set of keys from both FTX and 3Commas for the python script. That’s pretty straightforward stuff, so google it if you don’t know how.
Next we need to setup all our bots in 3Commas. We’re trading perpetual futures on FTX, and there’s like 140 or so odd perps we can trade. Since we’re going long and short, we need roughly 280 bots setup. Yikes! But no worries, the first python script helps you create the bots. The second then activates all the bots. For some reason you can’t (or I haven’t figured it out yet) create a bot via the API and have it enabled at the same time, so this requires two actions.
Lastly, we’ll run the python script which keeps an eye out on the prices and looks for those tokens or coins that are making a run or tanking, and then tells the correct bot to start a new deal. The bot will take care of the rest, ie managing the safety orders, take-profit, etc. The script will close a deal if it’s gone too far in the red, but you can adjust that parameter, or use a stop loss on the bot, as you wish.
Let’s jump into the techie bits.
Setting Up the Python Script to Automatically Trigger your 3Commas bots
The code is all stored here, and you’re free to use it and modify it as you want. You can click on the green Code button, then on Download ZIP to download a copy on your machine. Unzip the files and keep them in all the same folder.
Setup config.py
Rename the example.config.py
to config.py
. Open the file to edit it. You can use whatever text editor you normally code with, or use the Python IDLE software. The first few lines are where you’ll enter your API keys and sub-account names. The first three are for 3Commas, and the second is for FTX. Paste the keys between the single quotes, and add the sub-account names the same way.

The next few lines determines when the script triggers and closes deals or switches positions.
PAIRS_BLACKLIST
– Add any perps you don’t want bots for. Some of the ones listed already have very low volume and don’t trade well, and for some reasonPERP/USD
gets caught in my filter, so it’s here to make sure we don’t try to call it since it’s not a perp. Add as many as you want, following the same format already in the file.LTF_DELAY
andLTF_INTERVALS
– These work together to determine the time frame you want to look at.LTF_DELAY
sets the time period between checking for the latest prices. The default here is 60 seconds.LTF_INTERVALS
is the number of prices to grab to compare the percentage increase or decrease of a token or coin. The default values are equal to a 5-minute comparison. That’s 60 seconds times 5 = 300 seconds, or 5 minutes. In other words, every 60 seconds we’re going to compare the current price to what it was 300 seconds ago. You can go as long as you want here. I’ve run scripts that check every 10 minutes on a 3-hour window (ie interval of 18).LTF_BULL_CHANGE
andLTF_BEAR_CHANGE
– These are percent values we’re looking to exceed to cause a trigger. The default settings are 2.0% for long bots, and -2.0% for short bots. So, if a token or coin has risen in price (or decreased in price) by this amount in 300 seconds (from the calculation above), the long (or short) bot will be triggered to start a new deal.MAX_OPEN_POSITIONS
– This tells the script the maximum number of deals to run at the same time. The bot will automatically calculate how many deals you can run in parallel based on the funds in your account times the usage of each bot.ORDER_VALUE
,TAKE_PROFIT
, andSTOP_LOSS
– These are not used by the script and will be removed in a future revision.FUNDS_USAGE
– This tells the bot how much of the funds you want to use in your account for the bots. 0.9 will mean 90% of the funds will be used for making deals. Depending on the way you want to play, you might need some funds for rescuing a losing deal.SWITCH_PERCENT
– This is the percentage at which the bot will either close a losing deal or switch it to a short (or long) bot. It’s like a stop loss. You can either jack this up to high value so it doesn’t kick in and use the stop loss from the bot, or not. Your choice. Just remember to make it lower than your last safety order so you don’t prematurely close a deal that might still have a chance of turning around.TREND_STRENGTH
– This value determines if the bot will start deals going against the trend, and at what threshold. Since the bot looks at longs and shorts, it may start deals in both directions at any time, as long as it meets the change percentages in theLTF_BULL_CHANGE
andLTF_BEAR_CHANGE
settings. However, if say the market is trending up on most coins, starting a short deal on a coin or token might not be a good idea. This value helps determine the group strength of a trend. The default value of 65 means that if more than 65% of coins or tokens are trending up, the script won’t trigger any shorts. And vice versa, if 65% of coins or tokens are trending down, the script won’t trigger any longs.OPEN_POSITION_PRIORITY
– These are not used by the script and will be removed in a future revision.
The next lines in the config.py
file are used by the Py3c_create.py
script to generate the bots. These are the same as the bot settings in 3Commas you configure when setting up a bot, so they should look familiar if you’ve setup bots before.
#Create Bot Settings
BASE_ORDER_VOLUME = 10 #IN USD
TAKE_PROFIT = 1.5
SAFETY_ORDER_VOLUME = 10
MARTINGALE_VOLUME_COEFFICIENT = 1.0
MARTINGALE_STEP_COEFFICIENT = 1.5
MAX_SAFETY_ORERS = 4
ACTIVE_SAFETY_ORDERS_COUNT = 3
SAFETY_ORDER_STEP_PERCENTAGE = 0.5
LEVERAGE_CUSTOM_VALUE = 1
I’m not going to address these individually, so if you need more details, have a look through the help docs at 3Commas.
The last group of settings in the config.py
file are used by the Py3c_update.py
script to update your bot parameters. This was necessary since it’s difficult to tweak the bot settings on 280+ bots manually. There’s a few extra fields added here and is really only because the 3Commas API is a bit quirky that way. But it least it gives you a few more options, like adding a stop loss if you want it.
#Update Bot Settings
UPDATE_BASE_ORDER_VOLUME = 10 #IN USD
UPDATE_TAKE_PROFIT = 1.2
UPDATE_SAFETY_ORDER_VOLUME = 10
UPDATE_MARTINGALE_VOLUME_COEFFICIENT = 1.0
UPDATE_MARTINGALE_STEP_COEFFICIENT = 1.0
UPDATE_MAX_SAFETY_ORERS = 4
UPDATE_ACTIVE_SAFETY_ORDERS_COUNT = 3
UPDATE_SAFETY_ORDER_STEP_PERCENTAGE = 1.25
UPDATE_LEVERAGE_CUSTOM_VALUE = 1
UPDATE_STOP_LOSS_TYPE = 'stop_loss' # or stop_loss_and_disable_bot
UPDATE_STOP_LOSS_PERCENTAGE = 0
UPDATE_STOP_LOSS_TIMEOUT_ENABLED = False
UPDATE_STOP_LOSS_TIMEOUT_IN_SECONDS = 300
UPDATE_START_ORDER_TYPE = 'market'
Important: At the moment, you need to make sure the settings in both sections are identical, especially after an update. This is because the script uses settings from #Create Bot Settings
to determine the maximum number of deals it can open. If you update your bots and change the settings via #Update Bot Settings
, and not update the same parameters in #Create Bot Settings
, the script won’t be able to calculate the maximum number of deals correctly. I will fix this in a future update to the code.
Don’t forget to save your changes!
Add Dependencies
The scripts use a couple of external libraries built by some smarter people than me that makes all this possible, at least easier anyways. These include the CCXT library, and the py3cw library. You’ll encounter an error if you don’t first install these. Each of those links describes how to install them, or you can run pip install -r requirements.txt
from inside the folder with the other files. You can also find more general details on setting up/installing everything in this post in the Install Dependencies for Automated Trading Bots and How to Install and Setup Python Automated Trading Scripts sections.
Create Your 3Commas Bots
With the config.py
file and the dependencies installed, we’re ready to create our bots.
We do this with the Py3c_create.py
script. Run the script, either in the IDLE by hitting F5 on your keyboard when the file is open, or from the command line using python3 Py3c_create.py
. Note we use python 3 here, python 2 will not work.
The script will check for existing bot id files. If it’s never been run, these won’t exist and will continue to generate the bots. If the script does encounter existing bot id files, it will ask if you want to over-write them.
The script will then poll FTX and get a list of all available perps and generate a list of bots to create. It will filter out perps from the blacklist setting in the config file, and will also check the minimum order requirements for each coin or token and ignore ones that are too high for your settings. For example, if your base order or safety order values are $10, then you won’t be able to trade BTC, so the script doesn’t create a bot for BTC.
As the script runs it creates the bots on 3Commas via an API connection, and prints out its progress on the screen. It first creates all the long bots, followed by the short bots. It also generates four files, lbotid_list.txt
and sbotid_list.txt
, which contains each token/coin pair and its equivalent bot id on 3Commas. This is basically a lookup table the trigger script will use so it knows which bot id to send the new deal trigger for. The remaining two files are ignored_longs.txt
and ignored_shorts.txt
. These contain a list of pairs that bots were not generated for because of minimum order value requirements. These are not used by any scripts, they’re only there for your reference.
Enable Your 3Commas Bots for Trading
Sadly, it seems when a bot is created via the API it is by default not enabled. Enabling all the bots manually in 3Commas is not all that difficult, but since we have the list of bot id’s, we can do it via a script.
Run the Py3c_update.py
script. The script again checks for existing bot id files and will abort if none are found. Since you already created those in the previous section, you’ll be presented with three choices. Choose the Enable all bots option by typing in the number 2 and hitting enter.
The script will call up each bot and enable it, showing the progress on the screen and when it’s complete.
Start The Money Printing Machine!
If the above is setup as intended and no errors were encountered, you can run the main script using the command:
python3 Py3c_triggers.py
This script will show in the terminal window it’s running, and what it’s doing. Initially, it will spend some time collecting prices, then start sending deal start signals to your 3Commas bots. And that’s it! Sit back and watch the machine run! Occasionally the script will stop running, if the API connection is down – it happens sometimes, so just restart the script and it will continue where it left off. I’ve already configured an error catch for short downtimes and will be adding this in a future version of the script.
If you do run into errors trying to get the script to run, go through the setup again, and google your error – you’ll be surprised at how many solutions are already out there for your exact search. Lastly, drop a comment below and I’ll try to respond as soon as possible.
What’s Next?
This is really the start of this journey. There’s still a bunch of stuff to cover, like….
Will the Python Script Run When I Turn Off My Computer?
Yes, yes it will. The script will stop running when you turn off your computer, it goes to sleep, you lose your internet connection, etc, even for a moment.
For now, run the script on your computer for testing and getting the bot setup and working. It’s a great way to get familiar with editing the config file and understanding how it works.
In another post, I’ll show you how to set this up on the cloud (Virtual Machine) so it can run 24/7, and you can safely turn your PC off at night.
What 3Commas Bot Settings Should I Use?
I’ll cover this as well in a future post. For this particular bot, because we’re just chasing volatility, there’s no real best setting here. Ideally, an all-around type of setting works best, ie one with enough safety orders built in to capture the wild swings, while keeping our win rate times risk-reward high enough, and taking a moderate profit level.
I’ll also write another post on the best 3Commas bot settings to use in a trending market. I’ll add this since it will be perfect for the next python script I’m writing that will trigger based on coins or tokens that are in a trend. With this bot, we’ll want to maximize the amount our bot uses upfront to capture as much profit as possible while maintaining a smaller level of safety orders. I’ve run tests on these settings before, and they truly outperform the typical bot settings. Anyways, stay tuned for that coming up soon.
Don’t Miss What’s Coming Up Next!
Stay up to date on all the posts and how-to’s, Subscribe!
Hey Nick,
First of all, thank you so much for being willing to share your work. Starting around 2020 Jan I studied Python to learn how to apply machine learning, and worked with Freqtrade for a while, then tried Cryptohopper, and have finally landed on the same 3Commas / FTX combination that you have.
I’ve also been liquidated a few times on Binance, so I definitely feel your comment when you say Binance is unforgiving… Have lost a lot of money as well as made a lot of money, but always learning regardless!
1% daily may sound ludicrous to the typical person but I can attest that it is definitely possible with automated crypto trading. I’ve seen even 2-5% daily, like from 2021 Jan to April. The challenge lies in creating something that works consistently in all market trends (bull, bear, sideways) and “black swan” scenarios like we saw with 2020 March in relation to Corona and crashes like May 2021.
Anyhow, I wanted to ask you a few questions. I agree that the entry point is crucial, esp for a quick in-and-out scalping trade.
1. In the bot setup, you have “UPDATE_MAX_SAFETY_ORERS = 4” ; would you be able to share the %s of the deals at each level of used safety orders (e.g. 50% of all deals close at 0 SOs)?
– If it is skewed towards 0 to 1, I usually take this as a sign that the hypothesis regarding the entry point is promising.
2. When a position does use the last safety order, are you manually adding funds?
– What criteria are you using to determine when, at what price, and how much to add (e.g. nearest support level)?
– Since your SO volume and martingale volume coefficient are quite low, I imagine it means SOs aren’t being used often and your entry point is working well?
3. What would you do in a situation where the bags are accumulating and you run out of funds to add manual safety orders?
4. What kind of backtesting did you do to land on your current settings?
– Would you possibly be able to share this?
5. What is your criteria for blacklisting a pair?
– I think Freqtrade has code to auto-blacklist / whitelist certain pairs based on things like volume, perhaps it could be useful?
6. Do you see certain pairs working better than others (closes more deals, closes faster, uses less SOs, more overall profit)?
– Perhaps there is an opportunity in letting the code weigh more successful pairs more heavily by increasing their order size. Freqtrade might also have something along these lines.
I also wanted to share with you a couple things since you have already shared a great deal.
First of all, there is a Tradingview script that I have had moderate success with, called Reversal Finder:
https://uk.tradingview.com/script/OU82iZCq-Reversal-finder/
It identifies when there is a “bounce” in the price, after a spike up or down. It seems similar in concept to the hypothesis your python bot uses, so perhaps it will be useful to you. Sort of similar to your switch functionality. I had a bot running on SXPUSDT 15~30sec, with ~70% or so of the deals closing within minutes. My friend was able to modify the pine script code to allow for backtesting, I might able to share that soon too. Combined with DCA, it could possibly come close to being fully automated with a high % return.
Secondly, the same friend has recently launched a paid strategy called ZoneSwitch. It is more of a trend following strategy primarily for BTC or ETH, opening a long or short at 3-4x leverage depending on the trend reversal:
https://www.zonetraders.net/
I don’t get anything from promoting this, just wanted to share since I believe the backtesting data is very promising.
Please forgive me that this comment is a lot longer than expected!
Cheers, and looking forward to hearing from you and reading more posts.
Tora
LikeLiked by 1 person
Great article bro. Will try it out once I have time. Be sure to update it. thanks.
LikeLiked by 1 person
Hello! Posted a really long comment the other day, a bit bummed that it’s not showing up yet.
I’ve been giving this a try but seem to be getting this error when running python3 Py3c_create.py:
no existing bot ID files found, proceeding….
Error: {‘error’: True, ‘msg’: ‘Other error occurred: not_found Not Found None.’}
Traceback (most recent call last):
File “/root/py3c/Py3c_create.py”, line 175, in
build_bots()
File “/root/py3c/Py3c_create.py”, line 150, in build_bots
longbot_list, no_long_bots = generate_long_bots(pairs_list, min_price)
File “/root/py3c/Py3c_create.py”, line 81, in generate_long_bots
bot_list[key] = data[“id”]
TypeError: ‘NoneType’ object is not subscriptable
Do you know what the cause might be? Thank you!
LikeLike
Hey there! Sorry about that other comment, I’m not seeing it here for moderation, but I’ll dig through the spam list – it may have very well ended up there.
For this error it sounds like an issue with the account on 3Commas end. Make sure you’re using the correct account ID in the config.py file. This comment here has some information on how to correctly find that:
https://github.com/nickpagz/3commas-ftx-triggers/commit/cc56524126fd1e2d7567b2ba252585c166853f9b#commitcomment-54900004
I’ll run another test later on a fresh install, just to make sure it’s not the code, though it was working before I committed it.
LikeLiked by 1 person
PS. I found your comment, I’ll read through it in a bit and approve it. The reply may be post worthy though, looks like there’s some good questions in there.
LikeLiked by 1 person
Re: the error
Thanks! That has helped me identify the source of my confusion – when it says ‘TC_ACCOUNT_ID’, I had thought this was referring to my overall 3commas’ account #, which is a 6 digit number found in the top right of 3commas profile page.
However, I read that github thread you shared and understood you mean the TC account ID that refers to the linked FTX exchange. And then increment by 1 to make it use the FTX Futures account.
And voila, I ran the create script and the bots are being created 🙂
Re: the long comment
No worries, please take your time!
LikeLike
Great! Glad that worked for you. I think I need to add some extra documentation for that part, it’s not obvious or easy to find that out in 3Commas.
LikeLike
May I know if I could apply this bot setting and tweak it for spot trading? Or else do you have any bot settings and python script for scalping with high yield?
LikeLike
I don’t have any other scripts for spot trading at the moment, but sure you can mod the script and tweak it if you want. You can either download and mod it locally, or create a fork.
https://github.com/nickpagz/3commas-ftx-triggers
LikeLike
no existing bot ID files found, proceeding….
The following long pairs were ignored, order volume too low: []
The following short pairs were ignored, order volume too low: []
0 long bots created.
0 pairs ignored, order amount to low
0 short bots created.
0 pairs ignored, order amount to low
Ignored pairs can be found in ignored_longs.txt and ignored_shorts.txt
All done, have a nice day!
>>>
It does not show errors, but does not create bot either. I used to comments below to figure out the exchange-account id and incremented it with 1. Is there something I can try?
LikeLike
It seems to be a common issue, and I’ve tested the script again without any issues. It’s most likely still an account id being incorrect. Here’s another way to check for the correct account id. Create a new bot manually in 3Commas using the exchange/sub-account you want to connect to – make sure you’re able to select a perp pair, and your account balance from your ftx sub-account is shown in the assistant (to be sure you’re setting the bot up to the correct ftx sub account), there’s no need to start the bot, but save it. After the bot is created you’ll end up on the bot information page. Scroll down to the web hooks section and click on “Message to start all long bots on account” to expand it. The account id will be shown in the web hook command. Here’s a screenshot of what that looks like:

Please let me know if that works or not.
LikeLike
Yes! That did the trick. The exchange listed in the overview is the regular FTX exchange, while you need to select the futures account for this to work. In my case is was not just +1, which explained why it didn’t work. The bots are created as we speak 🙂
LikeLiked by 1 person
Hey Nick,
Thanks for the Scripts, I’ve been in the process of writing something similar to switch on and off my bots so looking forward to giving yours a go.
Have you any recent history on how this performed with the recent drop?
Thanks!
LikeLike
Hi Dale,
Apologies for the late reply. I actually had this particular bot off when that happened as I was testing some other scripts. In any case, it should have performed well since it was designed for events like this. Of course it depends on the parameters you specify for both the percentage deviation to trigger a buy, and your 3Commas bot take profit point.
LikeLike
Can this be modified to use other exchanges like ftxus?
LikeLike
Technically yes, though it’s designed to work specifically with the pair formatting from ftx.com which is for eg. “BTCPERP” and the 3Commas pair formatting “USD_BTC-PERP”. For ftx.us it should be fine as long as you can trade perps, which I’m not sure of. If you can, please let me know.
For ftx.us, you’ll want to modify the code in Py3c_triggers.py on lines 33 to 37 to read:
For other exchanges, change line 33 to read for example binance = ccxt.binance({ , or whatever exchange you use. This comes directly from the ccxt library explained here. Again, the pairs formatting and filters are hardcoded in my script, but not too difficult to change to match the format for others.
LikeLike
Hi Nick!
I tried to run the Python script from this blog link, but I am getting the following error:
(base) MacBook-Air-2:3commas-ftx-triggers-main jephrati$ python3 Py3c_create.py
no existing bot ID files found, proceeding….
Error: {‘error’: True, ‘msg’: “Other error occurred: record_invalid Invalid parameters {‘pair’: [‘No market data for this pair’]}.”}
Traceback (most recent call last):
File “/Users/jephrati/Desktop/3commas-ftx-triggers-main/Py3c_create.py”, line 175, in
build_bots()
File “/Users/jephrati/Desktop/3commas-ftx-triggers-main/Py3c_create.py”, line 150, in build_bots
longbot_list, no_long_bots = generate_long_bots(pairs_list, min_price)
File “/Users/jephrati/Desktop/3commas-ftx-triggers-main/Py3c_create.py”, line 81, in generate_long_bots
bot_list[key] = data[“id”]
TypeError: ‘NoneType’ object is not subscriptable
I followed the comments section, and I know that I have the right account ID. I am new to 3Commas, so I do not know if I missed something in the setup. I also sent you an email with the file that I used. Is it possible that there are issues if I use FTX US instead of FTX? (from 3Commas page: https://3commas.io/accounts/30988009)
Thanks,
Jeremy
LikeLike
Hey Jeremy, I had the same issue.
I resolved it by manually going and creating a bot for my FTX Futures account. When the bot is created you can scroll to the bottom of the screen, expand where it says “message to stop all long bots on account” expand that and it will give you the ftx futures account ID.
LikeLike
Hi Dale, yes, I tried to create a bogus bot, and I could confirm that the account ID I have in my config file is correct (emailed the details to Nick). Could it be because I am not currently subscribed to 3Commas? (I wanted to get the script to work before starting the subscription). Or maybe, something else is not installed properly?
LikeLike
Hi Jeremy,
I had to check on the ftx.us thing for you since I wasn’t sure. See my comment above on how to mod the code to work with ftx.us, and as well on my comments on the pairs formatting. Let me know if that works for you!
LikeLike
Hi Nick, Not sure if you have seen the enable Action in the API.
I’m going to add this to the Create Script. Its still 2 separate calls unfortunately
LikeLike
I see this is the same method you use in the update. 🙂 Nevermind. Ha
LikeLiked by 1 person
Thank you so much for making this. Exactly what I was looking for! I know nothing about Python, so this was a deep dive for me. BUT I was determined not to bug you for help. Took me a day and a half but it looks like its worked.
I don’t need to worry about the “Error: {}” message in between each bot in the script do I? It happens for every script that is triggered.
Anyway, you’re a legend for taking the time to make all this available. Huge appreciation!
LikeLike
Glad you were able to find it 🙂
If you mean when the bot is created or updated, no, no need to worry about it – only if you see an actual error message.
LikeLike
Looks like I spoke too soon. Bots are created, bots are updated, bots are activated, and the terminal displays the script searching FTX. However it never takes and trades/opens any deals. Is this “Error: {}” message between every bot perhaps more of an issue than I’d hoped? I’m really stuck now. Any thoughts?
LikeLike
Hmm, I’ve never seen that nor is it programmed in. Is this happening while the triggers script is running?
LikeLike
Thats right. I can see the triggers script identifying bull and bear moves, but no deals are placed within 3commas. I know the connection is working because the script builds all the bots and they appear and can be turned on by the script. I’ve rebuilt the whole thing a few times and regnerated API numbers just incase there was something wrong. Dammit… I was soooo close.
LikeLike
If you start a new deal manually in 3Commas does it start a new deal on FTX?
LikeLike
Yes it does.
LikeLike
It sounds like the script isn’t triggering a new deal because it thinks a) there’s already too many deals (ie. the max number of deals is already met), or b) those coins/tokens already have an active deal.
When you first run the trigger script the bot will display your account balance, max funds usage for your bots, and the calculated max number of positions. Make sure the number of positions is higher than the total number of positions you already have in that FTX sub account.
If the calculation is off, check the parameters in the config.py file and make sure the ones in
#Create Bot Settings
are updated to match the ones in#Update Bot Settings
. At the moment the calculation relies on the former, not the latter – and a minor issue I need to clean up in a future revision.LikeLike
Thanks for that. I don’t have any deals in FTX right now and I haven’t changed the default settings of the script. I can see the script acknowledge my account balance. I’ll run everything again and try to work this out. Cheers!
LikeLiked by 1 person
Hey, want to ask what is the longest time this bot has been running
LikeLike
Sorry, I’m not sure exactly what you mean, but I’ve run the bot full time from July 1 to August 5. There were a few down times in that period, up to 24 hours on some occasions, as I worked through the bugs. Does that answer the question?
LikeLike
[…] passive, but you don’t need to watch your bots all day. I am working on a python script, similar to this – that detects pairs that are trending, ranks them, and automatically starts and ends the […]
LikeLike
Hi, I run on VPS and encounter error:
File “Py3c_triggers.py”, line 348, in
all_open_positions = get_positions()
File “Py3c_triggers.py”, line 207, in get_positions
future = (x[“future”])
KeyError: ‘future’
any idea why?
LikeLike
Getting an error on bot after it checked the market prices….
Traceback (most recent call last):
File “3commas-ftx-triggers-main\Py3c_triggers.py”, line 348, in
all_open_positions = get_positions()
File “3commas-ftx-triggers-main\Py3c_triggers.py”, line 207, in get_positions
future = (x[“future”])
KeyError: ‘future’
LikeLike
Hi Thommy, apologies for the late reply. Sounds like the function is trying to return positions that are not perps. Are there open positions in the sub account you’re connecting to that are not perpetual contracts?
LikeLike
Hi,
No I turned on verbose and it seems it lists all my manual trades, but seems like all the data isn’t really there and it calculates something wrong. I don’t have any positions open and have only done a few manual trades on only perp contracts.
They come from me trying out different things, manually starting bots, doing manual trades, starting from ftx platform or 3commas platforms.
It works up until all the market delays are done and this text comes out before the error:
“Request: GET https://ftx.com/api/positions?showAvgPrice=true {‘FTX-KEY’: ”, ”: ”, ‘FTX-SIGN’: ”, ‘FTX-SUBACCOUNT’: ‘3Commas’, ‘User-Agent’: ‘python-requests/2.26.0’, ‘Accept-Encoding’: ‘gzip, deflate’} None
Response: GET https://ftx.com/api/positions?showAvgPrice=true 200 {‘Date’: ‘Sat, 23 Oct 2021 21:54:17 GMT’, ‘Content-Type’: ‘application/json’, ‘Transfer-Encoding’: ‘chunked’, ‘Connection’: ‘keep-alive’, ‘Vary’: ‘Accept-Encoding, Accept-Encoding, Origin’, ‘Cache-Control’: ‘private, max-age=0, no-cache’, ‘account-id’: ”, ‘ETag’: ‘W/””‘, ‘Content-Encoding’: ‘gzip’, ‘X-Cache-Status’: ‘MISS’, ‘CF-Cache-Status’: ‘MISS’, ‘Expect-CT’: ‘max-age=604800, report-uri=”https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct”‘, ‘Strict-Transport-Security’: ‘max-age=31536000; includeSubDomains; preload’, ‘X-Content-Type-Options’: ‘nosniff’, ‘Server’: ‘cloudflare’, ‘CF-RAY’: ‘6a2e33f9cd231685-ARN’, ‘alt-svc’: ‘h3=”:443″; ma=86400, h3-29=”:443″; ma=86400, h3-28=”:443″; ma=86400, h3-27=”:443″; ma=86400’} {“success”:true,”result”:[{“future”:”ATOM-PERP”,”size”:0.0,”side”:”buy”,”netSize”:0.0,”longOrderSize”:0.0,”shortOrderSize”:0.0,”cost”:0.0,”entryPrice”:null,”unrealizedPnl”:0.0,”realizedPnl”:0.41829092,”initialMarginRequirement”:0.05,”maintenanceMarginRequirement”:0.03,”openSize”:0.0,”collateralUsed”:0.0,”estimatedLiquidationPrice”:null,”recentAverageOpenPrice”:null,”recentPnl”:null,”recentBreakEvenPrice”:null,”cumulativeBuySize”:null,”cumulativeSellSize”:null},{“future”:”EOS-PERP”,”size”:0.0,”side”:”buy”,”netSize”:0.0,”longOrderSize”:0.0,”shortOrderSize”:0.0,”cost”:0.0,”entryPrice”:null,”unrealizedPnl”:0.0,”realizedPnl”:1.84272787,”initialMarginRequirement”:0.05,”maintenanceMarginRequirement”:0.03,”openSize”:0.0,”collateralUsed”:0.0,”estimatedLiquidationPrice”:null,”recentAverageOpenPrice”:null,”recentPnl”:null,”recentBreakEvenPrice”:null,”cumulativeBuySize”:null,”cumulativeSellSize”:null},{“future”:”OKB-PERP”,”size”:0.0,”side”:”buy”,”netSize”:0.0,”longOrderSize”:0.0,”shortOrderSize”:0.0,”cost”:0.0,”entryPrice”:null,”unrealizedPnl”:0.0,”realizedPnl”:1.44909,”initialMarginRequirement”:0.05,”maintenanceMarginRequirement”:0.03,”openSize”:0.0,”collateralUsed”:0.0,”estimatedLiquidationPrice”:null,”recentAverageOpenPrice”:null,”recentPnl”:null,”recentBreakEvenPrice”:null,”cumulativeBuySize”:null,”cumulativeSellSize”:null},{“future”:”FTT-PERP”,”size”:0.0,”side”:”buy”,”netSize”:0.0,”longOrderSize”:0.0,”shortOrderSize”:0.0,”cost”:0.0,”entryPrice”:null,”unrealizedPnl”:0.0,”realizedPnl”:0.00715,”initialMarginRequirement”:0.05,”maintenanceMarginRequirement”:0.03,”openSize”:0.0,”collateralUsed”:0.0,”estimatedLiquidationPrice”:null,”recentAverageOpenPrice”:null,”recentPnl”:null,”recentBreakEvenPrice”:null,”cumulativeBuySize”:null,”cumulativeSellSize”:null},{“future”:”LUNA-PERP”,”size”:0.0,”side”:”buy”,”netSize”:0.0,”longOrderSize”:0.0,”shortOrderSize”:0.0,”cost”:0.0,”entryPrice”:null,”unrealizedPnl”:0.0,”realizedPnl”:1.8485,”initialMarginRequirement”:0.05,”maintenanceMarginRequirement”:0.03,”openSize”:0.0,”collateralUsed”:0.0,”estimatedLiquidationPrice”:null,”recentAverageOpenPrice”:null,”recentPnl”:null,”recentBreakEvenPrice”:null,”cumulativeBuySize”:null,”cumulativeSellSize”:null}]}
Traceback (most recent call last):
File “E:\Installed\Crypto\3commas-ftx-triggers-main\Py3c_triggers.py”, line 348, in
all_open_positions = get_positions()
File “E:\Installed\Crypto\3commas-ftx-triggers-main\Py3c_triggers.py”, line 207, in get_positions
future = (x[“future”])
KeyError: ‘future’
LikeLike
Hmm, that is weird. The function does pull all positions, including closed ones, so in verbose I would expect to see the previous trades/positions, though it filters it out for only open positions. I can see the “future” key in the returned array in your data dump, so I’m not sure why it’s not picking it up. I wonder if they changed the response format?
I’ll take a look at this in some detail in the next day or so and see if I can replicate it on my end and get back to you.
LikeLike
Hi, I found the solution, the data is inside info dictionary, so I change the function as below:
def get_positions():
open_positions = {}
all_positions = ftx.fetchPositions(None, {“showAvgPrice”: True})
for x in all_positions:
y=x[‘info’]
future = (y[“future”])
size = (y[“size”])
side = (y[“side”])
cost = (y[“cost”])
recentAverageOpenPrice = (y[“recentAverageOpenPrice”])
if size != ‘0.0’:
open_positions[future] = size, side, cost, recentAverageOpenPrice
return open_positions
LikeLike
Nice! Thanks! I haven’t dug into it yet, but it looks like FTX might have changed that response since this was working before. I’ll try to replicate and push an update to the code later.
LikeLike
I was finally able to get to the bottom of this issue. It looks like it’s a quirk of Python versions. If I run 3.9.5, the original version works, on 3.9.2 your fix works.
Working on a fix soon, hopefully.
LikeLike
Hello,
I have an error when trying to run the bot after finding a pair and trying to start a deal. (It happens for any pair that pops on the top bull/bear, the one bellow is just an example)
Bot ### Starting new deal. Pair: USD_ROOK-PERP
LongPy_USD_ROOK-PERP (USD_ROOK-PERP): deal_####: Setting leverage: cross. Error occured during request: Impossible to set specified leverage value for the chosen pair
LongPy_USD_ROOK-PERP (USD_ROOK-PERP): deal_###: Error placing base order: Impossible to set specified leverage value for the chosen pair
For more context, I did not change any configuration parameters, just trying to Run as is first.
Do you have any idea of what could it be please?
Thank you and have a good day.
LikeLike
Hello,
I have an error when trying to run the bot after finding a pair and trying to start a deal. (It happens for any pair that pops on the top bull/bear, the one bellow is just an example)
Bot ### Starting new deal. Pair: USD_ROOK-PERP
LongPy_USD_ROOK-PERP (USD_ROOK-PERP): deal_####: Setting leverage: cross. Error occured during request: Impossible to set specified leverage value for the chosen pair
—
LongPy_USD_ROOK-PERP (USD_ROOK-PERP): deal_###: Error placing base order: Impossible to set specified leverage value for the chosen pair
For more context, I did not change any configuration parameters, just trying to Run as is first.
Do you have any idea of what could it be please?
Thank you and have a good day.
LikeLike
This looks like you’re trying to use a different leverage with the bot than the sub account in FTX is setup as, or has existing positions with differing leverage amounts.
You could try connecting to a different subaccount on FTX, one without any existing positions.
LikeLiked by 1 person
You are right! Connecting to a clean sub account solved it. Thank you for the really fast feedback 🙂
LikeLiked by 1 person
Been trying to make heads and tails about the number of bots because I am getting the return of:
Max positions: 0
I cant find that you are using LEVERAGE_CUSTOM_VALUE to calculate bot usage or am I reading it wrong somewhere?
Is it possible to calculate leverage into the math so its possible to run it with 20x leverage and get the max positions correct, as now its not starting any bots.
LikeLike
Yeah, this is a bug in the code. I ran the system without leverage and never had a chance to implement/test that out. There’s an issue logged here:
https://github.com/nickpagz/3commas-ftx-triggers/issues/8
I’ll try to work on that as soon as I can and get it updated.
LikeLike
I’m really confused why you are creating so many bots and not just two multi-pair bots? The multi-pair bots can receive messages to start and stop deals for individual pairs through a dynamic variable. There would be no need to create hundreds of bots, save all their ID’s etc etc.
LikeLike
Yes, this can be done depending on the exchange and the type of account. If you’re trading spot, no problem. With FTX and a sub-account trading perpetual futures (so we can go short as well as long, and use leverage) you’re not able to create a multi-pair bot. Otherwise yes, it would be much easier 😉
LikeLike
I’m trying to understand why, because I am in the process of converting the script (FTX futures) and can’t figure out the actual reason? The bot’s are ready and auto created with all the pairs etc. and the triggers are done, but I just haven’t started it yet to test. Could you elaborate what’s the reason and what I’m missing.
LikeLike
I physically can’t. If I try to setup a bot while connected to an FTX futures sub account, the multi-pair option is greyed out. Screenshot:
.
LikeLike
Make sure you’re actually connected to a futures account.
LikeLike
Oh yeah, my bad. It seems like it’s not actually the Futures account 😦
LikeLike
Hello Nick,
I’ve really enjoyed reading up on your script here and the comments as well. I recognize that there are some adjustments being made at the moment, but one of the questions listed above is something I’m still trying to figure out.
I’m no professional at coding in the least, but can the code be adjusted to accommodate for Binance.us? We don’t have access to standard Binance and FTX here in the US.
Additionally, since this would most likely be spot trades, would it be easier to just set up multiple multi-pair bots instead?
Curious as to thoughts and adjustments to code if applicable.
Thanks for your time and efforts!
LikeLike
If you know what you are doing it’s not that difficult. You can do two multipair bots.
You need to remove the pair creation out of the loop and add the array to the pairs value in bot creation. Then you need to change how it creates the id lists to something like “USDT_ALL:bot_id“. Then on the triggers.py you need to edit the buy and sell functions to send the pair as payload. You also need to change the pairs from USD to something like USDT.
It’s some work and the steps above are simplified and likely miss something, but I’ve done it, just not for Binance (makes no difference). I have never touched Python before, however I’m a full stack web developer.
LikeLike
Well, like Random mentions, it’s not impossible, but it would be a bit of work. Changing to Binance is trivial, going to spot is is more of a challenge. We would have to remove the ability to go short and the whole logic around switching, though it’s not a monumental task per se. Changing the bot to control deals (instead of individual bots per the look-up table) within a multi-pair bot might be the biggest change to the code – and it would likely be large enough it would need a re-write. It would probably be easier to maintain the current approach of multiple single-pair bots, from a modifying the code standpoint at least. It’s not difficult, I just haven’t considered it yet, nor tried to look at the 3Commas API and the py3cw library to see how to manage it.
I’m still planning on creating a new script (when bandwidth permits) that works a little different than this script, and based on some of the requests I’ll try my best to at least include the ability to “option out” some of these hurdles US crypto traders face.
LikeLike
To Nick and Random,
Thank you very much for the kind responses. As I said, I’m not a professional with coding, but I think I understand where the dilemma resides.
I’m definitely not going to say I have comfort with trying to do these manual adjustments to the script, but if I can help test anything in the future, I’m happy to do some assistance in the future.
Looking forward to seeing what can be ironed out for US crypto traders. Thank you for thinking of us!
LikeLiked by 1 person
Would you mind publishing the tradingview screener script?
LikeLike
Hey Dean, I think you mean this one?
https://www.tradingview.com/chart/geJEvaW9/
You can make a copy of the chart so you can modify it as you wish. Keep in mind not all the symbols are added to the chart as I’ve not kept it up to date, but most are there, and you can add any missing ones with the “+” Add or Compare Symbol option.
LikeLike
is the 2% margin that was given to the bots to start a deal the sweetspot? just curious ?
LikeLike
It was for me, but it will depend on your available funds and max number of bots you’ve set, and your timeframe. If you find you’re not hitting your max number of bots very often, then try lowering it a bit. If also depends on the timeframe you’re looking at. If you’re scanning over a 15 minute window, then is 2% the kind of breakout you’re looking for? Maybe you want to look for x% over an hour instead? It’s up to you really.
My thoughts on the bot was to get in early, hence the low-ish timeframe (5 to 15 mins) and the 2% trigger, and ride it until it stopped.
LikeLike
Hi Nick,
I got the same/similar ID-related error and I am on FTX US (same case as Jeremy’s comment on 9/17). I identified the ID via bot creation/lookup (and incremented by “1”) and adjusted the trigger file hostname. Unfortunately still getting the same error. Has anyone been able to get this working on FTX US?
Thanks!
Also, I am on FTX US.
no existing bot ID files found, proceeding….
Error: {‘error’: True, ‘msg’: “Other error occurred: record_invalid Invalid parameters {‘pair’: [‘No market data for this pair’]}.”}
Traceback (most recent call last):
File “C:\Users\ialsh\AppData\Local\Programs\Python\Python310\Py3c_create.py”, line 175, in
build_bots()
File “C:\Users\ialsh\AppData\Local\Programs\Python\Python310\Py3c_create.py”, line 150, in build_bots
longbot_list, no_long_bots = generate_long_bots(pairs_list, min_price)
File “C:\Users\ialsh\AppData\Local\Programs\Python\Python310\Py3c_create.py”, line 81, in generate_long_bots
bot_list[key] = data[“id”]
TypeError: ‘NoneType’ object is not subscriptable
LikeLike
Have a look at this comment, seems the “+1” trick doesn’t always work:
https://onepercent.blog/2021/08/09/make-three-thousand-percent-returns-trading-bots-3commas/comment-page-1/#comment-69
Nope, unfortunately FTX US is not setup for perps, so it won’t work.
LikeLike
Hello Nick!
I got as far as running the create bot script and see 109 LONG bots created along with the lbotid_list.txt. However, no SHORT bots, and no sbotid_list.txt file. Any thoughts?
Thank you!
LikeLike
Yeah, I think it’s because there’s no perps on ftx.us, so you won’t be able to go short. In fact, the script probably won’t work at all since it’s only filtering out/looking for perps. If you’re on FTX us, it won’t find any. I’m surprised you got as far as bot creation to be honest.
LikeLike
I am now on regular FTX not FTX US (that’s why I got this far)
LikeLike
Nice! Ok, then in that case it sounds like you’re not connected to the correct account. See that comment link I shared in reply to your other comment and see if that helps with the correct account number.
LikeLike
P.S. and all of the created Long Bots are FTX futures … so it’s all working, except not creating Shorts.
LikeLike
Indeed, I looked up the ID via the “Message to start all long bots on account” approach. In fact, in my case it worked “as is” (without incrementing by “1”) – I first tried incrementing and just got an error. So it seems the account must be correct if it generated all of the 109 Long Bots? This is the what the CMD output looks like when it’s generating – it cycles between creating a bot and throwing an Error: {} (which I I am guessing is in place of the Short versions). And it ends on some error messages.
THANK YOU FOR YOUR HELP!
USD_ONT-PERP > 7069887
Error: {}
USD_ORBS-PERP > 7069888
Error: {}
USD_OXY-PERP > 7069889
Order volume too low for USD_PAXG-PERP, bot not created
Error: {}
USD_PERP-PERP > 7069893
Error: {}
USD_POLIS-PERP > 7069896
Error: {}
USD_PROM-PERP > 7069897
Error: {}
USD_PUNDIX-PERP > 7069899
Error: {}
USD_QTUM-PERP > 7069900
Error: {}
USD_RAMP-PERP > 7069901
Order volume too low for USD_RAY-PERP, bot not created
Error: {}
USD_REEF-PERP > 7069902
Error: {}
USD_REN-PERP > 7069903
Error: {}
USD_ROOK-PERP > 7069904
Error: {}
USD_RSR-PERP > 7069905
Order volume too low for USD_RUNE-PERP, bot not created
Error: {}
USD_SAND-PERP > 7069906
Error: {}
USD_SC-PERP > 7069907
Order volume too low for USD_SECO-PERP, bot not created
Error: {‘error’: True, ‘msg’: “Other error occurred: record_invalid Invalid parameters {‘pair’: [‘No market data for this pair’]}.”}
Traceback (most recent call last):
File “C:\Users\ialsh\AppData\Local\Programs\Python\Python310\Py3c_create.py”, line 175, in
build_bots()
File “C:\Users\ialsh\AppData\Local\Programs\Python\Python310\Py3c_create.py”, line 150, in build_bots
longbot_list, no_long_bots = generate_long_bots(pairs_list, min_price)
File “C:\Users\ialsh\AppData\Local\Programs\Python\Python310\Py3c_create.py”, line 81, in generate_long_bots
bot_list[key] = data[“id”]
TypeError: ‘NoneType’ object is not subscriptable
LikeLike
Ok, so for the most part that is expected output. The
Error: {}
statement is an empty one, which means there’s no error. However, there does seem to be an error with the SECO-PERP (same from another user comment below). That would stop the script from creating any more bots, and why the short bots never get created – since they get created after all the long bots are successfully created.SECO is still a valid perp on FTX, so not sure why it’s borking – maybe an issue on 3Commas side. Try blacklisting SECO in the config file then running it again.
LikeLike
Hi – I am looking at the PAIRS_BLACKLIST line in the config – could you please clarify the exact syntax to “blacklist SECO” – thank you!
LikeLike
Sure, if you’re using the default list in the file, you can add SECO-PERP to it, like this:
['DMG-PERP', 'BRZ-PERP', 'PERP/USD', 'SRN-PERP', 'PRIV-PERP', 'SECO-PERP']
LikeLike
Nick, I tried adding the following:
PAIRS_BLACKLIST = [‘DMG-PERP’, ‘BRZ-PERP’, ‘PERP/USD’, ‘SRN-PERP’, ‘SECO-PERP’, ‘PRIV-PERP’]
Still only “lbotid_list.txt” is generated. Here is the output:
USD_REEF-PERP > 7075399
Error: {}
USD_REN-PERP > 7075400
Error: {}
USD_ROOK-PERP > 7075401
Error: {}
USD_RSR-PERP > 7075402
Order volume too low for USD_RUNE-PERP, bot not created
Error: {}
USD_SAND-PERP > 7075403
Error: {}
USD_SC-PERP > 7075404
Error: {‘error’: True, ‘msg’: “Other error occurred: record_invalid Invalid parameters {‘pair’: [‘No market data for this pair’]}.”}
Traceback (most recent call last):
File “C:\Users\ialsh\AppData\Local\Programs\Python\Python310\Py3c_create.py”, line 171, in
build_bots()
File “C:\Users\ialsh\AppData\Local\Programs\Python\Python310\Py3c_create.py”, line 150, in build_bots
longbot_list, no_long_bots = generate_long_bots(pairs_list, min_price)
File “C:\Users\ialsh\AppData\Local\Programs\Python\Python310\Py3c_create.py”, line 81, in generate_long_bots
bot_list[key] = data[“id”]
TypeError: ‘NoneType’ object is not subscriptable
LikeLike
Hmm, it looks like it’s failing on SC-PERP as well. I hope it’s not a new limit imposed by 3Commas or FTX. Try blacklisting SC as well as any others you come across. If it continues to fail around this point I’ll have to take a deeper look to see if any changes have been made in the API at either service.
LikeLike
Hi, encountering this problem when trying to run the bot creation script:
Order volume too low for USD_SECO-PERP, bot not created
Error: {‘error’: True, ‘msg’: “Other error occurred: record_invalid Invalid parameters {‘pair’: [‘No market data for this pair’]}.”}
Traceback (most recent call last):
File “C:\Users\userx\Downloads\3commas-ftx-triggers-main\Py3c_create.py”, line 171, in
build_bots()
File “C:\Users\userx\Downloads\3commas-ftx-triggers-main\Py3c_create.py”, line 150, in build_bots
longbot_list, no_long_bots = generate_long_bots(pairs_list, min_price)
File “C:\Users\userx\Downloads\3commas-ftx-triggers-main\Py3c_create.py”, line 81, in generate_long_bots
bot_list[key] = data[“id”]
TypeError: ‘NoneType’ object is not subscriptable
Do you know what is going wrong here or how to debug this? My guess is that a coin is non-existing in FTX/3commas but the error is not throwing an exception on the specific coin.
LikeLike
Hey Davey, see this comment – https://onepercent.blog/2021/08/09/make-three-thousand-percent-returns-trading-bots-3commas/#comment-177 – seems to be an issue with that particular perp. As mentioned in that comment, try blacklisting SECO in the config file and let me know if it works.
LikeLike
Now it broke here:
Error: {}
USD_SAND-PERP > 7075786
Error: {‘error’: True, ‘msg’: “Other error occurred: record_invalid Invalid parameters {‘pair’: [‘No market data for this pair’]}.”}
Traceback (most recent call last):
File “C:\Users\ialsh\AppData\Local\Programs\Python\Python310\Py3c_create.py”, line 171, in
build_bots()
File “C:\Users\ialsh\AppData\Local\Programs\Python\Python310\Py3c_create.py”, line 150, in build_bots
longbot_list, no_long_bots = generate_long_bots(pairs_list, min_price)
File “C:\Users\ialsh\AppData\Local\Programs\Python\Python310\Py3c_create.py”, line 81, in generate_long_bots
bot_list[key] = data[“id”]
TypeError: ‘NoneType’ object is not subscriptable
LikeLike
Ok, I’ll have to do some testing to see if I can replicate this.
LikeLike
I continued blacklisting but it continues to break …
PAIRS_BLACKLIST = [‘DMG-PERP’, ‘BRZ-PERP’, ‘PERP/USD’, ‘SRN-PERP’, ‘SECO-PERP’, ‘PRIV-PERP’, ‘SAND-PERP’, ‘SC-PERP’, ‘RUNE-PERP’, ‘RSR-PERP’]
LikeLike
So, I’m not sure how replicable this is, but I was running into the same issue on my test setup. It’s definitely coming from 3Commas side. I blacklisted these three pairs as well,
'SECO-PERP','SHIB-PERP', 'SHIT-PERP'
, and I was able to get through all the bot setup.I’ll need to take a deeper dive into why it’s one of these specifically though. Unfortunately the error message is a bit too generic from 3Commas.
LikeLike
Hi – with the added blacklists I was also able to finally get through generating Shorts. This is where it broke this time:
USD_TLM-PERP > 7087501
Error: {‘error’: True, ‘msg’: ‘Other error occurred: Expecting value: line 1 column 1 (char 0)’}
Traceback (most recent call last):
File “C:\Users\ialsh\AppData\Local\Programs\Python\Python310\Py3c_create.py”, line 171, in
build_bots()
File “C:\Users\ialsh\AppData\Local\Programs\Python\Python310\Py3c_create.py”, line 151, in build_bots
shortbot_list, no_short_bots = generate_short_bots(pairs_list, min_price)
File “C:\Users\ialsh\AppData\Local\Programs\Python\Python310\Py3c_create.py”, line 129, in generate_short_bots
bot_list[key] = data[“id”]
TypeError: ‘NoneType’ object is not subscriptable
LikeLike
Hmm, I didn’t have breakage after, so this sounds like some API weirdness on 3Commas end, but I will continue to test and see if I can find a common theme.
LikeLike
Hi, Ilya I’m stuck here how did you solve this error? I’m getting trouble with generate_short_bots
LikeLike
I think I just kept adding problematic pairs to blacklist until it went through all the way. This is what I what worked for me
PAIRS_BLACKLIST = [‘DMG-PERP’, ‘LUNA-PERP’, ‘BRZ-PERP’, ‘PERP/USD’, ‘SRN-PERP’, ‘SECO-PERP’, ‘PRIV-PERP’, ‘SAND-PERP’, ‘SC-PERP’, ‘RUNE-PERP’, ‘RSR-PERP’, ‘SHIB-PERP’, ‘SHIT-PERP’, ‘LEO-PERP’]
LikeLike
Hi, could you please share the profit your getting, I tried the script on November, but not getting any profits so I shut it down…
LikeLike
First of all hats off to you Nick, really appreciate your effort here.
Here is my blacklist pairs if someone starting to setting this up now.
PAIRS_BLACKLIST = [‘DMG-PERP’,’LUNA-PERP’,’BRZ-PERP’,’PERP/USD’,’SRN-PERP’,’SECO-PERP’,’PRIV-PERP’,’SAND-PERP’,‘SC-PERP’,‘RUNE-PERP’,‘RSR-PERP’,‘SHIB-PERP’,‘SHIT-PERP’, ‘LEO-PERP’,’BAL-PERP’>
even though I got this in blacklist when creating short bot it threw timeout errors (502), so I have changed the timeout retries in “Py3c_create” file to 3.
p3cw = Py3CW(
key=config.TC_API_KEY,
secret=config.TC_API_SECRET,
request_options={
‘request_timeout’: 20,
‘nr_of_retries’: 3,
‘retry_status_codes’: [502]
}
)
LikeLike
Nick, with so many bots how do you figure out how much the account needs to be funded to support this strategy?
LikeLike
The bot handles it. It will look at the amount available in the ftx sub-account, and how much each bot uses, and automatically limit the number of bots to use the percentage of funds you specify. This is the
FUNDS_USAGE = 0.9
parameter in the config file. 0.9 tells the script to only use 90% of available funds. There’s also aMAX_OPEN_POSITIONS
setting which will be the max number of deals open at one time. This will only kick in if you have more funds available than your bots can use.As an example, if each bot uses $200, and your funds available are $1,000, at 0.9 funds usage you’ll run up to 4 bots at a time. If you had $10,000, that would then likely hit your max open positions, and only that number of active deals will be started/run at one time.
Keep in mind there’s an error in the code with respect to leverage. The formula for calculating how many bots to run doesn’t account for leverage, so if you set leverage on the bots, then this will still limit the number of bots to a value consistent with having no leverage.
LikeLike
Hi Nick, finally tried the systems (I set it up on AWS) … everything got initiated properly, first bot started a deal, then noticed the process existed with the following error:
Cut Positions:
Switch Positions:
Wait 1.00 mins for updated market data. Time: 22:03:26 UTC. [5]/[5]
Top Bulls:
CRV-PERP – 2.31623 %
Top Bears:
YFI-PERP – -2.00 %
<<<>>>
Cut Positions:
Switch Positions:
Long trigger for CRV-PERP
<<<>>>
Wait 1.00 mins for updated market data. Time: 22:04:33 UTC. [5]/[5]
Top Bulls:
CRV-PERP – 2.10442 %
Top Bears:
<<<>>>
Traceback (most recent call last):
File “Py3c_triggers.py”, line 348, in
all_open_positions = get_positions()
File “Py3c_triggers.py”, line 207, in get_positions
future = (x[“future”])
KeyError: ‘future’
LikeLike
P.S. I saw the others had the same problem and tried the adjustment of the def get_positions() function (just line line added??) – but it made no difference.
def get_positions():
open_positions = {}
all_positions = ftx.fetchPositions(None, {“showAvgPrice”: True})
for x in all_positions:
y=x[‘info’]
future = (y[“future”])
size = (y[“size”])
side = (y[“side”])
cost = (y[“cost”])
recentAverageOpenPrice = (y[“recentAverageOpenPrice”])
if size != ‘0.0’:
open_positions[future] = size, side, cost, recentAverageOpenPrice
return open_positions
LikeLike
Let me do some testing on this and get back to you.
LikeLike
Thanks Nick, I got it working (with that fix). Been running for a couple of days. Now the challenge is to figure out why it’s loosing about 1% a day instead of gaining 🙂 Basically all of the profit deals are getting wiped out by the “panic sells”.
LikeLike
Glad to hear you go it working!
Well, today, yes! Definitely the panic sell would have kicked in today. Over the last three or four days the volatility has been really high, with some wild swings, so yeah, I could easily see the bot getting triggered then cutting the positions a few minutes later. It might be worth cranking the
SWITCH_PERCENT
value to something a fair bit lower to take it out of play in the current market conditions and then you can manually decide which ones to cut. I think the default is at -7.0, you can double it or go with like -50 to take it right out of action.LikeLike
Ok, I tested the original code and it works for me no problem. I think the issue is coming from, maybe (read: guessing here a bit) because the sub-account you’re connecting to has never had a PERP position in it before. So the returned array is empty, or at least doesn’t have a “future” position in it, so the code borks when it doesn’t find one (admittedly not the best error handling there, sorry!).
Here’s what I suggest:
Go back to the original code. Manually open a PERP position in that sub-account, then close it. Doesn’t matter what it is, we just need some history, then give the bot another go.
Let me know how that works, thanks!
LikeLike
Hi Nick, thanks very much for posting this. Very smart thinking. I have got as far enabling the bots and running triggers but I am getting htis error when the triggers gets to the end of the first five minutes.
Do you have any idea what might be causing this?
= RESTART: /Users/machappy/Google Drive/Personal/Financial/Crypto/Trading/Trading Bot/OnePercentBot/3commas-ftx-triggers-main/Py3c_triggers.py
Account balances: {‘info’: {‘success’: True, ‘result’: [{‘coin’: ‘USD’, ‘total’: ‘-0.05208683’, ‘free’: ‘-0.05348683’, ‘availableWithoutBorrow’: ‘0.0’, ‘usdValue’: ‘-0.052086828’, ‘spotBorrow’: ‘0.05348683’}, {‘coin’: ‘BTC’, ‘total’: ‘0.02’, ‘free’: ‘0.01998702’, ‘availableWithoutBorrow’: ‘0.01998702’, ‘usdValue’: ‘1072.5712848536’, ‘spotBorrow’: ‘0.0’}]}, ‘USD’: {‘free’: 0.0, ‘used’: -0.05208683, ‘total’: -0.05208683}, ‘BTC’: {‘free’: 0.01998702, ‘used’: 1.298e-05, ‘total’: 0.02}, ‘free’: {‘USD’: 0.0, ‘BTC’: 0.01998702}, ‘used’: {‘USD’: -0.05208683, ‘BTC’: 1.298e-05}, ‘total’: {‘USD’: -0.05208683, ‘BTC’: 0.02}}
Balance: -0.05208683
Max bot usage: 50
Max positions: -1
Wait 1.00 mins for updated market data. Time: 23:06:09 UTC. [1]/[5]
Wait 1.00 mins for updated market data. Time: 23:07:09 UTC. [2]/[5]
Wait 1.00 mins for updated market data. Time: 23:08:09 UTC. [3]/[5]
Wait 1.00 mins for updated market data. Time: 23:09:09 UTC. [4]/[5]
Wait 1.00 mins for updated market data. Time: 23:10:10 UTC. [5]/[5]
Top Bulls:
Top Bears:
<<<>>>
Traceback (most recent call last):
File “/Users/machappy/Google Drive/Personal/Financial/Crypto/Trading/Trading Bot/OnePercentBot/3commas-ftx-triggers-main/Py3c_triggers.py”, line 351, in
cut_positions, switch_positions = evaluate_positions(all_open_positions, price[config.LTF_INTERVALS], top_bull_pairs, top_bear_pairs)
File “/Users/machappy/Google Drive/Personal/Financial/Crypto/Trading/Trading Bot/OnePercentBot/3commas-ftx-triggers-main/Py3c_triggers.py”, line 164, in evaluate_positions
current_price = float(price[key])
KeyError: ‘1INCH-1231’
LikeLike
Hi Lisa,
It looks like there’s no USD available in the account for the bots to take positions with. Make sure the bots are connected to the correct FTX sub account. Also, if you’re trying connecting to a sub-account where there’s already open positions this will affect the calculations and may not trigger any bots. It’s best to use a separate sub-account on FTX for the bot, with no other open positions. Seeing that
1INCH-1231
in the traceback also indicates that’s an open position in your sub-account, and the bot doesn’t know how to handle it since the script only wants to see...-PERP
pairs.LikeLike
Thanks Nick, I figured it out. It was mostly due to an open position as you say. I created a dummy bot to make sure I had the account ID correct, but that dummy bot had the default OPen new trade ASAP setting. So was creating a position. As I was using a new subaccount, I hadn’t checked.
LikeLike
One question regarding your comment above. In the subaccount I had a BTC balance but no USD because I was assuming it would use the BTC balance to open a position as it normally does for me on PERPS account. My other PERP bots function fine without USD and just use whatever coins are in the account as collateral
LikeLike
Yeah, in general you can use any other coin or token as collateral and the 3Commas bots will still work/start deals. The way I’ve coded the script however, it looks for a USD value in the account, then does a calculation to see how many bots can be run in parallel. Because you didn’t have any USD in the account it borked the calculation (it showed -1 bot in your stacktrace). I would have to look at changing this code up to look at the account value in total, and not just USD, and compare that with the leverage value you’re using to do the calculation instead. That in itself creates some other nuances that aren’t so trivial to get around, but I’ll keep it in mind for future iterations.
LikeLike
I actually went in the opposite direction. With the original (-7) 70-80% of the bots just got stuck in the red or exited with the max loss, so I ended up lowering it to -3 (to get out of the deal quicker and lesser loss). Also tried experimenting with adding a stop loss, tweaking the bear/bull_change threshold, etc. Still end up either holding or loosing. Here are my current settings. What do you think?
UPDATE_BASE_ORDER_VOLUME = 50 #IN USD
UPDATE_TAKE_PROFIT = 1.2
UPDATE_SAFETY_ORDER_VOLUME = 50
UPDATE_MARTINGALE_VOLUME_COEFFICIENT = 1.0
UPDATE_MARTINGALE_STEP_COEFFICIENT = 1
UPDATE_MAX_SAFETY_ORERS = 3
UPDATE_ACTIVE_SAFETY_ORDERS_COUNT = 2
UPDATE_SAFETY_ORDER_STEP_PERCENTAGE = 1
UPDATE_LEVERAGE_CUSTOM_VALUE = 1
UPDATE_STOP_LOSS_TYPE = ‘stop_loss’ # or stop_loss_and_disable_bot
UPDATE_STOP_LOSS_PERCENTAGE = 0
UPDATE_STOP_LOSS_TIMEOUT_ENABLED = False
UPDATE_STOP_LOSS_TIMEOUT_IN_SECONDS = 300
UPDATE_START_ORDER_TYPE = ‘market’
LikeLike
To be honest, the price action the last couple days would make any bot struggle. Overall your settings look good, but also give your bots some room to do their thing. Remember the bots need to buy on downward moves to bring your average buy price down – all so that on a bounce you hit your TP point sooner.
If your SWITCH-PERCENT is too low, you may be cutting the bots too soon. A 3% drop in crypto is pretty normal. Looks like your bot will execute a safety order down to 3% drop, then you cut it right away? With the current volatility I would be using -15 or even lower (-20, -25 even). The deals will also take longer to close, so that red bag might be hanging around for a day or two in current conditions.
LikeLike
Ok, I’ll give it a try. What is more surprising/disappointing (so far) is is that this approach (which I thought made perfect sense) of identifying a position with momentum and “trying to catch it” doesn’t seem to be yielding a better outcome (than DCA that don’t do that). It seems that in “majority” of cases by the time the purchase is executed the slope already reverses (I thought the odds would be higher of just riding that momentum to exit deal). That’s how I ended up experimenting with the BULL/BEAR_CHANGE thresholds. How do you arrive at your default values? I currently have them 2.
LikeLike
Yeah, getting this right can be tricky and changes with the market. The problem is there will always be tokens/coins that reverse just after the trigger, no matter the level you choose. Some will run more, some less. What is needed is multiple bots in parallel with at least the average of them not reversing before hitting your TP. While you would catch less triggers, going with a higher trigger level over a longer time period might give better results. Admittedly, the default 2% is fairly low for crypto, dozens of tokens and coins do this daily. I haven’t played around much with different values, though at one time I did look at a 4 hour window, checking every 15 minutes, and looking for 4% breakouts. At the time it didn’t work, and the 2% did better on the shorter time frame, overall – and that’s where the default comes from.
LikeLike
P.S. My reasoning for trying to avoid getting into red bags (with this approach) is because here there is no intelligence about positions – vs. traditional DCA where a position is selected based on information and some rational why it has a chance of succeeding. Does that make sense?
LikeLike
I think so. It’s almost like you don’t need a DCA bot here at all, and just set a buy order directly on the exchange with a TTP and SL. The trigger is the break out and we just want to get in on a position and ride it until it runs out of steam.
LikeLike
That’s exactly where I arrived – in the end I was trying to make the DCA look like a buy order (with 1 SO and smallest SL that was allowed). Do you think it’s worthwhile to try out changing the code to do a simpler buy (unfortunately I am not proficient enough to do it)?
However, you describe that you were averaging 1% per day over the course of the last year? How much do you attribute it general market conditions vs. this approach of “identifying momentum”? VS. a a bot where positions where selected based on some preferences?
LikeLike
I’ve actually done it with some other scripts, so it’s definitely doable. In those scripts the orders are placed directly on FTX, no need for a 3Commas account. In the other scripts I did this the triggers weren’t profitable, so I didn’t publish them. So yeah, it is possible, but I don’t think I’m going to change this one to do that. I’m working instead on a script that does depend on DCA bots but triggers them based on trends, and trend strength. There is a future script in mind that will go without the need for 3Commas, and it would be more customizable in terms of the triggers – but that’s probably a few months away at this point.
For now, it would be best to do as you’ve done and just configure the bots with zero or one SO, a SL, and TP.
Truthfully, the returns are extrapolated from my test runs, and they weren’t actually run for an entire year. Having said that, it does work and the time periods I ran in were fairly flat markets – but did suffer from lots of chop. Ideally a slight trending market will do better compared to the volatility we’ve been seeing the last few days.
LikeLike
Hi Ilya i know exactly where your coming from .. I was just wondering if you have tested these settings you have mentioned with a single SO and tight stop loss??
LikeLike
I have in other scenarios and testing, but not with this particular script, no.
LikeLike
Hi Nick, yes, I experimented with some combinations – basically similar outcome; only benefit is a slower rate of loss. As I mentioned – I am in my 2nd week of learning, and been identifying and trying out all kinds of “recommended” approaches – currently my portfolio is 30% down 🙂
LikeLike
That’s not surprising for this week, plus if you have tight stop losses in play. I personally think this is where having SO’s on the bot can help – though, we really haven’t seen any bounces yet – and there’s possibly more downside to come before we see those bounces.
LikeLike
Thank you for your explanations. I am just starting out (two week ago bought my first coin); in fact, your blog is responsible for my getting into bots 🙂 Two more thoughts:
I wounder if the current script can be strengthened by doing some type of “scalping technical analysis” prior to final decision to initiate bot (eg. say 10 minute time-frame)?
Have you considered incorporating alerts from other services? For instance, several days ago I signed for exchange listing alert (https://cryptocurrencyalerting.com/) – anything listed on Coinbase or Binance. Sure enough next morning I get alert that BICO was listed on Coinbase. I checked for it on Coinbase and got message that “it wasn’t available yet”. Then I decided to check FTX and saw it – by this time (about an hour after alert BICO was up like 100%), and subsequently it went up another 300% by end of day. Those alerts can be provided as webhooks to trigger the the script.
LikeLike
Hmm, it’s possible I suppose. Though I feel there’s other and better options out there overall in terms of a trigger, and I’m working on a couple. At some point I’ll probably circle back to this script and see if I can improve the buy signal, say with some kind of confirmation, like checking the breakout on multiple timeframes, for example. I’m open to suggestions on what those might be.
I have considered something like this, but not looked into it too much. I did read an article about a week ago where someone tried this on Binance but the results weren’t great – for his setup. I did have at one point a script running that checks tweets from Coinbase related to new listings and had it popup in a Telegram channel and alert. I’ve seen the prices jump when that happens, and try to manually take a position when it happens. In terms of automating that, it is possible, yes. Not high on my priority list at the moment, but definitely something in the back of my mind.
LikeLike
https://cryptocurrencyalerting.com/ provides webhook alerts for new listings
LikeLike
Hi, Nick Thank you for sharing your script. I tried to run it on a Linux VPS. I get created all Bots in my accounts on 3commas, but I don have deals yet. How do you know if the script is still running? the script keeps running in the background? if I close my terminal and then open it I have to run it again to see the script’s updates. 🙌
LikeLike
Hey there,
If you close the terminal it will probably stop running. To get around that I use tmux. Start a new tmux session, then run the script. This video at around 5:30 or so describes how to use tmux for exactly this.
LikeLiked by 1 person
Hi Mike, It looks like a random error since I tried to run again the create.py script and I got this error on different pairs. I realize that the script creates bots alphabetically so I tried to add the next one Pair on the black list, but still shows me the error in another different pair.
I have this Black list: PAIRS_BLACKLIST = [‘DMG-PERP’, ‘BRZ-PERP’, ‘PERP/USD’, ‘SRN-PERP’, ‘PRIV-PERP’, ‘SECO-PERP’, ‘SC-PERP’, ‘SHIB-PERP’, ‘SHIT-PERP’]
USD_BTT-PERP > 7267991
Error: {‘error’: True, ‘msg’: ‘Other error occurred: Expecting value: line 1 column 1 (char 0)’}
Traceback (most recent call last):
File “/var/www/webroot/ROOT/Py3c_create.py”, line 171, in
build_bots()
File “/var/www/webroot/ROOT/Py3c_create.py”, line 151, in build_bots
shortbot_list, no_short_bots = generate_short_bots(pairs_list, min_price)
File “/var/www/webroot/ROOT/Py3c_create.py”, line 129, in generate_short_bots
bot_list[key] = data[“id”]
TypeError: ‘NoneType’ object is not subscriptable
Do you have any ideas? Thank you.
LikeLike
I finally got around to testing a new script and was coming across this issue again, it was getting frustrating to say the least. Anyways, after a few hours I finally figured it out. You need to black list SHIB-PERP in the config.py file. Shib is included as a perp on FTX, but it’s not an option in 3Commas to choose it. This is why the script kept breaking.
LikeLike
Hi Nick
This is some really great work! Being a US trader I wonder if anyone or you have done any major alterations to make this work on FTX-US or CBPro. I saw some others post similar questions but hadn’t seen anyone take on that project.
If anyone you know of has done this please share.
LikeLike
I’m not sure if anyone else has forked this and modded it for ftx-us, I certainly haven’t – mostly because they don’t have perps which is what the script is based around. My next script will also be using perps, but I’ll look into modding that one for use with ftx-us, but no promises at this point.
LikeLike
Thanks Nick! Completely understand! I will keep my fingers crossed. Haven’t programmed in years but maybe it’s time to dust off my coding skills and pickup python. If I make any headway I will share back
LikeLike
Hi Nick,
Great work! I’ve tried to convert it to FTX spot, I’ve realized there are not so many USDT pairs, so it does not fire too often(default config), maybe I will try it on Binance too.
Does this concept/strategy only work properly on perps? If yes, what’s the reason for it?
On the other hand, many times I’ve failed to catch the momentum… Am I right if the price starts dropping(long), there is no reason it will rise again? Or is that’s why a switch is a must?
Are the current(git) settings in the config(that’s what I’ve used), the ones that work for you?
Thanks,
Really amazing work, I’ve learned a lot
LikeLike
It’s designed around perps, yes. The code filters pairs with the name “perp” in it, so it will only create bots for those. I did it that way for the same reason you mentioned… not many pairs in spot on ftx. In fact, they have perps with no equivalent in spot. Plus, you can go short with perps, instead of trying to do it in spot where you need margin and collateral. The bot will look for long and short triggers, and I leaned on that capability with the perps.
No one really knows! The price could continue to rise, or it can fall. It can fall a bit, then rise again. The bot was designed to look for a breakout (or strong trend), and ride that for as long as it can. The switch is not a must, but it’s a way to try and recover a deal that’s going in the opposite direction. So if a breakout happens, a deal is triggered, then it starts going the other way – how long do you ride that for? The switch is there so you can also catch that opposite trend – ie, cut your losses and catch some profits in the other direction. To be honest, I’m not sure it helps with getting more returns instead of just cutting the deal. It was a feature I added after my initial testing run, so never got a chance to test the results long term.
They worked for me at the time, yes. But I wouldn’t say they’re the ideal settings to use as this varies by market conditions. I also mentioned I didn’t use the switch feature when testing, and I also didn’t use stop losses – I rescued my bags manually. Again, the settings should really be adjusted for the timeframes and breakout levels you’re looking at.
LikeLike
Thank You Nick, and special thanks for the detailed answer! It helped me a lot to understand it better!
Btw. I’ve never used Python before, it was a nice project to learn that too along the way.
Just a quick note for the upcoming traders who try this script, I think in the Py3c_create.py the pair should look like this:
“pairs”: “USDT_”+str.removeprefix(key,”USD_”).removesuffix(“/USDT”)
(and not “pairs”:key)
LikeLike
@Feri,
Would you mind sharing your code for spot trading on FTX? I was going to start looking at this code for spit trading given in the US we don’t have FTX or Binance. Additionally haven’t seen any US authorized exchanges to do perp trades.
LikeLike
Would you might sharing your forked code for FTX spot trading?
LikeLike