Coding a Stock Trading Bot - Python Tutorial

  Рет қаралды 27,216

TradeOptionsWithMe

TradeOptionsWithMe

Күн бұрын

Пікірлер: 74
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
If you want to learn algorithmic trading, check out this free course that I created here on KZbin: kzbin.info/aero/PLtqRgJ_TIq8Y6YG8G-ETIFW_36mvxMLad
@glacial_chinchilla
@glacial_chinchilla 4 жыл бұрын
This is what i've been looking for! I've been dreading using Interactive broker's API and setting up all of the ec2 servers and security, I just want to start on algos without all of the devops. Thank you!
@unknownman5296
@unknownman5296 3 жыл бұрын
nice job man !!! please make more !!!!!
@yespoggersfan5931
@yespoggersfan5931 3 жыл бұрын
Your videos are incredible sir !!
@fortineauaxel5886
@fortineauaxel5886 4 жыл бұрын
Love your Channel !! Greetings from France 🇫🇷
@TradeOptionsWithMe
@TradeOptionsWithMe 4 жыл бұрын
Thank You!
@nuggets7594
@nuggets7594 3 жыл бұрын
yeah please make more man Love your videos man
@AIToday2
@AIToday2 2 жыл бұрын
Does this work in every stock market trading servers( Like ASX)
@veliem3935
@veliem3935 4 жыл бұрын
Congratulations my guy, 2.4k views and no dislike🔥🤟🏾
@TradeOptionsWithMe
@TradeOptionsWithMe 4 жыл бұрын
That's awesome! Thanks!
@adelemarvel5040
@adelemarvel5040 2 жыл бұрын
Can you set a given time the both trades for a day.for example 5hrs everyday
@TradeOptionsWithMe
@TradeOptionsWithMe 2 жыл бұрын
Yes sure
@mohammadrezasoudi2131
@mohammadrezasoudi2131 4 жыл бұрын
Hi , Can I write a trading bot based on gann strategy and astrology? With warm regards.
@TradeOptionsWithMe
@TradeOptionsWithMe 4 жыл бұрын
Hi, sure you can. As long as you get the required data, you can use whatever you want as input. However, I can't comment on the effectiveness of strategies based on such indicators or astrology ;)
@AbhishekRajNahar
@AbhishekRajNahar 4 жыл бұрын
Hey, I'm beginner to both Python and Finance. Do you recommend I learn Finance basics and technical analysis first before I jump into making a bot or can I do both in parallel? What would be your advice to someone like me. What resources would you recommend?
@TradeOptionsWithMe
@TradeOptionsWithMe 4 жыл бұрын
Hi Abishek, Thank you for the question. I personally think, it's best to start by learning Python. Unless you have experience with other programming languages, it can be hard to really understand what a trading bot is doing. In my opinion, having a good grasp of Python will better help you understand a tutorial such as this one than a great understanding of the economic principles behind a strategy. But it's definitely possible to learn Python and relevant finance topics simultaneously. It has been a while since I have learned Python which is why I can't really point you to specific resources to get started. But you can usually find loads of great and free courses/tutorials by googling. Since this is a question I get frequently, I'll try to create a list of great resources to learn programming, finance, etc. sometime in the future. I hope this helps.
@AbhishekRajNahar
@AbhishekRajNahar 4 жыл бұрын
@@TradeOptionsWithMe Thank you so much for such a quick and informative reply. I have past experience with C++ and have a fair bit of understanding of Python. Will definitely sharpen them up
@GoldenTV3
@GoldenTV3 2 жыл бұрын
Would it be safer to instead just to program the bot to sell at $10 profit or so, instead of trying to use an algorithm. Just simple, if stock goes up enough to profit $10, sell. if it goes down $10 with a certain share number. Buy. Stop loss / buying back in would be a bit complicated though.
@chesse1015
@chesse1015 3 жыл бұрын
i'm sure you will reach 1 m subs in no time
@ArnavJainONE
@ArnavJainONE 2 жыл бұрын
I'm not sure why but when I run the bot it doesn't produce any results. Can anyone tell me why that happens?
@HKChris
@HKChris 2 жыл бұрын
Very useful video, thank you!
@veliem3935
@veliem3935 4 жыл бұрын
Hi there I'm a beginner in algos and coding ... I wanted to know does the sequence which you put out the codes matter or as long as you enter the codes correctly? Thanks for another great video 👌🏽 Love from South Africa 🇿🇦
@TradeOptionsWithMe
@TradeOptionsWithMe 4 жыл бұрын
As long as you code out everything before actually running the algorithm, it doesn’t matter which part you code first. But note that the order of the lines of code inside a given method does matter. So you can’t just start a method with a return statement followed by the rest, but you can change which method comes first and which comes last. I hope this explanation clarifies it, otherwise, definitely let me know.
@veliem3935
@veliem3935 4 жыл бұрын
@@TradeOptionsWithMe you're the best🥺🥺
@kbisht3680
@kbisht3680 4 жыл бұрын
You should consider making a udemy etc course. I for one would definitely buy it
@TradeOptionsWithMe
@TradeOptionsWithMe 4 жыл бұрын
Thank you very much for the suggestion!
@veliem3935
@veliem3935 4 жыл бұрын
Me too 🙋🏾‍♀️
@andrewyork3869
@andrewyork3869 4 жыл бұрын
@@TradeOptionsWithMe I agree there are alot of people who wish they had the talent you do.
@reginaldpooftah4525
@reginaldpooftah4525 4 жыл бұрын
I'd buy it too
@Th3_Gael
@Th3_Gael 3 жыл бұрын
There's a course on udemy about this already isn't there? www.udemy.com/course/python-for-finance-and-trading-algorithms/ New so genuinely interested to know if there's a difference
@flippantfishtaco3132
@flippantfishtaco3132 4 жыл бұрын
This was extremely helpful, I have subscribed. Looking forward to more. Would you mind telling me, which resources do you use for researching the LEAN API? I find that the code hints in the browser IDE often don't appear. I just started cloning my projects to my local and working in VS Code, but the class and method definitions didn't seem to get picked up. Probably this has something to do with my VS Code Python settings/addons.
@TradeOptionsWithMe
@TradeOptionsWithMe 4 жыл бұрын
Hi Rob, Thanks for the positive feedback. I also have the problem that code suggestions don't always appear. A great way to get started is going through QuantConnect's bootcamp. Otherwise, I mainly use the documentation and forum as a help when developing an algorithm.
@flippantfishtaco3132
@flippantfishtaco3132 4 жыл бұрын
​ @TradeOptionsWithMe Thanks for the quick reply. Are you using these docs? www.quantconnect.com/lean/docs It seems like these are written with C# in mind, and I notice that some things are not present. For example, the convenience method Consolidate, doesn't seem to be listed anywhere here. I've been searching around their github most recently when I can't find things, but this is a slow process. I've gotten as far as the Liquid Universe lesson in the bootcamp.
@TradeOptionsWithMe
@TradeOptionsWithMe 4 жыл бұрын
I usually use this doc page to get an overview: www.quantconnect.com/docs/ Otherwise, you can usually find things by using the search tool directly on QC. This will typically bring you to a page with some examples and explanations. If that doesn't help, you can always try to search for existing posts in the QC forum or create your own forum post.
@TradeOptionsWithMe
@TradeOptionsWithMe 4 жыл бұрын
Create your free QuantConnect account here: www.quantconnect.com/?ref=towm
@CanITradeICT
@CanITradeICT 4 жыл бұрын
Correct me if I am misunderstanding what is going on in the algo. How can you add the ability to sell after a certain % of profit? It appears that right now the only thing that triggers the sale of the stock is the trailing stop loss. Any Feedback is much appreciated!
@TradeOptionsWithMe
@TradeOptionsWithMe 4 жыл бұрын
Thanks for the comment. You are absolutely right that currently this algorithm only closes a position if the trailing stop loss is hit. To implement a profit-taking mechanism, you would need to add a section that liquidates the position as soon as the price has moved far enough compared to the entry price. Alternatively, you could also send out a take-profit order after entry. In that case, you just would have to cancel the stop loss order if the take-profit order is hit.
@frenchman69420
@frenchman69420 4 жыл бұрын
How do i make my code talk to the exchange after i coded my algorithm?
@TradeOptionsWithMe
@TradeOptionsWithMe 4 жыл бұрын
Thanks for your comment. Your algorithm usually doesn't directly communicate with an exchange. Instead, it communicates with a broker which communicates with an exchange. To make your algorithm do that, you have to use the API of your broker. QuantConnect does this for you if you are using one of their supported brokers. All you have to do then is click on "Go Live" above the code section and you will be directed to a page with more details. I hope this helps.
@simonnattrass2171
@simonnattrass2171 4 жыл бұрын
Wonderful thank you 😊👍
@TradeOptionsWithMe
@TradeOptionsWithMe 4 жыл бұрын
You are very welcome!
@daveshiroma
@daveshiroma 4 жыл бұрын
Don’t chase, let the trade come to you. The trend is your friend.
@kacceyjoseph5040
@kacceyjoseph5040 4 жыл бұрын
Wdym
@contrarianthinker
@contrarianthinker 4 жыл бұрын
@@kacceyjoseph5040 trade with the trend
@kacceyjoseph5040
@kacceyjoseph5040 4 жыл бұрын
@@contrarianthinker okay I guess
@lmaolol2248
@lmaolol2248 3 жыл бұрын
like your videos man
@opiston
@opiston 4 жыл бұрын
I recently gave up on QuantConnect. I created a simple trading algo click on backtest, and was waiting for 10+ minutes for the backtest to complete. I don't know if the quantconnect system was just having a bad day or what. To get a testing node and buying a live trading account, it cost $50ish / month / person. Do you guys actually have good experience with quantconnect?
@TradeOptionsWithMe
@TradeOptionsWithMe 4 жыл бұрын
Thanks for your comment. Sometimes the backtesting seems to get stuck but usually reloading the page fixes this. But I’d say this problem has gotten a lot better over the past few weeks. But note that depending on the algorithm 10 minutes isn’t necessarily that much. If, for instance, you want to backtest an options trading bot (which uses minutely data) that has to calculate the Greeks every minute for a period of multiple years, the amount of data that is being used is absolutely gigantic. You can’t expect such a backtest to finish in a couple of minutes, not at QuantConnect or anywhere else. As for the cost, you don’t necessarily need a backtesting node. If you want to save money and are okay with a few minor restrictions, you could only use a live trading node. This will cost you about $28 a month (or slightly less with a yearly subscription). Considering that a live trading node has to be up and running 24/7 since it always has to be able to communicate with your broker, I’d say this price is pretty fair. I hope this helps. But definitely let me know if you have any other questions or comments.
@opiston
@opiston 4 жыл бұрын
@@TradeOptionsWithMe thank you for your response and the detailed info. I am new to algo trading, so I didn't realize how much processing is required to test intraday behind the scheme. I will give it a try again, but if the backtest takes a while and sometimes it gets stuck, then I can imagine waiting for the backtest to finish for half an hour and not knowing if the backtest is still ongoing or not.
@TradeOptionsWithMe
@TradeOptionsWithMe 4 жыл бұрын
Usually it doesn’t get stuck once it has started. From my experience it only really gets stuck when initializing the backtest. So if the initialization takes more than a couple of minutes, you can just try reloading the page and starting another backtest. And note that the backtests are run on QuantConnect’s server nodes. This means, you don’t actually have to keep your computer running while waiting for the backtest to finish up. You could just turn off your computer or do something else and come back later.
@opiston
@opiston 4 жыл бұрын
@@TradeOptionsWithMe I did not realize that I didn't have to be connected to wait for the test to complete. It's a relief to know this, thanks for your insight again.
@Jamesedwardkoch
@Jamesedwardkoch 3 жыл бұрын
Ok just one more question... : without refering to evident profits made, how would one confidently justify or defend that the trading which they are doing (systematic or discretional) is not gambling. What kind of behaviour distinguishes a gambler from a diligent & professional trader?
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
Good question. I’d say the difference between a trader and a gambler is the approach. A good trader should always have a clear plan as well as a process. You should never take anything for granted. You should have a scientific approach that allows you to learn from your experience and thereby become better. But note that due to the embedded uncertainty in the financial markets, luck will always play a role. It’s just important that you never allow yourself to blow up if something doesn’t go as you expected.
@Jamesedwardkoch
@Jamesedwardkoch 3 жыл бұрын
@@TradeOptionsWithMe great thank you very much 👍🏻
@kdanish8971
@kdanish8971 4 жыл бұрын
hi sir i lyk ur work i want to contact you ,can i?
@TradeOptionsWithMe
@TradeOptionsWithMe 4 жыл бұрын
The fastest way to contact me is by leaving a comment under one of my posts on KZbin or my site. If you want to contact me privately, you can do so here: tradeoptionswithme.com/contact-me/
@caiusKeys
@caiusKeys 3 жыл бұрын
But need a Lambo by next week bro!
@Al-ms6me
@Al-ms6me 3 жыл бұрын
i got this error: During the algorithm initialization, the following exception has occurred: AttributeError : 'HorizontalDynamicCircuit' object has no attribute 'SetBenchMark' at Initialize in main.py:line 64 :: self.SetBenchMark("SPY") AttributeError : 'HorizontalDynamicCircuit' object has no attribute 'SetBenchMark'
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
The m shouldn’t be capitalized. It should be SetBenchmark, not SetBenchMark. Note that you can also just use the link in the description box to clone my algorithm.
@Al-ms6me
@Al-ms6me 3 жыл бұрын
Ok Cheers man. That link took me to the same video.... ill try again though... theres every change i was brain fried from reading code for hours 😂😂
@samuelescarfone9290
@samuelescarfone9290 3 жыл бұрын
For some reason it keeps giving me this error (object has no attribute 'CoarseSelection' at Initialize in main.py:line 9)
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
Thanks for the comment. Sadly, I can’t tell you what’s the problem with so little info. That’s why I’d recommend using the link in the description box to clone my algorithm. That should definitely work.
@Jamesedwardkoch
@Jamesedwardkoch 3 жыл бұрын
I have subscribed now, but I would love to hear your response to the phrase, "If this was so easy to do, and to make a profit, then everyone would do it."
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
Thanks for the sub! I really appreciate it. My response to that phrase is: it’s not easy! Developing your own trading algorithms is very time intensive and it is by absolutely no means easy to develop a trading bot that performs well over a long enough time frame. Note that the benchmark should not be profitability. Most buy and hold strategies of simple index funds have been profitable, so it’s not enough to just develop a profitable bot. Instead, you want to develop a bot that outperforms a comparable index fund in the same sector with a similar risk profile. Also note that just because a bot performs well over a certain backtest, does not mean that it will perform well in the future. Algorithmic trading simply is a different approach to the markets than the conventional discretionary approach. For a full comparison of the two, you could check out this post: tradeoptionswithme.com/systematic-vs-discretionary-trading/ I hope this helps. Otherwise, certainly let me know.
@Jamesedwardkoch
@Jamesedwardkoch 3 жыл бұрын
@@TradeOptionsWithMe Thank you very much for the great reply. I look forward to going though all your content.
@gustavramedies2901
@gustavramedies2901 4 жыл бұрын
Can you code my system
@TradeOptionsWithMe
@TradeOptionsWithMe 4 жыл бұрын
Hi, I am sorry but I currently don’t code for anyone else. I can only recommend learning to code yourself since it is an incredibly valuable skill to learn.
@jaitramayani6887
@jaitramayani6887 4 жыл бұрын
👍👍👍👍👍👍👍
@ryankao1983
@ryankao1983 3 жыл бұрын
why is the auto-generated subtitles German? can you please change it to English?
Learn How to Code a Trading Bot in Python
48:17
TradeOptionsWithMe
Рет қаралды 25 М.
10 Algorithmic Trading Mistakes to Avoid!
14:32
TradeOptionsWithMe
Рет қаралды 64 М.
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
Predicting Stock Prices in Python
29:14
NeuralNine
Рет қаралды 541 М.
What is Algorithmic Trading & How to Get Started
15:56
TradeOptionsWithMe
Рет қаралды 555 М.
Building a Trading Robot in Python | Pt. 1
29:06
Sigma Coding
Рет қаралды 187 М.
Build A Killer Stock Portfolio Using Python
28:53
Computer Science (compsci112358)
Рет қаралды 204 М.
James Beilby (Banking Industry): An Algo Execution System in Rust
10:32
Understanding Recruitment
Рет қаралды 5 М.
Top 6 Algorithmic Trading Strategies!
12:15
TradeOptionsWithMe
Рет қаралды 311 М.
Algorithmic Trading Strategy Using Three Moving Averages & Python
31:46
Computer Science (compsci112358)
Рет қаралды 54 М.
Resources to Start Coding Trading Algorithms
8:55
ForrestKnight
Рет қаралды 332 М.