How to set up a remote dev environment for algo-trading with Python in VSCode — Transcript
Full transcript
- 0:00let's say you have a great idea for a
- 0:02trading algorithm you're excited about
- 0:04it and you want to try it out but
- 0:06unfortunately your development
- 0:08environment is just not ready maybe it's
- 0:10because you haven't installed all the
- 0:11dependencies yet or maybe you are out of
- 0:14your office and cannot access your work
- 0:16computer or maybe you just want to play
- 0:18around with a couple of packages without
- 0:20messing up your existing environment if
- 0:22any of these describe your current
- 0:24situation you can use a remote dev
- 0:26environment
- 0:27it's really easy to set up at this after
- 0:29watching this tutorial and it's super
- 0:31affordable in fact you can get started
- 0:34for free
- 0:35[Music]
- 0:38when it comes to choosing a cloud server
- 0:40provider what we're looking for is a
- 0:42good balance of the quality and the
- 0:44price if you are living in the us i
- 0:46highly recommend using digitalocean
- 0:48there is starting server which is more
- 0:49than enough for our use case it starts
- 0:52from 5 bucks a month but if you use my
- 0:54link you can get it started for free the
- 0:56other cloud provider that i personally
- 0:58recommend and use is hestner their
- 1:01starting plan offers more resources for
- 1:03the same price and if you use my link
- 1:05you will get 20 euros free credits
- 1:08[Music]
- 1:11i already have a history account so i'm
- 1:13gonna log in
- 1:19i will choose the tutorials project
- 1:22since i'll be using this server for
- 1:24development is actually quite important
- 1:26if the location of the server is closest
- 1:28to me so that the ping would be lower
- 1:30for that reason i choose germany but you
- 1:32do whichever is closest to you
- 1:35ubuntu 2004 is exactly the image that i
- 1:38want so i'm not gonna change that
- 1:40i will choose the second server plan
- 1:42because for only 60 cents more per month
- 1:44i will get two cpu cores which i think
- 1:47totally worth it
- 1:50and now i have to choose the ssh key of
- 1:52my local machine
- 1:53in your case if your account is new you
- 1:55have to generate your ssh keys if you
- 1:58haven't already and add it by choosing
- 2:00the add ssh key button
- 2:02and at the end i will change the server
- 2:04name it's not really important what you
- 2:06set here but i prefer something that i
- 2:08can remember
- 2:10and now my server should be ready in
- 2:12just a few seconds
- 2:14for logging into my server i will be
- 2:16using the terminal app so i'm gonna copy
- 2:18the ip address from here
- 2:21and in my terminal i will type ssh root
- 2:24add sign and then paste my ip address it
- 2:26is asking me whether or not i trust this
- 2:28server and i do so i will type yes
- 2:32and we are in
- 2:34[Music]
- 2:37i will head over to jesse's
- 2:38documentation environment setup ubuntu
- 2:42and copy the command for running the
- 2:44installation script for ubuntu 2004
- 2:48i will place it here and press enter the
- 2:50installation process is going to take
- 2:52approximately seven minutes so i will
- 2:55skip this video and come back when it's
- 2:56done all right at the end it will ask
- 2:59you whether or not you want to change
- 3:00your default shell to z shell and i will
- 3:03type y to say yes
- 3:06at this point you should have everything
- 3:07installed just to check we will type
- 3:09python3
- 3:11python
- 3:12uppercase v and yes the python version
- 3:14is correct then i'll do the same for pip
- 3:17and just to show you a list of the
- 3:19packages that this script installed for
- 3:21us i will type pip list
- 3:24a couple of useful packages are y
- 3:27finance talib stats models
- 3:31quant stats
- 3:33numpy
- 3:34pandas and more
- 3:36let's create a new jesse project by
- 3:38copying the command from the
- 3:39documentation website and paste it into
- 3:42the terminal
- 3:44then i will cd into my project
- 3:46and create a new environment file by
- 3:48typing cp.mv.example.mv
- 3:53by typing ls i will see all the existing
- 3:56files inside my project
- 4:00now remember this is a remote server so
- 4:03to edit the files that are in it
- 4:05typically i have to use an editor that
- 4:07is already installed on that server by
- 4:10default the nano editor is what is
- 4:12installed on these types of server but
- 4:14the problem with it is that it kind of
- 4:16sucks and is very hard to use what i'd
- 4:18like to do instead is to open these
- 4:21files inside an editor that i am already
- 4:23used to such as pycharm or vs code
- 4:26fortunately there is an extension for vs
- 4:28code called remote ssh that allows us to
- 4:31do exactly that so go ahead download and
- 4:34install vs code for your platform if you
- 4:36haven't already and then head over and
- 4:38open the extensions section
- 4:41and inside the search box type remote
- 4:44via ssh
- 4:46choose the first result and click on the
- 4:48install button
- 4:53all right now that we have the extension
- 4:55installed it's time to connect to our
- 4:57server to connect to your server open
- 4:59the command palette by pressing command
- 5:02shift and p on mac or if you are on
- 5:04windows press shift control np
- 5:08and enter ssh
- 5:12and choose add new ssh host
- 5:15here i will type ssh root add sign and
- 5:18then paste in the ip address of my
- 5:20server and choose the first address for
- 5:21saving the configurations everything
- 5:24looks good i'm gonna open the command
- 5:25palette one more time and this time
- 5:27choose connect to host and choose the ip
- 5:29address of my server
- 5:33everything looks good if i run the ls
- 5:35command you will see my project files
- 5:37i'm going to sit into my project
- 5:39all right so now what i want to see is
- 5:41the files of the project inside vs codes
- 5:44built in explorer to open the project
- 5:47directory inside vs code i will click on
- 5:49the open folder button and choose my bot
- 5:52directory and click on the ok button
- 5:56and i will say yes i do trust the others
- 5:58which is me
- 6:00and now i can actually edit the project
- 6:02files that are hosted on the remote
- 6:04server as if they were hosted on my
- 6:06local machine it feels the same i can
- 6:08just edit something press save and
- 6:11that's it
- 6:13[Music]
- 6:17this looks really good but one thing
- 6:19that we're still missing is auto
- 6:21completion for instance let's say that i
- 6:24want to use the
- 6:25size to quantity utility function of
- 6:27jesse for that i can say quantity equals
- 6:31utils dot and now if you had auto
- 6:34completion i would have seen the methods
- 6:36that exist inside the utils module so to
- 6:39enable auto completion i need to install
- 6:42an extension so i will open the
- 6:44extension panel and look up python and
- 6:47intellisense is the extension that i
- 6:49want
- 6:51so i'll go ahead and click on the
- 6:53install in ssh green button it should
- 6:56take a few seconds
- 6:59so now if i head back to my strategy
- 7:02file remove the dot and press it again i
- 7:05will get auto completion so i'm gonna
- 7:08choose size to quantity
- 7:10and give it 500 bucks and the entry
- 7:12price would be my current price which is
- 7:14self.price
- 7:17and change the quantity from one to the
- 7:20quantity variable
- 7:22so now the editor can understand my
- 7:24python code and is able to help me write
- 7:27my strategies faster than before
- 7:32to start jesse i will open the built-in
- 7:35terminal inside vs code and execute
- 7:37jesse run
- 7:40the reason i'm getting this error is
- 7:42because by default the environment file
- 7:44that we created by copying from the
- 7:46example file is set to work with docker
- 7:49so for a native environment setup like
- 7:51ours we need to set postgres and redis
- 7:54hosts into localhost those values
- 7:56already exist so all i have to do now is
- 7:59to comment this line and uncomment this
- 8:01one and i'll do the same for redis
- 8:04all right let's give this another try
- 8:07and this time we get the database is not
- 8:09ready and after 10 seconds it fails with
- 8:12an authentication error that's because
- 8:15even though the installer script that we
- 8:17used earlier installed postgres for us
- 8:20it didn't create a database user and
- 8:22password so let's head over to the
- 8:24documentation again and navigate into
- 8:27the environment setup and under ubuntu
- 8:31you will find the postgresql section and
- 8:34i can just copy and paste these commands
- 8:36inside my terminal to create a username
- 8:39database and password
- 8:48so if i execute the command one more
- 8:51time it should work
- 8:55here's something really interesting
- 8:57usually when you're using jesse on a
- 8:58remote server you must use your server's
- 9:01external ip address in order to access
- 9:03it but vs code can do something magical
- 9:05for you if you run the same command
- 9:07inside vs code's built-in terminal it
- 9:09will automatically bind your local ip
- 9:11address into the remote server's
- 9:13external ip
- 9:15so if inside my local browser i enter
- 9:18localhost with 9000 port it will open
- 9:21the dashboard of my remote server and
- 9:23it's really cool because it feels like
- 9:25you're running things on your local
- 9:27machine and to prove it to you that this
- 9:29dashboard is indeed running on the
- 9:31remote server i will open the about
- 9:33section and as you can see the operating
- 9:35system is linux while my local machine
- 9:38is a mac so that's how i know this for
- 9:40sure
- 9:41[Music]
- 9:44to install jupyter lab inside the
- 9:46server's terminal i will execute pip
- 9:48install jewfighter lab it's going to
- 9:51take several seconds and now we can
- 9:53start using it to insert jupyter lab i
- 9:56will execute jupyter
- 9:58hyphen
- 9:59lab
- 10:00it throws an error saying that running
- 10:02as root is not recommended but i don't
- 10:05really mind it so i'm going to skip it
- 10:06by using the allow root flag at the end
- 10:09of it and just like before vs code is
- 10:12going to do its magic thing and bind my
- 10:15local address into the external ip
- 10:17address of the server so if i copy this
- 10:19url and paste it into my browser i
- 10:22should be able to see my jupyter lab
- 10:24workflow
- 10:26let's create a notebook to execute some
- 10:28python code in case you're not already
- 10:30familiar with due python notebooks they
- 10:32are great for researching using python
- 10:34they allow you to write your code inside
- 10:37separate blocks and see the result right
- 10:39there to show you a good example of this
- 10:42inside this notebook i'm gonna import
- 10:44some candles using jesse's research
- 10:46module calculate the 50 period sma of
- 10:50those candles and display both of them
- 10:52on a chart first i'm going to import a
- 10:55few libraries that i need
- 10:57from date time import date time
- 11:01import
- 11:02matplotlib
- 11:04dot
- 11:05pi plot
- 11:07as plt
- 11:09this next line is not actually required
- 11:11but i'm gonna do it just to silent an
- 11:13annoying warning of pandas
- 11:17next i will import the research module
- 11:19from jessie and also jesus technical
- 11:21indicator module
- 11:23ptc candles echo
- 11:27research dot
- 11:29get candles
- 11:31the first parameter is exchange name
- 11:34which i will pass binance
- 11:36the second one is the symbol which i
- 11:39will pass btc
- 11:41usdt
- 11:43i will pass 30 minutes as a time frame
- 11:47and then i will pass a starting date
- 11:49i want 10 days of candles
- 11:52from 10th of november 2021 until 10 days
- 11:55later
- 11:57if i execute this
- 11:59i will get an error saying that candle
- 12:02not found in database the reason i'm
- 12:04getting this error is because i didn't
- 12:06import any candles with jesse
- 12:09so i'm going to create a new terminal
- 12:11window on my vs code
- 12:13and execute the jsu-run command to
- 12:16run the dashboard
- 12:19after entering my password and logging
- 12:22in
- 12:23i'm gonna navigate into the import
- 12:25candles page
- 12:27and choose binance as my exchange
- 12:30btc usct as my symbol
- 12:34and change the starting date to 9th of
- 12:36november which is one day before the
- 12:37actual date that i need just in case the
- 12:40importing process is going to take
- 12:42approximately five minutes so i'm going
- 12:44to skip the video and come back when
- 12:46it's done
- 12:47all right now that we have our candles
- 12:49let's head back to the jupiter lab and
- 12:51try executing that block of code one
- 12:54more time
- 12:56this time i didn't get any errors which
- 12:58means it worked
- 12:59next i want the moving average of these
- 13:01candles with the period of 50. i can get
- 13:04that by saying ta.sma
- 13:08and pass in my candles
- 13:10and the next parameter is the period and
- 13:13because i need all the moving average
- 13:14values and not just the last one i'm
- 13:17going to pass sequential equals true
- 13:20just to be sure i'm gonna print the
- 13:22values
- 13:24i can minimize the output if i don't
- 13:26need it anymore by clicking on the blue
- 13:29line
- 13:31inside the chart i'm going to need only
- 13:33the closing prices and not the whole
- 13:34candles so i need a numpy array of the
- 13:37closing prices only and since jesse's
- 13:39candles have the type of numpy array
- 13:42that's easy to do
- 13:47let's print it just to be sure the
- 13:49format is correct
- 13:51and minimize it
- 13:54all right now i have everything that i
- 13:56need for my charts except for timestamps
- 13:58we already have timestamps in our
- 14:00candles but they are in the integer
- 14:02format which isn't what the matplotlib
- 14:04library expects
- 14:06so i need to convert them into datetime
- 14:08objects
- 14:10to do that i'm going to create a python
- 14:12list named times and then loop through
- 14:15every single candle
- 14:17create new time date out of those
- 14:19milliseconds timestamps and store it
- 14:21inside the times list
- 14:28let's print it just to make sure the
- 14:29format is correct
- 14:34and finally we can display our chart i
- 14:36will start by setting the size of my
- 14:38chart a little bigger than the default
- 14:44and then i will start by plotting btc
- 14:46close prices
- 14:49i can do that by saying plt dot plot
- 14:53which is a function
- 14:55and then i pass my timestamps and then
- 14:58btc close prices
- 15:01and i set the color to orange
- 15:05and i set the label to
- 15:07btc
- 15:10next i will plot
- 15:12the 50 moving average
- 15:14by typing plt dot plot
- 15:19and then again i pass timestamps
- 15:22moving average values
- 15:24and i set the color to
- 15:26black and the label to
- 15:29sma 50
- 15:32and finally to display the chart i will
- 15:34say plt dot legend
- 15:38oops look like i forgot
- 15:40an equal sign
- 15:42i'm sure you guys saw it
- 15:44let's give it another try and this time
- 15:46it works as you can see we have a chart
- 15:48with btc prizes and the 50 moving
- 15:51average this was a simple example but it
- 15:54shows you how powerful this thing could
- 15:55be
- 15:58[Music]
- 16:00this tutorial is almost done but before
- 16:02i leave you guys i want to show you a
- 16:03common problem with this setup and the
- 16:05solution for it when running python
- 16:07processes like we just did whether using
- 16:09the terminal app or vs code's built-in
- 16:11terminal one common problem is that
- 16:14sometimes you close the terminal session
- 16:16whether intentionally or accidentally
- 16:18but the process keeps running in the
- 16:20background so the next time that you try
- 16:22to run the same command it will fail
- 16:24saying that the port is already in use
- 16:26by another process there are a couple of
- 16:28ways to solve this problem my solution
- 16:30is to use a tool called a screen which
- 16:32gives you better control over your
- 16:34terminal sessions here let me show you
- 16:37you can install a screen on your server
- 16:39by running
- 16:40apt install python y screen
- 16:45in my case it's already installed
- 16:48and now instead of executing jsu-run
- 16:50directly
- 16:51first i will create an end screen
- 16:53i can do that by saying screen
- 16:55python uppercase s and then i pass in a
- 16:59name
- 16:59which makes reattaching easier
- 17:02for this process i will name it jesse
- 17:04and now i'm actually inside a new screen
- 17:07window
- 17:08so if i execute jsurun in here
- 17:12and close my terminal windows entirely
- 17:15i can later on open another terminal and
- 17:17reattach to the same window and to do
- 17:20that i will execute a screen python r
- 17:23and passing the name of that window
- 17:25which was jesse and i can just continue
- 17:28as if i never close the terminal at all
- 17:31now let's create another terminal window
- 17:33for jupiter screen
- 17:36hyphen uppercase s
- 17:40and i will name it dewpiter
- 17:42and to run jupiter i will
- 17:44execute jupiter
- 17:47lab
- 17:50then again i have to pass the allow root
- 17:53flag
- 17:56and then i can copy and paste this url
- 17:58inside my browser to use jupyter but
- 18:01sometimes when you are running the
- 18:02process inside a screen window the port
- 18:05binding of vs code doesn't work anymore
- 18:07so what i can do here is to replace
- 18:10localhost with the external ip address
- 18:12of my server the reason this isn't
- 18:14working now is because when i started
- 18:16jupyter i didn't specify a host address
- 18:19specifically so by default it uses
- 18:21localhost but to access the application
- 18:23using an external address i need to
- 18:26either specify the ip address or to
- 18:28allow it to serve the application to all
- 18:30addresses i can pass in four zeros so
- 18:34i'm gonna stop the session inter y
- 18:36so this time after writing the same
- 18:38command
- 18:39i will pass in the ip option
- 18:41with the value of
- 18:43zero zero zero zero
- 18:47now it doesn't matter which url i copy
- 18:49because i will be changing the hostname
- 18:51either way
- 18:52now i'm gonna paste in the ip address of
- 18:55my server
- 18:57and this time it should work
- 19:01let's do the same for jesse's dashboard
- 19:04and it works perfectly that's it for
- 19:07this tutorial this was just about the
- 19:08installation of the remote dev
- 19:10environment if you want to see examples
- 19:12of me using jc's research module make
- 19:15sure to subscribe because i will be
- 19:17making videos about that thanks for
- 19:19watching
About this transcript
This page contains the full transcript of How to set up a remote dev environment for algo-trading with Python in VSCode by Algo-trading with Saleh, generated from the public captions YouTube serves with the video. The transcript has 2,975 words across 482 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.