How To Build a Simple Cryptocurrency Trading Bot with Python and the Binance API
E conheça também sobre o Melhor Bot Para Opções Binárias 2022
Que tal um robo gratuito para IQ Option? Sistema Para IQ Option Grátis
Hi everyone,
I made some simplifications and further amendments to the already covered trading bot on the Slow / Fast SMA holding strategy. Let me know what you think in the comments below 🙂
Thx a lot for watching.
Get the Notebook/Source code by becoming a Tier-2 Channel member:
Disclaimer: This video is not an investment advice and is for educational and entertainment purposes only! Cryptocurrency and automated trading is bearing a high amount of risk which might result in a total loss of your invested capital.
If you want to support me you can register for Binance with this link, but don’t feel forced to:
Mentioned video in the very beginning:
Note: In the very beginning I am referring to changes in the csv file. While recording I have actually considered it to be way more easy to directly change the dataframe. You can still work with a changing csv file with 2 amendments: Pulling the csv file before looping over the selling and buying conditions. Change the changepos function and add a to_csv function (as in the linked video).
Set up Binance API video:
Backtesting Crypto strategies:
Backtesting SMAs in general (including finding best pairs):
Video on deployment on the Google Cloud Platform (GCP):
Also please check out my cryptobot playlist, there is a lot more stuff to check out if you are interested in those kinds of topics:
[‘BTCUSDT’,’ETHUSDT’,’LUNAUSDT’,’SOLUSDT’,’UNIUSDT’,’AVAXUSDT’,’QNTUSDT’,’BNBUSDT’,’GALAUSDT’,’XRPUSDT’,’SHIBUSDT’,’ENJUSDT’,’DOTUSDT’,’SANDUSDT’,’DOGEUSDT’,’VETUSDT’,’NEARUSDT’,’ONEUSDT’,’XLMUSDT’,’MANAUSDT’,’TRXUSDT’,’XTZUSDT’,’BCHUSDT’,’FILUSDT’,’ATOMUSDT’,’KLAYUSDT’,’AAVEUSDT’,’HNTUSDT’,’EGLDUSDT’,’ADAUSDT’,’LINKUSDT’,’MATICUSDT’,’EOSUSDT’,’THETAUSDT’,’LTCUSDT’,’NEOUSDT’,’ETCUSDT’,’XMRUSDT’,’TFUELUSDT’,’FTMUSDT’,’ALGOUSDT’,’HBARUSDT’,’FTTUSDT’,’MKRUSDT’,’AXSUSDT’,’GRTUSDT’,’CAKEUSDT’,’ICPUSDT’,’FLOWUSDT’,’XECUSDT’]
00:00 – 00:50 Infrastructure of the bot (please read Note in the description)
00:50 – 04:11 Going over some Trades on Binance
04:11 – 04:56 Prerequisites / Disclaimer
04:56 – 07:31 Setting up initial csv file/ dataframe
07:31 – 08:05 Libraries / Set up
08:05 – 10:10 Pulling historical price data
10:10 – 11:45 Technical indicator / SMA calculation and check
11:45 – 15:16 Function changing positions in case of buy / sell
15:16 – 22:15 Trading logic
22:15 – 24:34 Running the bot / Hints on deployment
#Python #Tradingbot #Crypto #Binance
Vídeo
Thanks so much my friend !
BTW, I'd love to join binance and reference you in whatever way possible but the binance is way over-strict in their acceptance of new customers. I mean, I turned myself into a darn monkey in front of the web cam, nodding, smiling, opening my mouth, holding the IDs and still got rejected. I tried my passport, drivers license, id… No… I think I just have to put my xrays showing my bones (MRI scan results might do better idk) to prove I have no intention to rob them.
Thank you !!!
how to capture entry price of future trade after place market order? plz
Hi! and thank you for the video it is very helpful and I learned so much from it. I noticed that this bot can trigger buy orders in the middle of the bullish run (especially when starting it for the first time or after a restart) and I think I might have figured a way to prevent this by using an AND condition when checking fastSMA and slowSMA in the BUYING for loop. We need to use an AND condition to check that the row before the last row is the inverse, and i believe this will ensure that it will trigger a buy order only at the begining of the bullish run. I would love your comment on this and I have included my coded solution below. also is the data request rates within binance's limit?
lastrow = df.iloc[-1]
beforelastrow = df.iloc[-2]
if lastrow.FastSMA > lastrow.SlowSMA and beforelastrow.SlowSMA > beforelastrow.FastSMA:
Thanks a lot man ! I have a question: Do these two lines below serve the same purpose for reaching quantity value ? posframe.loc[posframe.Currency==curr, 'quantity'] /// posframe[posframe.Currency==coin].quantity.values[0]
Hi Algo, thanks for the great video!
Is the posframe updated automatically in its notebook while the trader function runs in a separate notebook?
How do we make the posframe reflect changes in quantity and position automatically while the bot is running?
Thanks a ton for your help!
Hi Algovibes , this framework is great , how can it be improved further , in a situation where the cloud service( I am using pythonanywhere) stops and restarts , the data held in the posframe is lost , so when they restart the bot after a few seconds, the bot forgets about the assets already held in the posframe, any solution to this? a situation where after a restart the bought checks the assets already in the posframe. Thanks for the great work
Great video mate. thanks
the loop doesnt save the updated data to csv, so the position and quantity doesnt change, but the rest works. any help?
after i build robot where you put robot vps where
Thank you very much for sharing your vast knowledge with everybody!
I´m trying to do a similar script (using a CSV file) and I´d like to run it in the cloud 24/7, should I create a Windows VM in GPC?
Thanks in advance!
Amazing.
Good job
Thanks
Please write a trader bot base on kucoin websocket api
Kucoin api gave Too Many Request error
Could a simpler trading bot be made where you enter in the first order and the bot goes off of that. Say the stock is at .0125 and you buy. Could you design the bot to simply sell if it goes to .0126? Then when it goes back down to 0.125 buy again? And if it doesn't reach that in an allocated amount of time, cancel the bot and wait for the user to initiate a trade again. And at a stop loss, the user has to re-initiate the trades. Rather than using indicatiors, databases, etc…
Cool! I like that. I know this is a proof of concept, but there is room for improvement. Let me point out the most obvious. You need run the trade function only once per candle. In this case as the bot is trading based on the hourly timeframe, the trade function should run only once per hour. If it simply runs in an endless loop without a break, it would open positions on the first iteration and then on the further iterations do nothing except logging until the next candle. I do this even more optimized by subscribing to the chart data via WebSocket. When the exchange pushes a new candle to my bot, the trade funtion is triggered.
Thank you so much for the content. One question though. If we want to get a ticker for a certain coin, should we use a WebSocket or just (I'm trading in futures market) futures_klines(…) inside an infinite loop? I am asking cause a lot of times I have encountered a timeout exception that terminates my program and after a lot of research, I haven't found a clean solution around it so now I'm thinking to refactor most of my code (i'm using the second way).
Hey, that's a great video! I think it's possible to create some mock instead of real binance client and try this bot in "test mode", right ? Just run it for a month in some cloud and see the actual profit. Has anyone tried it ?
Great content.
How can I run the code only in the old data? (Backtesting)
Danke.
Deine Videos sind immer interessant.
Ich lerne fleißig.
Ihre Studentin aus Deutschland
How to set up stop losses
Great videos. Can you make one python code based on Helkin Ashi
9:00 Sorting Data
I would likt to build a live trading simulation for Binance. So unlike backtesting i would like to use live data to test an algorithm without actually having to spend money. Do you know how i could use the Binance API for that? Would that maybe qualify as a Idea idea for you? Would love to see that. Great Videos, you really show that it's not that hard to build your own trading bots!