YouTube2Text

Build a Trading Algo with AI | No Coding Required — Transcript

by Zerodha Varsity · 9,115 words · 1,464 segments · language en · Watch on YouTube

Full transcript

  1. 0:00I have been trading and investing since
  2. 0:022006.
  3. 0:04It's been a while and I've done all
  4. 0:06sorts of things in the market be it
  5. 0:08swing trading, intraday trading,
  6. 0:10investing, even mutual fund SIPs. But
  7. 0:13there's one thing that I've always
  8. 0:15wished I could do and that is algo
  9. 0:17trading. Although I understand what an
  10. 0:20algo is, I was never able to implement
  11. 0:23it on my own due to my inability to
  12. 0:26code. for anyone to develop an algo. To
  13. 0:28help me understand how I can develop my
  14. 0:31very first algo, I have my colleague
  15. 0:33Akshai here and he has promised me that
  16. 0:36he will teach me how to develop my very
  17. 0:38first algo using AI and of course using
  18. 0:41the APIs offered by your broker. So if
  19. 0:44you're like me wanting to learn how to
  20. 0:46develop an algo without knowing how to
  21. 0:49code, then go ahead, grab a cup of
  22. 0:51coffee, get your notebook and pen and
  23. 0:53we'll get started.
  24. 0:56All right, Akshai. Uh, so let's get
  25. 0:59started. Uh, but before we deep dive,
  26. 1:02tell me what is an ALGO?
  27. 1:05>> So, Karthik, an ALGO is basically a set
  28. 1:07of instructions, uh, trading
  29. 1:09instructions where you give it an input,
  30. 1:11which could be your data that you get
  31. 1:12from your broker and you get an output
  32. 1:15as a signal or you could automate it and
  33. 1:17it also places an order for you.
  34. 1:18>> Okay. Uh so depending on your use case
  35. 1:21an algo could be a fully automated algo
  36. 1:23or a semi-automated algo where you the
  37. 1:26trading is in basically in your control
  38. 1:27and you make a decision on the signal
  39. 1:30that you get.
  40. 1:30>> Can you very quickly give me an example
  41. 1:33of what an algo could be in terms of
  42. 1:36instructions? An algo can be something
  43. 1:38as simple as uh say buying like 200
  44. 1:41shares of Infosys if it if it uh if
  45. 1:44there's a moving average crossover
  46. 1:45happening or and even an RSI if there is
  47. 1:48an overbought and oversold level. Uh you
  48. 1:51could go long and short on any
  49. 1:53particular stock. So, not only can you
  50. 1:55take a decision on one stock, you could
  51. 1:57also use it to probably scan multiple
  52. 1:59stocks at the same time. And uh yeah,
  53. 2:01and basically refine your trading based
  54. 2:04on
  55. 2:05>> your correct me if I'm wrong. So, let's
  56. 2:07say I define my algo right now.
  57. 2:09>> I want to buy 100 shares of Reliance
  58. 2:13whenever HDFC moves above its 200 day
  59. 2:16moving average for whatever reason.
  60. 2:18>> Okay,
  61. 2:18>> that does that qualify as an algo? That
  62. 2:21is also technically possible
  63. 2:22[clears throat] if you have your rule
  64. 2:23set written in such a way that you know
  65. 2:26HDFC has to cross a particular level and
  66. 2:28you buy reliance for that.
  67. 2:29>> Okay. Because you said it's a bunch of
  68. 2:31instructions. It can it could be as
  69. 2:33wacky as this.
  70. 2:34>> But technically this is an algo also,
  71. 2:36right?
  72. 2:36>> Yes. Technically this would be an algo
  73. 2:38as well. So it just needs a set of
  74. 2:40instructions.
  75. 2:41>> Okay.
  76. 2:41>> Uh and if those instructions are met, if
  77. 2:43the rule set are met, it has a decision
  78. 2:45then to either go long or short on
  79. 2:47whatever decision you have made.
  80. 2:48>> Okay. All right. Aai. Now before we move
  81. 2:51ahead, I want you to reassure me once
  82. 2:53again that I don't have to know how to
  83. 2:56write a single line of code and yet
  84. 2:58build my first algo. Uh is that a
  85. 3:01definitive yes or a no?
  86. 3:02>> So I give a 100% promise that neither
  87. 3:06you nor I will be writing a single line
  88. 3:08of code.
  89. 3:08>> Okay.
  90. 3:09>> Uh we would orchestrate the entire algo
  91. 3:11using uh uh AI coding assistant that
  92. 3:14we'll be [clears throat] installing.
  93. 3:15>> Akshai. Now before we deep dive you also
  94. 3:17mentioned that there is something called
  95. 3:19as a semi-automated and fully automated
  96. 3:22algo. Now quickly can you please explain
  97. 3:25to me what do you mean by this and also
  98. 3:27tell me what is it that we are going to
  99. 3:29build today?
  100. 3:30>> Uh so an algo is basically your set of
  101. 3:32instructions that could give you a
  102. 3:34signal based on those instructions being
  103. 3:36met. Now in an automated algo uh the
  104. 3:39signals will be acted upon by the algo
  105. 3:41itself and to place the order but in a
  106. 3:43semi-automated uh case you would get the
  107. 3:45signals displayed to you as an alert and
  108. 3:47you would have to log into a trading
  109. 3:49terminal and then place the order
  110. 3:51manually yourself.
  111. 3:52>> All right. So basically in a
  112. 3:53semi-automated uh algo the end decision
  113. 3:56is upon me.
  114. 3:57>> Yes.
  115. 3:58>> So I the algo can suggest a signal but
  116. 4:00whether to take that signal and place
  117. 4:03the order the decision making is left to
  118. 4:05me.
  119. 4:05>> Yes. Whereas in a fully automated
  120. 4:07system, the algo takes that decision on
  121. 4:10on its own.
  122. 4:11>> Yeah.
  123. 4:11>> Right.
  124. 4:12>> Yeah.
  125. 4:12>> Super. And what are we going to build
  126. 4:14today?
  127. 4:15>> Uh so we would uh since we are doing
  128. 4:17this for the first time, I would suggest
  129. 4:19we start with a simple semi-automated
  130. 4:21system where
  131. 4:22>> uh we work on a daily time frame and
  132. 4:24generate a list of signals on list of
  133. 4:26stocks that are showing the signals for
  134. 4:28your trading idea. By the way, if you
  135. 4:31guys want us to demonstrate how you can
  136. 4:33generate a fully automated algo, then
  137. 4:35please do comment and maybe we can
  138. 4:38consider doing a separate video for
  139. 4:39that. Okay, Aai, now that you've given
  140. 4:42me some sense of what an algo is and how
  141. 4:44we are going to develop our first algo,
  142. 4:46uh can I define the algo that we want to
  143. 4:49develop and it's a fairly simple one.
  144. 4:52The idea is to scan all the top 100
  145. 4:54stocks of Nifty, basically the Nifty
  146. 4:56100, and generate a signal, bullish or a
  147. 5:00bearish signal, whenever the 6-day
  148. 5:02simple moving average crosses over a
  149. 5:0530-day simple moving average. Right? And
  150. 5:08when a signal is generated, I want the
  151. 5:10ALGO to list the signal in terms of its
  152. 5:14recency. Meaning if a signal if the
  153. 5:17crossover has happened yesterday in a
  154. 5:19particular stock I want the algo to give
  155. 5:22it the highest weightage
  156. 5:24>> as opposed to a signal that has happened
  157. 5:26let's say 2 weeks ago right so basically
  158. 5:29the most recent signal the algo assigns
  159. 5:33a higher weight so a this is the algo I
  160. 5:35have in mind can this be codified and we
  161. 5:39can put this in a form of algo and not
  162. 5:41just that I know we are using an AI tool
  163. 5:45Can we also do it in such a way that the
  164. 5:47entire algo is visually represented in a
  165. 5:51nice UI?
  166. 5:52>> Yeah. So that is actually a perfectly
  167. 5:54good example of uh first AL uh trading
  168. 5:57idea as well as how to visualize uh this
  169. 5:59trading idea in particular.
  170. 6:01>> Uh so yeah we can do it and I think we
  171. 6:03can get started with the process.
  172. 6:05>> Cool. So I'm fairly excited. Aai uh you
  173. 6:08please tell me what is the very first
  174. 6:10step that I need to take.
  175. 6:12>> Yeah. Uh so for the very first step we
  176. 6:14will install uh uh codeex which is
  177. 6:16CHGP's very own coding agent and we'll
  178. 6:19showcase its uh strengths in the sense
  179. 6:20that we would use it to install all the
  180. 6:23other tools that we need uh to build
  181. 6:25this algo. Yeah. So everything end to
  182. 6:27end would be done by the coding agent
  183. 6:28and we would uh in natural language uh
  184. 6:31prompt it to build our algo.
  185. 6:34>> All right. So as step number one we are
  186. 6:36installing codeex right?
  187. 6:37>> Yeah. Yeah. So let's start with
  188. 6:39installing uh codeex. Uh since it's a
  189. 6:41chatg product, we could just uh type
  190. 6:43chatgpt and codex on Google search and
  191. 6:46the first link is where we would have
  192. 6:49our download for our codeex. Yeah. So
  193. 6:51let's install it for Windows. Codex is
  194. 6:53also available for Mac OS as well. So
  195. 6:55since I'm using a Windows system, I'm
  196. 6:57just going to install it for Windows for
  197. 6:59now. Uh I'll run the Codex installer as
  198. 7:02well.
  199. 7:04And the installation should just take a
  200. 7:06couple of minutes.
  201. 7:10Now that we have Codex Karthik, I'll
  202. 7:12just open it and launch the app. A
  203. 7:14>> I'm looking at Codex for the very first
  204. 7:16time and to me it looks very similar to
  205. 7:18Chad GPT's uh user interface.
  206. 7:21>> Yeah, Karthik. So Codeex is basically a
  207. 7:25tool by the same uh company. Uh
  208. 7:28essentially it sits on your system and
  209. 7:30is able to interact and build files uh
  210. 7:32on your system directly. So it is a far
  211. 7:35more powerful tool than the chat GPD
  212. 7:37that we use on the browser.
  213. 7:39>> So Akai uh now that we've got codeex uh
  214. 7:42you've helped me understand the
  215. 7:44difference between what codeex is and
  216. 7:46chat GPT is uh so what is the next step?
  217. 7:50What should what should we do?
  218. 7:52>> Yeah. So with regards to building a
  219. 7:53semi-automated algo dashboard uh we have
  220. 7:56two prerequisites that we uh need to
  221. 7:58install. Uh the first tool that we'd
  222. 8:00like to install is Python which is the
  223. 8:02programming language
  224. 8:03>> on which you would write our rule set
  225. 8:05on.
  226. 8:06>> Uh the second tool that we'd like to
  227. 8:08install would be NodeJS.
  228. 8:10>> Okay.
  229. 8:10>> That would wrap around the algo and help
  230. 8:13visualize it in a cleaner and a more
  231. 8:15beautiful UI.
  232. 8:16>> Okay. So basically Python is our main
  233. 8:20programming language.
  234. 8:21>> Yeah.
  235. 8:21>> But just to clarify, we are not going to
  236. 8:23write a single line of code.
  237. 8:25>> Yeah. And uh Codex is going to do that
  238. 8:27for us. And we also have need this other
  239. 8:30tool called NodeJS to wrap a UI around
  240. 8:34whatever we are developing.
  241. 8:35>> Yes, that's exactly it.
  242. 8:36>> Okay, cool. Okay. So, how do we go about
  243. 8:39installing these uh utilities or tools?
  244. 8:42>> Yeah. So, let's use codeex itself to
  245. 8:46install everything that is required.
  246. 8:47It's a very simple prompt. It's like
  247. 8:48prompting how you would prompt in chart
  248. 8:50GPT. It's the same prompt that you would
  249. 8:52uh type here as well. Okay.
  250. 8:54>> So, let's start with Python first. So, a
  251. 8:56very simple prompt.
  252. 8:58>> Okay.
  253. 9:02[clears throat]
  254. 9:02>> A your prompt is can you install Python
  255. 9:05and add it to path?
  256. 9:07>> Yeah.
  257. 9:08>> What is this path and how would a
  258. 9:11non-programmer even know that this
  259. 9:13should be a specific instruction? So
  260. 9:16essentially adding it to path helps uh
  261. 9:19the operating system know that Python is
  262. 9:22available uh throughout the operating
  263. 9:24system. So any Python files we create uh
  264. 9:27if you were to open it it would open as
  265. 9:28a Python file and not as a text file.
  266. 9:31>> Okay. So for ease just add it to the
  267. 9:33path.
  268. 9:34>> Yeah.
  269. 9:34>> Right. Okay.
  270. 9:35>> Yeah. Okay.
  271. 9:37>> Uh yeah. So as you can see is launching.
  272. 9:40it has found the uh the installer itself
  273. 9:44>> and it has launched it by itself.
  274. 9:46>> Okay. So again it was a simple prompt
  275. 9:49that codeex is now taking over the
  276. 9:51system and doing
  277. 9:52>> I know I'm jumping ahead but when you
  278. 9:54said [clears throat] you need another
  279. 9:55utility called NodeJS
  280. 9:58>> is it going to be a similar path uh
  281. 10:00similar prompt wherein you say can you
  282. 10:02install NodeJS and add it to the path or
  283. 10:06or is it a different uh prompt
  284. 10:08>> here it would just be can you install
  285. 10:09NodeJS
  286. 10:10>> okay so no need of path
  287. 10:12>> no no need of path here Codex has
  288. 10:14finished installing Python let's go to
  289. 10:15the second utility ility which is
  290. 10:17NodeJS. So the same prompt again can
  291. 10:20install Node.
  292. 10:36Okay. So I see NodeJS is also being
  293. 10:38installed by Codeex. Uh as a quick
  294. 10:41summary so far we've first downloaded
  295. 10:43Codeex from Chad GPT. Then we asked
  296. 10:46Codex to download Python. And then after
  297. 10:50Python was installed, uh we asked Codex
  298. 10:53to install NodeJS.
  299. 10:55>> Yes.
  300. 10:55>> Right. Uh just for my uh understanding,
  301. 10:58this need not be in the same order. I
  302. 11:00can install NodeJS first and then do
  303. 11:02Python. Right.
  304. 11:03>> So there is no uh you know particular
  305. 11:06order for this. Uh so with this have we
  306. 11:10got all the prerequisites ready?
  307. 11:13>> Yeah. So we mostly have all the
  308. 11:14prerequisite that we need. Uh we have a
  309. 11:16little bit that we would also need to
  310. 11:18install which is uh your broker API.
  311. 11:21>> Okay.
  312. 11:21>> Uh so depending on which broker API you
  313. 11:23use, you could install the module for
  314. 11:25that API. Since we are using Zeroda
  315. 11:27Skite Connect here,
  316. 11:28>> okay,
  317. 11:28>> uh we would go ahead and prompt Codeex
  318. 11:30to install Zeroda Skite Connect module
  319. 11:32for us.
  320. 11:33>> Okay. Uh so this module that you're
  321. 11:35talking about Akai, uh is it again in
  322. 11:37the form of a prompt that we need to
  323. 11:39install?
  324. 11:40>> Yeah. So this module is for Python. Uh
  325. 11:42so very similar to how we installed
  326. 11:44Python and NodeJS, we can just prompt
  327. 11:47Codeex to install this module for us for
  328. 11:48Python.
  329. 11:49>> Okay.
  330. 11:50>> So I'll just go ahead and type that.
  331. 11:56A I see your prompt as can you install
  332. 11:59Kite Connect SDK for Python?
  333. 12:02>> Yeah.
  334. 12:02>> Uh I'm curious to know would codex know
  335. 12:05what kite connect is? Will it have the
  336. 12:07entire context uh for this particular
  337. 12:10installation?
  338. 12:11>> Yeah. So in this case since kite connect
  339. 12:13is a specific mod module uh built by
  340. 12:16zeroda itself uh codeex has context of
  341. 12:19what kite connect is uh and in this case
  342. 12:21is very easily able to install it by
  343. 12:23just this simple prompt. Yeah. Uh so
  344. 12:26yeah as you can see codex has installed
  345. 12:27kite connect python SDK.
  346. 12:30>> Okay. So now we have codeex we have
  347. 12:32python we have nodejs and we've also
  348. 12:34installed something called as kite
  349. 12:36connect python SDK.
  350. 12:38>> Yeah. uh we've still not yet developed
  351. 12:40our algo. What is the next step?
  352. 12:43>> Yeah. So uh now that we have installed
  353. 12:44kite connect successfully uh the next
  354. 12:47step is to uh create an application on
  355. 12:50zeroda's kite developer portal.
  356. 12:52>> Okay.
  357. 12:52>> Uh the application is something that
  358. 12:54zeroda would recognize and would then
  359. 12:57basically we create a connection between
  360. 12:59both.
  361. 13:00>> Okay. and we receive an incoming stream
  362. 13:02of data and also if we have to post
  363. 13:04requests for order placement or any
  364. 13:07other requests that we have uh we could
  365. 13:09do using this application. So Ashai the
  366. 13:11way I understand this is so on one side
  367. 13:14you've instructed codeex to install
  368. 13:17Python install NodeJS and also install
  369. 13:21the kite connect Python SDK so you've
  370. 13:24set up some sort of uh infrastructure
  371. 13:26there on the other side you spoke about
  372. 13:30uh setting up an application within the
  373. 13:32Zeroda environment
  374. 13:34>> right so I'm guessing once this
  375. 13:36application is set up you're going to
  376. 13:38link the two and start developing ing
  377. 13:40the algo is my thinking correct?
  378. 13:42>> Uh your so your thinking is called
  379. 13:44Karthik. Uh we just have to create an
  380. 13:47account on Zeroda Skype developer
  381. 13:49portal.
  382. 13:49>> Okay.
  383. 13:50>> Uh post which we'll be creating an
  384. 13:52application within it.
  385. 13:53>> Okay.
  386. 13:53>> This application is what Zeroda would
  387. 13:55recognize and uh there would be a stream
  388. 13:58of messages that would be sent back and
  389. 13:59forth between Zeroda and this ALGO that
  390. 14:01you'll be creating.
  391. 14:02>> Okay. Uh and this application is the
  392. 14:05algo that we would be creating, right?
  393. 14:06>> Yes, the application is the algo.
  394. 14:08>> Okay. All right. But uh that sounds
  395. 14:10exciting Akai. Although I've been using
  396. 14:12Zerodha for such a long time,
  397. 14:14>> I have never really logged into this
  398. 14:16developer account. Although I keep
  399. 14:18hearing developer account uh every now
  400. 14:20and then in the office. So yeah, so a
  401. 14:24little embarrassing but I I've never
  402. 14:25used it. So please please do show me how
  403. 14:28to set it up.
  404. 14:29>> Yeah, Karthik. So let's navigate to the
  405. 14:31Kite developer account.
  406. 14:32>> Okay.
  407. 14:32>> So as you can see here, since I already
  408. 14:34have an account, uh it's already
  409. 14:36prefilled my information. But uh if you
  410. 14:38are creating an account for the first
  411. 14:39time,
  412. 14:40>> I'm guessing it's a simple signup uh
  413. 14:42page.
  414. 14:43>> Exactly.
  415. 14:44>> Okay.
  416. 14:44>> Uh so for the first time, we could avoid
  417. 14:47the IP white list since it's not starred
  418. 14:49as well.
  419. 14:50>> Okay.
  420. 14:50>> We can avoid this section
  421. 14:52>> and fill the rest of the sections here.
  422. 14:54>> Okay. Because I don't know what IP
  423. 14:56whitelist means. Uh
  424. 14:58>> uh as you may have realized, I'm a
  425. 15:00complete tech idiot. So So I don't know
  426. 15:03what IP whitelist is. But you're saying
  427. 15:04I can ignore this for now. Yeah, you can
  428. 15:06ignore this for now and towards the end
  429. 15:08we'll probably discuss what the IP
  430. 15:10whitelisting bit is.
  431. 15:11>> Okay, go ahead.
  432. 15:12>> So yeah, uh after logging into our
  433. 15:14developer account, this is how the page
  434. 15:16looks. Okay,
  435. 15:16>> so you have a tab for your apps,
  436. 15:18billing, a profile, forum, uh where uh
  437. 15:22there are discussions happening
  438. 15:23regarding APIs.
  439. 15:24>> Okay.
  440. 15:25>> Uh for now, let's start with creating
  441. 15:26our app first.
  442. 15:27>> Okay.
  443. 15:28>> So let's create an app.
  444. 15:29>> Okay.
  445. 15:30>> Uh so we see a couple of types here. For
  446. 15:32now, we can ignore personal and
  447. 15:33publisher.
  448. 15:34>> Okay. Since our algo requires historical
  449. 15:36data, we would have to go with the
  450. 15:39connect type. So connect requires 500
  451. 15:41credits which is equivalent to 500
  452. 15:42rupees and this gives us access uh to
  453. 15:45historical data as well as live market
  454. 15:47data.
  455. 15:48>> Okay.
  456. 15:48>> Uh this is charged per month. So that's
  457. 15:51500 credits for 30 days.
  458. 15:53>> So this is 500 rupees uh equivalent to
  459. 15:55500 rupees per month. Okay. This is
  460. 15:57>> so yeah a so basically what you're
  461. 15:59saying is we need to use connect because
  462. 16:03uh it has access to historical data
  463. 16:05which is exactly what we need for this
  464. 16:08particular algo.
  465. 16:09>> Yeah
  466. 16:10>> because we are scanning uh the crossover
  467. 16:12for the nifty 100 stocks the 6 day
  468. 16:16simple moving average versus 30-day
  469. 16:17moving average and how back in history
  470. 16:20are we going back for this? Uh so for
  471. 16:23this pit for our current algo we are not
  472. 16:25going too far back in history. Okay.
  473. 16:27>> Uh but the available data that we have
  474. 16:29here can go scan as far back as the
  475. 16:32stock's inception.
  476. 16:33>> Okay.
  477. 16:34>> So um
  478. 16:35>> uh so it is going to give me all the
  479. 16:37historical data. Uh if I'm thinking
  480. 16:40right this will be particularly useful
  481. 16:43if I have to back test strategies.
  482. 16:45>> Yeah. So this would be particularly
  483. 16:47useful if you want to back test
  484. 16:48strategies at a larger time frame.
  485. 16:50>> Okay. So let's start with an application
  486. 16:52name. Is there any name that you'd want
  487. 16:54to give for this algo?
  488. 16:56>> I'll be super imaginative. I'll call it
  489. 16:58my first algo.
  490. 17:00>> All right, that works.
  491. 17:02>> So my first algo.
  492. 17:04>> Okay.
  493. 17:05>> Uh and
  494. 17:07I'll add the zeroda client ID. So this
  495. 17:11is your zeroda's client ID that you
  496. 17:14have.
  497. 17:14>> Okay.
  498. 17:15>> So I'll add that as well.
  499. 17:16>> Okay.
  500. 17:17>> Um so now before Yeah. So now the next
  501. 17:20field that is required is the redirect
  502. 17:22URL.
  503. 17:22>> One one second. There is an app icon. Is
  504. 17:25it uh needed?
  505. 17:27>> An app icon is technically not needed.
  506. 17:29>> It's uh depending on whether you want to
  507. 17:32add an application icon as well.
  508. 17:34>> You could do it.
  509. 17:35>> Okay.
  510. 17:35>> Uh but for now we could ignore the app
  511. 17:37icon and also the postback URL.
  512. 17:39>> Okay.
  513. 17:40>> Uh the next field that we'd have to fill
  514. 17:41up here is the redirect URL. Okay. So
  515. 17:43the redirect URL is basically when you
  516. 17:45log to your application uh you would
  517. 17:49need a request token. Uh we would come
  518. 17:52to this in the authentication bit. Uh
  519. 17:54but for now all you need to know is that
  520. 17:56the redirect URL can be anything simple.
  521. 17:58It could be uh in our case we could also
  522. 18:01put google.com.
  523. 18:03>> Okay.
  524. 18:04>> So a very simple redirect URL. So I'll
  525. 18:06add that here.
  526. 18:07>> Okay.
  527. 18:08>> Uh and then a description for this algo.
  528. 18:10So maybe I can add your uh trading idea
  529. 18:14itself. So maybe u moving
  530. 18:18average
  531. 18:20cross.
  532. 18:23So a very simple description here.
  533. 18:25>> Okay. So redirect URL you've said
  534. 18:27google.com. So u you will have to
  535. 18:30explain
  536. 18:32maybe at a later stage uh why this is
  537. 18:35needed and what what actually should go
  538. 18:38in there. But we'll pick it up later.
  539. 18:40>> Okay.
  540. 18:40>> Um All right. So, so far it's pretty
  541. 18:44straightforward.
  542. 18:45>> Yeah. So, let's go ahead and create our
  543. 18:47application.
  544. 18:49>> Uh you would have to enter the I
  545. 18:51understand prompt here.
  546. 18:55>> Okay.
  547. 18:56>> And once you do so it there is a prompt
  548. 18:59here saying insufficient balance.
  549. 19:01>> Okay.
  550. 19:01>> Uh which is where we'd have to go to a
  551. 19:03billing account.
  552. 19:04>> Okay.
  553. 19:04>> Uh let's just go to our my apps and
  554. 19:06confirm. So you can see here your my
  555. 19:08first ALGO is created
  556. 19:09>> but the status says here as pending.
  557. 19:11>> Pending. Okay.
  558. 19:12>> So let's quickly go to the billing
  559. 19:14section
  560. 19:15>> and add 500 credit. So there are a
  561. 19:17couple of ways that you could add
  562. 19:18credits.
  563. 19:18>> Okay. It's a straightforward payment. Uh
  564. 19:21>> exactly. So you have a straightforward
  565. 19:23payment uh section or you could directly
  566. 19:25link it to your kite account that you
  567. 19:27already have
  568. 19:28>> and uh depending on whether you have 500
  569. 19:31rupees available in that account or not.
  570. 19:32Okay.
  571. 19:32>> You could directly add credits from
  572. 19:34there as well.
  573. 19:34>> Okay. Uh so for this example, I'll just
  574. 19:36use a payment gateway and add credits.
  575. 19:39>> Okay.
  576. 19:43>> Yeah. So as you can see, payment is
  577. 19:45successful. Our credits have been added
  578. 19:46here.
  579. 19:47>> Uh let's quickly go back to my apps. Uh
  580. 19:50go to our first algo here and we can
  581. 19:53activate it right now. So I'll just
  582. 19:54click activate now.
  583. 19:55>> Okay.
  584. 19:56>> And similarly, I'll just put
  585. 20:01the I understand prompt.
  586. 20:03>> Okay.
  587. 20:04Uh yeah.
  588. 20:08So yes, we have activated our first Algo
  589. 20:10application.
  590. 20:11>> Okay.
  591. 20:11>> Uh it tells us when it expires, so 30
  592. 20:14days from now.
  593. 20:14>> Okay. [clears throat]
  594. 20:15>> And these are the app details here
  595. 20:18>> that we filled in earlier.
  596. 20:20>> Okay.
  597. 20:20>> Now this is our application and our
  598. 20:22application has uh a couple of
  599. 20:25credentials that are unique only to this
  600. 20:28application and these are credentials
  601. 20:30that technically you should not share
  602. 20:31with anyone else. Uh so on one side
  603. 20:34you've set up the uh codeex and python
  604. 20:36and nodejs infra. So that was let's look
  605. 20:39at it as part a part b you've come to
  606. 20:42the zeroda environment and you've set up
  607. 20:44a application.
  608. 20:46>> Yeah.
  609. 20:46>> Uh you've we've called it my first algo.
  610. 20:49>> Uh after successfully creating it uh we
  611. 20:52are looking at something called as an
  612. 20:54API key and I know that there is
  613. 20:57something else called as API secret.
  614. 21:00>> Yes. Right. So
  615. 21:03is this uh is the API key and the API
  616. 21:06secret like my login ID and password uh
  617. 21:10is that correct? Is my understanding
  618. 21:11correct?
  619. 21:12>> Yeah. So the API key and API secret
  620. 21:15basically allows Zerodha's ecosystem to
  621. 21:17recognize that this application is
  622. 21:19trying to connect to Zeroda's APIs.
  623. 21:22>> Okay.
  624. 21:22>> So your API key is like your username
  625. 21:25>> and your API secret is like your
  626. 21:26password.
  627. 21:27>> Okay. uh apart from these two
  628. 21:29credentials you have one more credential
  629. 21:31that you will request from Zeroda itself
  630. 21:34and that is your session that that is
  631. 21:36called an access token. So that access
  632. 21:37token keeps your session alive for 24
  633. 21:40hours.
  634. 21:41>> Okay. Okay.
  635. 21:42>> So for now for just this process uh
  636. 21:45let's quickly save the API key since we
  637. 21:47don't want to keep coming back and forth
  638. 21:49on the developer account.
  639. 21:50>> We can save the API key and the API
  640. 21:52secret in a text file and save it in a
  641. 21:54folder which where we'll be working on.
  642. 21:57>> Okay. So I'll quickly create a new
  643. 21:59folder.
  644. 22:02So I'm creating a new folder. Is there a
  645. 22:04name that you'd want to call this
  646. 22:05folder?
  647. 22:06>> Uh let's call this folder my first algo
  648. 22:09itself. Again very imaginative.
  649. 22:13>> Yeah.
  650. 22:13>> Right. So this folder is created on the
  651. 22:15desktop. Uh I'll just quickly open it.
  652. 22:18>> Uh the folder is completely empty right
  653. 22:20now.
  654. 22:20>> Okay. Okay. Uh what I'll do is I'll
  655. 22:22create a new text file
  656. 22:26and call it credentials.
  657. 22:29>> Yeah, since we are doing it at a
  658. 22:30beginner uh state.
  659. 22:32>> Okay.
  660. 22:32>> We'll save our credentials in a
  661. 22:33[clears throat] text file. Ideally, a
  662. 22:35more robust way of saving it would be an
  663. 22:37env file where it's not technically
  664. 22:39visible directly.
  665. 22:42>> Yeah. So, let's save the credentials in
  666. 22:43the cred the text file. So,
  667. 22:45[clears throat] our API key here
  668. 22:55and our API secret as well.
  669. 23:07So, I'm saving both and
  670. 23:09I [clears throat] have saved them to
  671. 23:10this text file in the my algo folder. My
  672. 23:13first Algo folder. Yeah, just to
  673. 23:15reconfirm
  674. 23:18for a non-programmer like me, the way I
  675. 23:20understand this is the API key and the
  676. 23:22API secret uh is as sacred as your
  677. 23:26bank's user ID password. So, utmost
  678. 23:29caution has to be exercised while uh
  679. 23:32saving it on system and um uh and even
  680. 23:36sharing it with others. Right.
  681. 23:37>> 100%. Yeah.
  682. 23:38>> Okay.
  683. 23:40>> So now I have saved the API key and the
  684. 23:42API secret in a text file.
  685. 23:44Now we are good to start developing our
  686. 23:46algo.
  687. 23:46>> So for the first step what we do is we'd
  688. 23:48go back to codeex again.
  689. 23:50>> Okay.
  690. 23:51>> Uh in the same chat or you could create
  691. 23:53a new chat.
  692. 23:54>> You could give it the location of where
  693. 23:56your folder is. So I'll just copy the
  694. 23:58location here.
  695. 23:59>> Okay.
  696. 24:00>> And
  697. 24:02uh and again a simple prompt I'll ask
  698. 24:04can
  699. 24:05>> can we start a fresh chat just to uh
  700. 24:07>> yes
  701. 24:08>> uh start from like a clean slate.
  702. 24:11>> Sure.
  703. 24:11>> Okay. So we could start a new chat
  704. 24:13directly. So in the same uh chat
  705. 24:16>> I could I'll just put a prompt saying
  706. 24:19can you
  707. 24:21in this folder?
  708. 24:31Yeah. So I'm prompting codeex to now
  709. 24:33work in the folder that we just created.
  710. 24:36>> Okay. [clears throat]
  711. 24:46All right. So as you can see codeex is
  712. 24:48now going to work in this folder and
  713. 24:50it's also told us that it currently
  714. 24:52contains a credentials.ext.
  715. 24:54>> Okay.
  716. 24:54>> Uh now for the final bit about of the
  717. 24:57application is uh our login for this
  718. 25:00application will have a separate URL.
  719. 25:02>> Okay.
  720. 25:02>> And that URL will remain constant
  721. 25:04throughout.
  722. 25:04>> Okay. So we would first ask Codex to
  723. 25:07generate that URL for us and and we'd go
  724. 25:10ahead and bookmark that URL for future
  725. 25:12use as well.
  726. 25:13>> Okay.
  727. 25:13>> So a simple prompt here again. Can you
  728. 25:17give me the guide? Okay.
  729. 25:21Um based on
  730. 25:27yeah so I'm asking Codeex to give me the
  731. 25:29login URL here.
  732. 25:30>> Okay.
  733. 25:39So is this step basically
  734. 25:42uh asking codeex to connect to kite?
  735. 25:44>> Yes. So this is a step that's basically
  736. 25:47asking codeex to connect to our
  737. 25:49application uh URL.
  738. 25:52>> So as you can see here uh much of the
  739. 25:55URL is the same. The only bit that will
  740. 25:58change across uh different applications
  741. 26:00is your API key here. Okay. So this is
  742. 26:02the API key that was there for my
  743. 26:03application.
  744. 26:04>> Okay.
  745. 26:05>> So I'll just copy this URL.
  746. 26:08I'll go back to my browser. Paste it
  747. 26:11here.
  748. 26:12>> Now this URL you could bookmark since
  749. 26:14this URL doesn't change.
  750. 26:16>> Okay.
  751. 26:17>> Uh yeah. So you have to authorize the
  752. 26:20application.
  753. 26:22Yeah. So now that I've logged in,
  754. 26:25>> uh it has taken me to google.com.
  755. 26:28>> Uh now I'll probably explain the
  756. 26:30redirect URL. So the redirect URL of
  757. 26:32this application takes me to google.com.
  758. 26:35>> Along with that URL, there is certain
  759. 26:37extra information that is given here.
  760. 26:39>> Okay.
  761. 26:39>> As you can see,
  762. 26:40>> right?
  763. 26:41>> Uh the information that we require is
  764. 26:42the request token here.
  765. 26:44>> Okay. Okay.
  766. 26:44>> Uh so the request token is this block of
  767. 26:47text here
  768. 26:48>> that is between the request token and
  769. 26:51the and that is there here.
  770. 26:53>> Okay. Okay.
  771. 26:53>> So let's just quickly that is the
  772. 26:56request token that is there.
  773. 26:58>> Okay. Now that we have reached the step,
  774. 27:00we can now finally start building the
  775. 27:01algo.
  776. 27:02>> Okay. Uh
  777. 27:03>> but what are you going to do with that
  778. 27:05request token? Do we have to paste it in
  779. 27:07the credential file or
  780. 27:09>> No, no, no. We would not be pasting it
  781. 27:10in the credential file.
  782. 27:11>> Now that we're building our UI uh in the
  783. 27:14UI itself, we'll add our login uh
  784. 27:16portal.
  785. 27:17>> Okay. A so what we've done so far is
  786. 27:20we've built the uh infrastructure, the
  787. 27:23railroads required to develop our first
  788. 27:26algo. All the things that we've done
  789. 27:27with codeex, all the things that we've
  790. 27:29done on the zeroda kite connect
  791. 27:31environment, they're all the basic uh
  792. 27:34you know background work
  793. 27:36>> but we've still not developed a single
  794. 27:38line of code or rather we've still not
  795. 27:40asked codeex to you know write a single
  796. 27:43line of code uh and start developing the
  797. 27:46algo. Uh so have we reached that point
  798. 27:49or is there something more that needs to
  799. 27:51be done?
  800. 27:52>> No, we have reached that point now. We
  801. 27:54have done with everything that was
  802. 27:55required. uh we can start building our
  803. 27:57algo right now.
  804. 27:58>> Okay.
  805. 27:58>> So let's go back to codeex and prompt it
  806. 28:00to start building our algo.
  807. 28:01>> Okay.
  808. 28:02>> So now we can start building our algo.
  809. 28:04>> Okay.
  810. 28:04>> So I already have a prompt to build the
  811. 28:07algo.
  812. 28:08>> Okay.
  813. 28:08>> So I'm just going to paste that here in
  814. 28:09chat and ask codeex to build the algo.
  815. 28:12>> Okay. Now Akai, now before you hit enter
  816. 28:15and uh CEX starts doing its thing, uh
  817. 28:19please take me through this prompt line
  818. 28:21by line. What is it uh that you've
  819. 28:24you're asking Codex to build? I'm
  820. 28:26guessing this is the uh the heart of the
  821. 28:29algo engine that we are building, right?
  822. 28:31>> Yes. Yes.
  823. 28:33>> Yeah. So, please uh take me through it
  824. 28:35line by line.
  825. 28:36>> So, the prompt is basically asking Codex
  826. 28:38to build a single Python file.
  827. 28:40>> Okay.
  828. 28:41>> Which would run which would be our algo
  829. 28:42that we'd run.
  830. 28:43>> Okay.
  831. 28:44>> Uh so, the first thing it would do is it
  832. 28:45would au authenticate
  833. 28:47>> using the API key and the API secret.
  834. 28:49>> Okay. I will also be giving it the
  835. 28:51request token that we had from the URL
  836. 28:53earlier
  837. 28:54>> uh to get the access token.
  838. 28:56>> Uh post the authentication it would
  839. 28:58download the nifty 100 constituents.
  840. 29:00>> Okay.
  841. 29:01>> And get the instrument symbols from uh
  842. 29:04zeroda's API uh for instruments.
  843. 29:07>> Okay.
  844. 29:07>> Uh post that the next line is that it
  845. 29:09fetches the daily historical data. It
  846. 29:11then calculates the SMA 6 and SMA 30 for
  847. 29:14the all the stocks that we are
  848. 29:16>> compiling. uh it would then detect a
  849. 29:18bullish and bearish crossover and then
  850. 29:20rank them by the most recent crossover
  851. 29:22dates.
  852. 29:23>> Okay.
  853. 29:23>> So this is what it's doing at the
  854. 29:24background. It's output that it will
  855. 29:27have is it would rank the stocks.
  856. 29:29>> Okay.
  857. 29:29>> It would show us the symbol. Uh it would
  858. 29:32show the signal type the crossover date
  859. 29:34based on recency.
  860. 29:35>> Okay.
  861. 29:36>> Uh and the close price SMA 6 and SMA 30
  862. 29:39as well.
  863. 29:39>> Yeah. So just to get my understanding
  864. 29:42correct
  865. 29:44you are essentially [clears throat] now
  866. 29:46connecting to the zeroda kite ecosystem
  867. 29:50uh and now I understand uh why you said
  868. 29:52we need kite connect because you're
  869. 29:54asking it to download historical data.
  870. 29:57>> Yeah.
  871. 29:57>> So on one hand it is fetching all the
  872. 30:00data then it's also doing the math
  873. 30:03required to identify the crossover.
  874. 30:05>> Yes.
  875. 30:05>> Right. And you're also specifying a
  876. 30:08certain format in which you want the
  877. 30:10output in.
  878. 30:12>> So, so yeah. So, this is the meat of the
  879. 30:14algo, right?
  880. 30:15>> Yes.
  881. 30:16>> Okay. So, yeah, super curious. Why don't
  882. 30:18you hit that enter button?
  883. 30:20>> Uh, so right before we hit it, I'll just
  884. 30:22give it the request token that is
  885. 30:23required.
  886. 30:24>> Okay.
  887. 30:25>> So, going back to the redirect URL that
  888. 30:26was there earlier, let's just copy the
  889. 30:28request token as well.
  890. 30:30>> Okay.
  891. 30:31>> And I'll copy this bit.
  892. 30:34let codeex know that this is the request
  893. 30:36token.
  894. 30:37>> Okay.
  895. 30:42>> And let's hit enter.
  896. 30:45>> Okay.
  897. 30:46>> While Codex does whatever it's supposed
  898. 30:48to do, Ashai, uh what if I have a
  899. 30:50different algo in mind? What if the user
  900. 30:52has a different algo?
  901. 30:53>> Yeah.
  902. 30:54>> Uh it could be based on uh technical
  903. 30:57analysis, it could be based on
  904. 30:59>> uh I don't know standard deviations or
  905. 31:01whatever. So how can they go about
  906. 31:05building an algo uh using whatever setup
  907. 31:09you've shown us?
  908. 31:10>> Yeah. So the the beauty of Python and
  909. 31:13along with Codex is that uh almost all
  910. 31:16of the technical indicators this
  911. 31:18includes even candlestick patterns uh
  912. 31:20and the entire vastness of the technical
  913. 31:22indicators everything is available as
  914. 31:24modules in Python.
  915. 31:25>> Okay.
  916. 31:26>> Uh and Codex is smart enough to have
  917. 31:28known what your context is. So if you
  918. 31:31give it if your idea requires
  919. 31:34candlestick patterns,
  920. 31:36>> if your prompt involves candlestick
  921. 31:37patterns, it knows where which module to
  922. 31:40pull.
  923. 31:40>> Okay.
  924. 31:40>> So if the module isn't installed, it'll
  925. 31:42go ahead and install it.
  926. 31:43>> Okay.
  927. 31:44>> Uh but the entire vastness of technical
  928. 31:46analysis is possible using codeex and
  929. 31:48Python.
  930. 31:48>> Okay. Now for example, let's say I have
  931. 31:50a different algo in mind.
  932. 31:52>> Uh I want to download the historical
  933. 31:54data of um of Niftyund stocks. I want to
  934. 31:59calculate the returns of these stocks
  935. 32:02>> then based on the returns I want to plot
  936. 32:05the standard deviation
  937. 32:07>> and I want to identify the return which
  938. 32:10is at let's say the third or third
  939. 32:12standard deviation
  940. 32:14>> plus three standard deviation short
  941. 32:16those
  942. 32:17>> and go long on the minus three standard
  943. 32:19deviations something as quantitative as
  944. 32:22this can also be codified and an algo
  945. 32:25can be developed right
  946. 32:26>> yes it can very easily be developed In
  947. 32:28fact, all of this can be done in the
  948. 32:29same natural language that you're
  949. 32:31speaking
  950. 32:32>> if you were to prompt it in the same
  951. 32:33way. Codex would be able to build it
  952. 32:35completely uh end to end.
  953. 32:38>> So technically this uh I I I remember
  954. 32:41reading this tweet somewhere.
  955. 32:44>> The most powerful language today,
  956. 32:45programming language today is English.
  957. 32:48>> Yeah.
  958. 32:48>> Right. So as far as I can creatively
  959. 32:51express my algo
  960. 32:53>> in plain simple English natural language
  961. 32:56I should be able to develop any algo.
  962. 32:58>> Yes. In [clears throat] fact the more
  963. 33:00detailed you are in your uh in in our
  964. 33:02earlier prompt that we had
  965. 33:04>> uh not only did we tell it what to do we
  966. 33:06also gave it how the output should look.
  967. 33:08>> So the more detail you add to your
  968. 33:10prompt in what you want the algo to do
  969. 33:12uh the better it is.
  970. 33:13>> Okay. So so far from whatever I've seen
  971. 33:17uh I think the uh the difficult part I I
  972. 33:21wouldn't even call it difficult but uh
  973. 33:23for most common people
  974. 33:25>> uh including uh like someone like me who
  975. 33:28has zero tech idea
  976. 33:30>> I think the the confusing or the
  977. 33:32difficult part is to set up the initial
  978. 33:35infrastructure needed uh this is right
  979. 33:38from in installing codeex
  980. 33:40>> python uh NodeJS and on the the side
  981. 33:44setting up the entire kite
  982. 33:46>> uh you know kite connect ecosystem once
  983. 33:49the infrastructure is set
  984. 33:51>> I think the other things are fairly easy
  985. 33:53to do right the the defining of the algo
  986. 33:56itself is fairly easy
  987. 33:57>> yes so once your infra is set up the
  988. 34:00rest of use the usage of API is actually
  989. 34:02very easy
  990. 34:02>> the API the documentation is already
  991. 34:04available everything is built around the
  992. 34:06ease of usage
  993. 34:08>> okay
  994. 34:09>> yeah so as you can see here the the
  995. 34:12codeex has built the script here.
  996. 34:13>> Okay,
  997. 34:14>> I'll quickly just open the script.
  998. 34:16>> Wait, so are you telling me this is my
  999. 34:18algo?
  1000. 34:19>> Yeah. So, this file here
  1001. 34:21>> is now your algo.
  1002. 34:23>> Okay.
  1003. 34:23>> So, it's an SMA scanner.
  1004. 34:27>> Yeah. So, this is how your algo looks.
  1005. 34:29>> Okay.
  1006. 34:30>> It's a lot of lines.
  1007. 34:32>> This is uh super scary to me. Uh you're
  1008. 34:35just showing me
  1009. 34:37>> lines and lines of code that C codeex
  1010. 34:40has beautifully written. I have I have
  1011. 34:42zero technical idea to even verify
  1012. 34:46whether this is correct or wrong
  1013. 34:48>> but a to me
  1014. 34:51>> while this is fancy this is not usable
  1015. 34:54to me uh I can't I can't I'm not capable
  1016. 34:57enough to figure out if these lines are
  1017. 35:00correct code you know I can't do it so
  1018. 35:04>> unless and until you put this in a nice
  1019. 35:06UI
  1020. 35:09>> this is I I can't use this. So, can we
  1021. 35:12wrap up uh wrap around it a nice UI?
  1022. 35:15>> Yeah. So, now that we have built this,
  1023. 35:17we could build the same thing
  1024. 35:20>> in a more useful.
  1025. 35:22>> Why don't you close this? It is scaring
  1026. 35:23me.
  1027. 35:23>> Yes. So, I'll start by doing that.
  1028. 35:26>> So, yeah, you don't have to see these
  1029. 35:27scary lines of code. Uh let's wrap the
  1030. 35:30entire algo in a nice good UI.
  1031. 35:33>> Okay.
  1032. 35:33>> Uh so, we'll break down the UI in three
  1033. 35:35prompts and we'll slowly build the
  1034. 35:37entire dashboard that we are going for.
  1035. 35:39>> Okay. Uh so let's start with the first
  1036. 35:42prompt. Okay.
  1037. 35:42>> I already have the prompts uh
  1038. 35:44pre-written.
  1039. 35:45>> So I'll just paste them here.
  1040. 35:49>> Yeah. So this is the prompt. Uh as you
  1041. 35:51can see here in the prompt, there are a
  1042. 35:53couple of tools that we did not install
  1043. 35:56uh initially.
  1044. 35:57>> Okay.
  1045. 35:58>> Um which is react and beat.
  1046. 36:00>> Uh in this case, Codex would recognize
  1047. 36:02that these tools are not available
  1048. 36:04>> and it would install it by itself.
  1049. 36:06>> One second. So uh so your prompt says
  1050. 36:10build a React plus wheat front end. So
  1051. 36:14for non-programmers like me, how would I
  1052. 36:16even know that you need something like
  1053. 36:19React and Wheat to build a UI
  1054. 36:22>> or now that you've said it, is it a good
  1055. 36:25practice to always prompt saying that
  1056. 36:28build a UI using React and Wheat? Oh
  1057. 36:31>> yeah. So the reason why I've chosen
  1058. 36:33react and wheat is the front end looks
  1059. 36:35really beautiful when you use uh
  1060. 36:37JavaScript.
  1061. 36:38>> Okay.
  1062. 36:38>> Uh if you hadn't prompted Codeex uh to
  1063. 36:41build it in using React and it would
  1064. 36:44probably use a module from Python and do
  1065. 36:46the same as well.
  1066. 36:47>> Okay.
  1067. 36:47>> Uh just that the front end would not
  1068. 36:48look as beautiful as it would with this.
  1069. 36:51>> Okay. Can I generalize it this way that
  1070. 36:53whenever I'm trying to build a UI,
  1071. 36:56>> I need to use React and Wheat to make it
  1072. 37:00look beautiful. Is it a fair
  1073. 37:02generalization?
  1074. 37:02>> That is a fair generalization to use
  1075. 37:05React and V to make the front [snorts]
  1076. 37:06end more beautiful
  1077. 37:08>> and as we build this app you will
  1078. 37:10realize how uh goodlooking the UI can
  1079. 37:13be.
  1080. 37:13>> Right. It better be good-looking.
  1081. 37:14>> Yeah. [laughter]
  1082. 37:16>> Okay.
  1083. 37:16>> So yeah so the front end which is the UI
  1084. 37:19bit is using React and we
  1085. 37:22>> for the back end we are using Python
  1086. 37:23itself. Uh particularly a module called
  1087. 37:26fast API. Again, uh since fast API
  1088. 37:28wasn't installed at the start, uh Codex
  1089. 37:30will recognize the lack of this module
  1090. 37:32and install it by itself.
  1091. 37:33>> Yeah, by the way, for all the people
  1092. 37:36watching this, all the prompts we've
  1093. 37:39used, we will put it up in the
  1094. 37:40description. So, it's it will be easily
  1095. 37:42available for you all. So, don't get
  1096. 37:45stressed uh you know about not seeing
  1097. 37:47the prompt fully clearly at this point.
  1098. 37:50You can always check on the description.
  1099. 37:52Why don't you hit that enter button and
  1100. 37:54let's see what happens. Uh sure Karthik
  1101. 37:58>> a so typically how long does it take CEX
  1102. 38:01to build a nice UI?
  1103. 38:03>> Um so depending on your tasks it could
  1104. 38:06take uh a simple prawn could take a
  1105. 38:08couple of seconds.
  1106. 38:09>> Okay.
  1107. 38:09>> Uh but if you're trying to build
  1108. 38:11something large and has multiple moving
  1109. 38:13parts then it could take uh anywhere
  1110. 38:15from a couple of minutes to probably 10
  1111. 38:18plus minutes as well.
  1112. 38:19while this does whatever it's doing
  1113. 38:23to I just wanted to touch upon the cost.
  1114. 38:26So firstly we spent 500 rupees for
  1115. 38:30against 500 credits for kite connect. So
  1116. 38:32that's on the
  1117. 38:33>> uh API side of things.
  1118. 38:35>> Yes.
  1119. 38:36>> Uh are you using I should have asked
  1120. 38:38this before but are you using a free
  1121. 38:40version or a paid version of Codex here?
  1122. 38:42>> So CEX is available both to the free
  1123. 38:44users and the paid user.
  1124. 38:46>> Okay. The version I'm using here is the
  1125. 38:48paid version. Okay.
  1126. 38:49>> Uh so this is uh a pro version that I'm
  1127. 38:52using.
  1128. 38:52>> Okay.
  1129. 38:53>> Uh but in the free version also you
  1130. 38:56could use uh since uh codeex functions
  1131. 38:59on the basis of credits which basically
  1132. 39:02get replenished every week.
  1133. 39:04>> Okay.
  1134. 39:04>> Uh so on the basis of your usage if
  1135. 39:06you're using it for something very
  1136. 39:08heavy. Okay.
  1137. 39:08>> Uh like building a UI as well,
  1138. 39:10>> it would take a certain amount of
  1139. 39:12credits. So if you do run out of
  1140. 39:14credits, you'll probably have to wait
  1141. 39:15for a particular duration for the
  1142. 39:16credits to get replenished.
  1143. 39:18>> Okay. So basically uh it makes sense to
  1144. 39:21have a pro version of whichever LLM
  1145. 39:23you're using, right?
  1146. 39:24>> Yeah. In if your use case is going to be
  1147. 39:27to build an algo and continuously
  1148. 39:29develop on it.
  1149. 39:31>> My suggestion is to have a paid version.
  1150. 39:33>> Okay.
  1151. 39:33>> As it helps in that.
  1152. 39:35>> Okay. So also while we are doing this
  1153. 39:37using codeex I think uh people can use
  1154. 39:41any LLM be it anthropic be it
  1155. 39:44>> gemini or uh whatever else right so it's
  1156. 39:47not it's it is basically LLM agnostic
  1157. 39:50>> yeah this is completely LLM agnostic you
  1158. 39:52could use cloud work as well cloud code
  1159. 39:54as well
  1160. 39:55>> uh or any other LLM that you that you
  1161. 39:58prefer to build the same
  1162. 40:00>> okay but regardless of which LLM you use
  1163. 40:03the framework is going to be the same.
  1164. 40:05So you first install
  1165. 40:07>> the prerequisites on one side and then
  1166. 40:09do whatever is needed on the kite
  1167. 40:12connect side and then start prompting it
  1168. 40:14uh by by using natural language.
  1169. 40:17>> Yeah, that is
  1170. 40:18>> okay.
  1171. 40:18>> Yeah, Karthik. So I think Codex has
  1172. 40:20finished uh building our uh UI.
  1173. 40:23>> Okay.
  1174. 40:23>> So let's quickly launch it and see. So
  1175. 40:26it says the app is running locally now
  1176. 40:28at front end here.
  1177. 40:29>> So I'll just copy this link and go to my
  1178. 40:32browser and paste it. Okay.
  1179. 40:37>> So, yeah, as you can see, it has built a
  1180. 40:40login page with the API key, API secret,
  1181. 40:43and request token here.
  1182. 40:44>> Okay.
  1183. 40:45>> Let's quickly fill those forms in and
  1184. 40:47see how what happens post the login.
  1185. 40:49>> Okay.
  1186. 40:50>> Um, so I'll just go back to my
  1187. 40:52credentials that I had saved.
  1188. 40:58>> Yeah. So, I filled the API key and the
  1189. 40:59API secret.
  1190. 41:00>> Okay. Uh the request token has a shelf
  1191. 41:03life of a couple of minutes.
  1192. 41:05>> Okay.
  1193. 41:05>> Uh so you have to use it in that time
  1194. 41:07frame. So since we had our request token
  1195. 41:10called a long while back,
  1196. 41:12>> we'll call it again.
  1197. 41:13>> Okay.
  1198. 41:14>> So I'll just log in again.
  1199. 41:19>> So you're logging into the developer
  1200. 41:21account.
  1201. 41:22>> Yes, I'm logging into my application uh
  1202. 41:24which has my API key here.
  1203. 41:26>> Yeah, basically your application is in
  1204. 41:27the developer account here.
  1205. 41:31So I'll just log in.
  1206. 41:38Yeah. So it's again redirected us back
  1207. 41:40to google.com.
  1208. 41:42>> Uh but the request token is here. So
  1209. 41:44I'll just copy the request token. So
  1210. 41:46everything between the request token and
  1211. 41:48>> the and here.
  1212. 41:49>> Yeah, I remember that.
  1213. 41:51>> Copy that.
  1214. 41:52>> Okay.
  1215. 41:53>> Um go back to our dashboard that is here
  1216. 41:56and paste it here. Now let's see what
  1217. 41:59happens when you click login.
  1218. 42:02So as you can see [clears throat]
  1219. 42:04uh we have logged in uh it has it in the
  1220. 42:08prompt here that we had shared earlier.
  1221. 42:10>> Okay.
  1222. 42:11>> We had asked it to create a dashboard
  1223. 42:13which wherein after login
  1224. 42:16>> it creates a user tab for us
  1225. 42:18>> and then it calls the API for our user
  1226. 42:20profile.
  1227. 42:20>> Okay. So it calls the username, user ID,
  1228. 42:24the products that are there and the
  1229. 42:25exchanges that are available for this
  1230. 42:27account.
  1231. 42:28>> So since this is my account, uh the
  1232. 42:30details that it's showing here are my
  1233. 42:32username, my user ID,
  1234. 42:34>> the products that I have available and
  1235. 42:36also the exchanges that I have available
  1236. 42:38for me to trade on.
  1237. 42:39>> Okay. But show me the signals, the
  1238. 42:41bullish and the bearish signals. That's
  1239. 42:43what we are working towards, right?
  1240. 42:45>> Yes. Yes. So we'll reach there. So this
  1241. 42:46was the first prom that has built this
  1242. 42:48>> and now we know that the APIs are
  1243. 42:50running. Yeah. So now let's go ahead and
  1244. 42:52add a signals tab which will show us the
  1245. 42:54signals that I've generated for your
  1246. 42:57trading idea that you came up with.
  1247. 42:58>> Okay.
  1248. 42:59>> So I already have a prompt ready for it.
  1249. 43:02I'll just share that with Codex and it
  1250. 43:04should be able to build it.
  1251. 43:09>> Okay. Uh can we go through this once?
  1252. 43:11>> Yes. add a signals tab to the existing
  1253. 43:14zeroda dashboard which basically is what
  1254. 43:16you've built just now using codeex
  1255. 43:19[clears throat]
  1256. 43:19>> and um and basically the other bits is
  1257. 43:24uh is to do the math right
  1258. 43:26>> yeah is to do the math so the first part
  1259. 43:28is to fetch the symbols that is the 100
  1260. 43:31symbols
  1261. 43:32>> uh then to get the historical candles
  1262. 43:35for it
  1263. 43:36>> then calculate the SMA 6 and the SMA 30
  1264. 43:39>> uh the next part is it detects the
  1265. 43:41bullish and bearish crossovers and then
  1266. 43:43it ranks the stocks.
  1267. 43:44>> This was done earlier for the Python
  1268. 43:46file.
  1269. 43:46>> Python. Yeah,
  1270. 43:47>> a very similar prompt for this UI.
  1271. 43:49>> Just that we are now mentioning that the
  1272. 43:51UI it has to be built for a UI and not
  1273. 43:53for a Python file.
  1274. 43:54>> Okay. Okay.
  1275. 43:55>> So now I'll just run this prompt as
  1276. 43:56well.
  1277. 44:10Uh so yeah, it looks like Codex has
  1278. 44:13finished working through this prompt as
  1279. 44:14well.
  1280. 44:15>> Okay,
  1281. 44:15>> let's check the signals it's generated.
  1282. 44:17Let's go back to the UI. Um it's added a
  1283. 44:21signals tab here to the side. Let's go
  1284. 44:23there.
  1285. 44:24>> So yeah, it has built a short SMA, long
  1286. 44:27SMA, loop back, and also max is 100.
  1287. 44:30Okay.
  1288. 44:31>> So, let's just see what happens when I
  1289. 44:32click the button here.
  1290. 44:35>> So, yeah, Karthik, you can see it has
  1291. 44:37generated signals here.
  1292. 44:38>> Okay.
  1293. 44:39>> It has ranked it by the crossover date
  1294. 44:41as well.
  1295. 44:42>> Okay.
  1296. 44:42>> So, this is the most recent date
  1297. 44:45>> uh to the last date that is available.
  1298. 44:47So, it's ranked it by the recency as
  1299. 44:50well.
  1300. 44:50>> Okay. A So, the algo has generated a
  1301. 44:55bunch of signals.
  1302. 44:57Can we physically verify the validity of
  1303. 45:00any of the signals? Maybe we can pick
  1304. 45:02Asian paints.
  1305. 45:04>> Uh it's supposed to be a bearish signal
  1306. 45:06as of today, 30th of uh June.
  1307. 45:10>> Can we check it on the kite chart?
  1308. 45:12>> Yeah. So, let's just navigate to our
  1309. 45:14kite portal.
  1310. 45:15>> Okay.
  1311. 45:16>> Uh I'll just
  1312. 45:19go to Asian PES.
  1313. 45:22So, this is Asian PES on a daily time
  1314. 45:24frame.
  1315. 45:25>> Okay. I'll just add a moving average
  1316. 45:27crossover indicator.
  1317. 45:30So, I'll go for a moving average double.
  1318. 45:32>> Okay.
  1319. 45:33>> And then let's change the
  1320. 45:36>> the settings
  1321. 45:37>> settings. Yes.
  1322. 45:41I'll make this a six
  1323. 45:44and 30.
  1324. 45:45>> Okay.
  1325. 45:49>> Yes. So, as you can see there is a
  1326. 45:51crossover.
  1327. 45:52>> It has Yeah, it has got a crossover. So
  1328. 45:55basically all we have to do is now that
  1329. 45:57we've built the algo and put a nice UI
  1330. 46:00around it,
  1331. 46:02>> I just have to run this on a daily basis
  1332. 46:04and it's going to scan
  1333. 46:06>> and tell me where the signals are
  1334. 46:09>> generated. Yeah,
  1335. 46:10>> and this is exactly what you mean by
  1336. 46:12semi-automated because based on the
  1337. 46:14signal here,
  1338. 46:16>> I still have to go back to Kite or
  1339. 46:18whatever my whoever my broker is and
  1340. 46:21place an order to buy or sell, right?
  1341. 46:24>> So, if the [clears throat] algo was
  1342. 46:27automatically placing the order bases
  1343. 46:30the signal, that would have been a
  1344. 46:31full-fledged uh fully automated algo.
  1345. 46:34>> Yeah.
  1346. 46:35>> Right. So, uh so actually this is uh
  1347. 46:38super interesting.
  1348. 46:39Um
  1349. 46:41what else should I know at this point?
  1350. 46:43>> This session we have built a signal
  1351. 46:45which is an SMA crossover.
  1352. 46:46>> Okay,
  1353. 46:46>> you could apply this to any of your
  1354. 46:49particular trading uh idea. So you could
  1355. 46:52>> you could also try volume breakouts,
  1356. 46:54range breakouts.
  1357. 46:55>> Okay,
  1358. 46:55>> any idea you basically have you could do
  1359. 46:57it across uh not just on a daily time
  1360. 47:00frame,
  1361. 47:01>> you could also scan it across intraday
  1362. 47:03time frames as well.
  1363. 47:04>> Okay,
  1364. 47:04>> so there you get the signals uh coming
  1365. 47:06in while the market is open. Okay.
  1366. 47:09>> So for traders who are intraday traders
  1367. 47:11could also benefit from using APIs as
  1368. 47:13well.
  1369. 47:14>> Okay. Uh and I'm guessing it doesn't
  1370. 47:15matter what the underlying asset is it I
  1371. 47:19can pretty much use the same thing
  1372. 47:20across commodities as well.
  1373. 47:22>> Yes. So like [clears throat] I had
  1374. 47:23showed initially in my user tab if
  1375. 47:26commodities is enabled for you.
  1376. 47:27>> Okay.
  1377. 47:28>> Uh you could do this across commodities
  1378. 47:29as well. You could do this across BC as
  1379. 47:32well. So you have your NSE BC MCX.
  1380. 47:35>> Yeah.
  1381. 47:35>> A this was very interesting.
  1382. 47:38Now let me quickly summarize. I know
  1383. 47:40I've done it several times throughout
  1384. 47:41the video but um but I would like that
  1385. 47:44uh summary at every uh logical uh you
  1386. 47:48know points. So basically I've used
  1387. 47:52codeex it could be any LLM that I can
  1388. 47:54use
  1389. 47:55>> and the as a first step or as a part a I
  1390. 48:00I set up the infrastructure needed to
  1391. 48:03build my algo
  1392. 48:05>> uh which was to install Python which was
  1393. 48:08to install NodeJS
  1394. 48:10and then as part B I connected uh I set
  1395. 48:13up my kite connect API
  1396. 48:15>> ensured both of them are linked uh and
  1397. 48:18then started uh coding my algo using
  1398. 48:22codeex uh through a prompt.
  1399. 48:25>> Yeah.
  1400. 48:25>> Uh but of course the the scary Python
  1401. 48:28lines I didn't want to deal with. So I
  1402. 48:30asked uh Codex to build a beautiful uh
  1403. 48:35UI right and you said you promised me it
  1404. 48:39would build a nice
  1405. 48:40>> beautiful UI which it has. Uh I can I
  1406. 48:43can beautify this further. I think it
  1407. 48:45all depends on the user's creativity,
  1408. 48:48right? And now that this algo is done,
  1409. 48:51all I have to do is run this algo on a
  1410. 48:53daily basis and my uh and I'll get my
  1411. 48:56signals to uh track, right?
  1412. 48:59>> Yeah. And and pretty much any trading
  1413. 49:02idea that you have can be
  1414. 49:04>> developed as an algo using natural
  1415. 49:07language, right?
  1416. 49:08>> Yeah.
  1417. 49:09>> Yeah. And I think I [clears throat] find
  1418. 49:10this idea super powerful because if
  1419. 49:13because it enables non-programmers like
  1420. 49:16me to actually aspire to build algos.
  1421. 49:20>> Yeah.
  1422. 49:20>> Yeah. So any closing thoughts?
  1423. 49:23>> No, I mean uh it all it took was a
  1424. 49:26natural language prompt to build
  1425. 49:27something so unique.
  1426. 49:29>> Yeah.
  1427. 49:29>> And in particular to your trading style.
  1428. 49:32>> Yeah.
  1429. 49:33>> Yeah. It's I mean we have come a long
  1430. 49:34way from the AGO journey
  1431. 49:36>> from from having to have done all that
  1432. 49:39manually by yourself.
  1433. 49:40>> Yeah.
  1434. 49:41>> Going through the whole entire not only
  1435. 49:43did you have to be a trader earlier, you
  1436. 49:44had to be a programmer as well.
  1437. 49:46>> Yeah.
  1438. 49:46>> Now you just need to have the idea
  1439. 49:48>> and orchestrate the entire algo using
  1440. 49:51codeex. So
  1441. 49:53>> yeah, absolutely. This is fantastic. I
  1442. 49:55hope you found this video useful. Uh for
  1443. 49:58me personally, there was a lot of
  1444. 49:59learning. I hope you guys also uh
  1445. 50:02learned something new through this
  1446. 50:04video. Uh if you want us to make more
  1447. 50:07videos on ALGO, please do let us know
  1448. 50:10comment and we will read your comments
  1449. 50:13and take your feedback into
  1450. 50:14consideration. Also, we are doing
  1451. 50:17physical events on uh helping people
  1452. 50:19understand how to develop ALGOS. uh
  1453. 50:22please do keep a track of all the
  1454. 50:25physical events uh that we are posting
  1455. 50:26on our social media and if it's
  1456. 50:29happening in your city please do
  1457. 50:30register and attend these events. Uh
  1458. 50:33hopefully we get to see you offline. By
  1459. 50:36the way, we also have a Hindi and a
  1460. 50:37Canada varsity channel. Please do
  1461. 50:40subscribe uh and check out those
  1462. 50:42channels if you prefer learning in your
  1463. 50:44regional language. I'll see you guys in
  1464. 50:47the next video.

About this transcript

This page contains the full transcript of Build a Trading Algo with AI | No Coding Required by Zerodha Varsity, generated from the public captions YouTube serves with the video. The transcript has 9,115 words across 1,464 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.