Cryptocurrency 💰 Trading Bot 🤖 with Python & Binance - Reversal & Trailing Stop Loss

preview_player
Показать описание
Hi everyone,
In this video we are building a cryptocurrency trading bot which buying condition is based on a reversal of the recent past return and is taking a Trailing Stop Loss for the selling condition.
In the end I did some cuts as the Stop Loss Order was being triggered after roughly one hour.

Get the Notebook/Source code by becoming a Tier-2 Channel member:

If you like the content please subscribe to make future content possible. Thank you very much in advance! :-)

Let me know what you think or let me know your questions in the comment below.

Please watch the previous video to better along:

Video on cumulating returns:

Disclaimer: This video is for educational and entertainment purposes only and is not an investment advice!

0:00 - 0:51 Trading strategy
0:51 - 02:42 What is a Trailing Stop Loss?
02:42 - 03:45 Subscribe etc. and Disclaimer
03:45 - 05:00 First script: Getting live data via socket manager / SQLite storage
05:00 - 07:00 Second script: Connect to SQLite database and the Binance API
07:00 - 07:45 Request live data by SQL to dataframe
07:45 - 10:24 Coding example of Trailing Stop Loss
10:24 - 15:38 Coding the strategy: Buying condition (Reversal)
15:38 - 21:38 Coding the strategy: Selling condition (Trailing Stop Loss)
21:38 - 25:18 Testing the strategy / Discussing the trade outcome

#Python #Trading #Crypto
Рекомендации по теме
Комментарии
Автор

Hi everyone, please note there is a mistake in the script at 20:50. 
Instead of taking the first valid entry it should be the last valid entry or just iloc for the very last row and check if the condition is fulfilled.

Thanks DanyC for pointing that out!

Algovibes
Автор

Just found your channel. Loving this series, fantastic work. Subbed.

williamdagger
Автор

Tremendous content! I really appreciate your videos... gives hope to a newbie programmer like me that I could actually augment my trading with Python.

markk
Автор

Thank you for creating these videos. They are goldmine of knowledge

anshmiester
Автор

Let me thank you first for amazing content.. Keep your research on and on.. All the best!

viqarahmed
Автор

thank you for good approach. it is not really clear for me why we need to store and read from SQL DB. we can retrieve the data with 1sec interval and work with it instead.

ylisko
Автор

Hi, very recently discovered your videos, very good. Do you ever backtest a strategy before running it on your real account? I mean testing it on e.g. 5 years of historical data. And only starting it with real money if the strategy has proven to be profitable on this backtesting period.

tradermodeste
Автор

Hey nice video, congrats! I have a doubt about the stop condition, you are using the first_valid_index(), but should not be the last_valid_index() what we need here? because in the case of fist_valid_index yo get always the same row. Did i miss something here ?

danyc
Автор

Auch top erklärt, gute Geschwindigkeit, freue mich auf die nächsten! Cool wär' noch, wenn der bot periodisch den Zwischenstand des Trades in % printet, aber das ist ja nicht so schwierig, es selbst noch zu tun hehe. Was hältst du von Gridbots? Haste damit schon Erfahrungen gesasmmelt? Denke mir, relativ risky, falls die coin in den brunnen fällt aber bei verlässlichem sideways movement sicherlich ne gute Sache. Anyways, Danke erstmal für das video 🙂

gallerksee
Автор

in order to run the engine do we have to install MySQL? or the modules in python are enough?
actually where does the DataStream gets stored and how can we delete if not required for later?

nine_tales
Автор

Hi Algovibes, I would first highly appreciate for the rich and highly informative content out here. I hope to see more of your videos, but in the mean time i was i wondering if u could incorporate a trailing buy order with this bot.

AbdirashidMAli
Автор

Great Content, Bring some more strategy with trailing stop loss.

adityarawat
Автор

Fantastic, One request, how can we stream live klines for Binance Futures contracts ? I looked into documentation but got confused, any syntax for the same, or its very complicated for us, thanks

kamleshdatt
Автор

Hi Algo, I m watching few different video of the playlist (very good content by the way ty).
One question pop in my head about the difference between the way you can get the data. Is there a difference between the binanceWebsocket module and the the websocket ? I understand the purpose is to connect to binance stream but is there one more efficient than the other ?

Turbonito
Автор

I'm "like number" 500... Just saying I'm pretty special.... Also i like your content!

fuba
Автор

Hi Algovibes, thanks for the video. I'm wondering if there's a situation where the qty BOUGHT > qty when the bot will try to SELL due to commission? If this is the case I imagine you'll receive an error when it tries to sell? I'm wondering how you can get around this, 1 solution might be to update qty after the BUY order by subtracting the commission? Then you might run into the qty being defined as a float with too many decimal places such that it's defined past the min step size of the order. Do you have any thoughts on this?

christopherchen
Автор

Hi Algovibes, First of all thank you for all the videos you make. I have learned a lot from it. However, I have a question regarding backtesting and I hope you could help me. I would like to know when I resample a (crypto) data frame to, for example, 20 minutes or in those 20 minutes my trade met my take profit condition or my stop loss condition. So it must be calculated whether the High or Low of each minute achieves the percentage of my take profit or stop loss compared to the Open of the first minute or not. If not then move on to the next minute. How can I best do this? Thank you in advance.

tayaamme
Автор

@Algovibes, Amazing videos! You have helped me tremendously in building my first ever trading bot. I do have a question though: What is the benefit of writing the dataframes into a db first and then pulling it back up to monitor/trace the stop loss? Couldn’t you theoretically keep the data in the pandas dataframe and work with the entries directly from there?

razolino
Автор

Thank you for your amazing videos! I was wondering if you have any plans to do a Futures Trading Bot video? We would highly appreciate it if you can do one or guide me. :D Keep up the good work!!

ishmamchoudhury
Автор

Perhaps put msg into a deque instead of a db. Then no worries about getting too large.

bobjazz
visit shbcf.ru