1. Routes - Algo trading from scratch with Python — Transcript
Full transcript
- 0:02in this video i will explain what
- 0:04justice routes are and then i'll show
- 0:05you different examples of how to use
- 0:07them
- 0:12a route is used to tell jesse where to
- 0:14trade what to trade in which time frame
- 0:17and using which strategy i'll show you a
- 0:19basic example in a second and then i'll
- 0:22show you how to go further by using
- 0:23multiple symbols and time frames inside
- 0:25the same strategy let's get started i
- 0:28will dive into strategy development in
- 0:30one of the upcoming videos but in this
- 0:32one i still need a simple strategy to
- 0:34show you how to use routes so i'm gonna
- 0:36start by writing a golden cross strategy
- 0:38which is like the hello world of algo
- 0:40trading i don't want to do short selling
- 0:43here so i'll just remove the shoot short
- 0:45and go short methods i'll begin by
- 0:47defining two moving averages whenever
- 0:49the one with the shorter period crosses
- 0:51the longer one we open a long position
- 0:54the period for the short ema is going to
- 0:56be 21 and for the longer one
- 1:00i'll use
- 1:0150
- 1:02and to define the cross i'll say return
- 1:05true whenever the short ema is bigger
- 1:08than
- 1:09the long ema
- 1:10since i'll be using a market order for
- 1:13entering my trades the value of should
- 1:16cancel entry doesn't really matter but
- 1:17i'll return true just because it's good
- 1:19practice
- 1:20as for my entry order i want to use all
- 1:23the existing balance in my account and
- 1:26for the entry price i want to use the
- 1:28current price in other words i want to
- 1:30use a market order so i'll say quantity
- 1:33equals
- 1:35utils dot size to quantity
- 1:39first parameter is going to be my
- 1:41current balance
- 1:43the second one will be the entry price
- 1:45actually let's define the entry price as
- 1:47a separate variable and use it here
- 1:51now i can define the buy order by saying
- 1:54self dot by equals
- 1:57quantity
- 1:58comma
- 2:00enter price
- 2:01as for exiting my positions i want to do
- 2:03it whenever the opposite of my intrude
- 2:05rule happens
- 2:07first i'll define the object position
- 2:09method
- 2:11then i will copy the code for my moving
- 2:14averages paste it here
- 2:16and
- 2:17i'll say if the short ema is smaller
- 2:20than the long ema liquidate my position
- 2:23all right now i have a basic strategy
- 2:26let's say i want to backtest this
- 2:28strategy on binance spot
- 2:31and the symbol of btc usdt
- 2:34using the 15 minutes time frame
- 2:37and the strategy is is going to be the
- 2:39example of strategy which is what we
- 2:40just defined now let's head to the back
- 2:42testing page and see how we can define
- 2:45the route for it inside the route
- 2:47section you will always find at least
- 2:49one existing route that's because it is
- 2:51the minimum requirement so i can just
- 2:53modify the existing one for the exchange
- 2:55i will choose binance spot
- 2:58the symbol is already btc uct but even
- 3:01if it wasn't i could enter it here
- 3:04and the time frame will be 15 minutes
- 3:07and the strategy is already selected
- 3:10because there's only one strategy in my
- 3:12current directory and that's a basic
- 3:14route now i could just sort the back
- 3:16test by selecting the duration first
- 3:19and pressing the start button
- 3:26you can also trade multiple symbols at
- 3:29the same time whether with the same
- 3:31strategy or different ones for example
- 3:34let's say i want to trade the same
- 3:35strategy for both btc usdt and eth usct
- 3:40i already have the first route for btc
- 3:43now i have to create another trading
- 3:45route
- 3:46for eth usdt
- 3:49the time frame could be anything but i
- 3:50still want the 15 minutes and the
- 3:52strategy could also be anything but in
- 3:55this case i only have one strategy and
- 3:57it should work fine for both of them
- 4:00instead of adding a new trading route i
- 4:02could just duplicate the existing one
- 4:04and change the symbol so let's delete
- 4:06this one
- 4:08and this time
- 4:10i'll duplicate the existing one and
- 4:12enter the symbol to be eth usct and now
- 4:16the time frame exchange and strategy are
- 4:18all the same as the first route
- 4:25one of the cool features of jesse is
- 4:26that you're not limited to using one
- 4:28time frame only you can use multiple of
- 4:30them and you don't even have to worry
- 4:32about look-ahead bias either this is the
- 4:35chart of btc usdt on the 15-minutes time
- 4:38frame which is what we were trading on i
- 4:40also added the indicators that we had
- 4:42inside our strategy which are the emas
- 4:45with the periods of 21 and 50. our entry
- 4:48rule was to open a long position
- 4:50whenever the short ema crosses the long
- 4:52ema in other words whenever the blue
- 4:54line goes above the green line in some
- 4:57cases like in this one we're going to
- 4:58face false breakouts the blue line is
- 5:01above the green line but is so fresh
- 5:03that it probably wasn't a good idea to
- 5:05open a position just yet a simple way
- 5:07for filtering out these subs of false
- 5:10breakouts is by simply using a bigger
- 5:12time frame for determining the bigger
- 5:14trend of the market the right chart is
- 5:16the bitcoin price in the hourly time
- 5:18frame and the left one is the one with
- 5:20the 15 minutes which is what we were
- 5:22trading on as you can see here even
- 5:24though the crossover happened on the 15
- 5:26minutes time frame the right chart which
- 5:28is the hourly time frame is not showing
- 5:30an uptrend so if we could use the hourly
- 5:32time frame as some kind of filtering
- 5:34indicator this would not have happened
- 5:37so we can say we have a short term and a
- 5:39long term trend so i'll define a new
- 5:42property called
- 5:44short trend
- 5:45and i'll copy and paste from what we had
- 5:47earlier except that now instead of
- 5:50returning true i will return
- 5:52one for an uptrend
- 5:55and
- 5:56minus one for any other situation and
- 5:58i'll modify what we had before to use
- 6:01this new property
- 6:04and also use it for exiting trades all
- 6:07right now that we have the trend for the
- 6:08left chart which is the 15 minutes time
- 6:11frame i need to define the code for the
- 6:13hourly time frame which is the right
- 6:15chart
- 6:16i'm gonna copy the short trend
- 6:19paste it here
- 6:21and rename it into
- 6:23long trend
- 6:24the difference is of course about the
- 6:26candles before i was passing them by
- 6:28using the self.candles property which
- 6:31gives me the candles for the current
- 6:33trading time frame which in our case is
- 6:3515 minutes to get them for the hourly
- 6:37time frame i need to specifically ask
- 6:40for them to do that i'll be using the
- 6:42get candles method the first parameter
- 6:44is the exchange which i will pass in the
- 6:46current exchange as for symbol i will
- 6:49pass in the current trading symbol which
- 6:51is btc usdt
- 6:54and as for the time frame instead of
- 6:56passing it as self.timeframe which gives
- 6:59me the current trading timeframe i will
- 7:01specifically ask for the hourly time
- 7:03frame and then i will repeat this for
- 7:06the long ema as well
- 7:08and we should be good so once again the
- 7:10only difference between long trend and
- 7:13short trend is the candles for the short
- 7:15trend i'm using self.candles which gives
- 7:18me candles for the current trading time
- 7:20frame and symbol which in this case is
- 7:2215 minutes and btc uct and for the long
- 7:25trend i'm using get candles which allows
- 7:27me to specifically ask for a certain
- 7:29time frame and symbol in this case i'm
- 7:31asking for the hourly time frame now
- 7:33that i have this new indicator ready i
- 7:35can use it inside my interview rule so
- 7:37inside my shoot long method i'm gonna
- 7:39add and
- 7:41self.long trend
- 7:43equals one all right let's run another
- 7:45back test and this time i should get an
- 7:47error saying that the below route is
- 7:49missing from my routes that's because
- 7:51even though we are using the hourly time
- 7:53frame inside our strategy we didn't tell
- 7:56jesse about it to do that i'll have to
- 7:58add an extra route which is identical to
- 8:01a trading route with only one difference
- 8:03it doesn't accept any strategy for our
- 8:05case i have to choose the same exchange
- 8:08which is binance spot
- 8:10and the symbol will again be btc usdt
- 8:13but the time frame has to be the hourly
- 8:16time frame and again there is no
- 8:18strategy for an extra route
- 8:20now if i run the back test again this
- 8:22time it should go through
- 8:29let's say we were to backtest our
- 8:31strategy for each usdt instead of btc in
- 8:34this case looking at the chart of
- 8:36ethereum alone is probably not the best
- 8:38idea it is a known fact that the btc
- 8:40price moves the whole crypto market so
- 8:42it's probably a good idea to use this
- 8:44data as some kind of confirmation before
- 8:46entering trades
- 8:48i'm gonna copy the code for short trend
- 8:51paste set and rename it into
- 8:55btc short trend
- 8:58and just like before i have to replace
- 9:00self.handles with self.getcandles
- 9:04which allows me to specifically pass in
- 9:06the exchange the symbol which in this
- 9:09case
- 9:10instead of passing self.symbol i will
- 9:12pass in
- 9:13btc usdt
- 9:16and then the time frame which in this
- 9:18case i want it to be my trading time
- 9:20frame so i just pass it by self.time
- 9:22frame and i'll do the same for this
- 9:25variable
- 9:27and inside the shoot long method i will
- 9:29add and self.btc short trend equals one
- 9:35and if i run the back this again i
- 9:37should get an error saying that
- 9:39the route for btc usdt is missing that's
- 9:43because i've only told you see about the
- 9:45routes for each usdt so now i have to
- 9:48define a new one for btc usat that is
- 9:51going to be an extra route
- 9:53with the time frame of 15 minutes which
- 9:56is my trading timeframe and the symbol
- 9:59will be btc usdt now if i run it again
- 10:03it should work
- 10:05alright that's it in the next video
- 10:06we're gonna talk about how to import
- 10:08candles and explain the concept of
- 10:10warm-up candles in jesse
- 10:17[Music]
About this transcript
This page contains the full transcript of 1. Routes - Algo trading from scratch with Python by Algo-trading with Saleh, generated from the public captions YouTube serves with the video. The transcript has 1,709 words across 261 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.