Algorithmic Trading Using Python #4 - Handling Data

  Рет қаралды 90,676

TradeOptionsWithMe

TradeOptionsWithMe

Күн бұрын

Пікірлер: 83
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
I hope you are enjoying the series. You can clone the code from this video here: www.quantconnect.com/forum/discussion/11052/algorithmic-trading-video-series?ref=towm But note that coding along can lead to a better learning effect!
@urban2327
@urban2327 3 жыл бұрын
Very clearly explained! Waiting for more food!
@urban2327
@urban2327 3 жыл бұрын
Is it possible to access the Slice data in a purely time driven strategy made with Schedule.on(), (because OnData() method is not needed)?
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
Sorry for the late reply. Yes, that is possible. You can, for instance, access such a slice object through history requests. This will be covered in more detail in about the 6th video of this series.
@alexsolo9189
@alexsolo9189 2 жыл бұрын
@@TradeOptionsWithMe hi i was thinking how can sell stock at certain percentage let's say 1% when the stock goes up by 1% than it's value when purchased , so how can I write code based on this situation i don't know much about it , will u assist me
@oozification
@oozification Жыл бұрын
replicated the same code but it did not work with end date specification I had to remove end data method , do you know why it might be the case ?
@bipmix
@bipmix 6 ай бұрын
it may please you to know that as a totally rank beginner at python and coding, i was abkle to follow this command by command and re-do the code, and it worked! i would also say to others who are watching this: take the tie to opy the code lines, item by item and learn the fundamentals before going on to other more complex issues because this video can be used as a fallback solutions when you run into problems. its really basic but a must. once you can plug in the data, yu are golden, great series!
@memecomic6305
@memecomic6305 7 ай бұрын
the quality of this series is insanly good. thanks a lot.
@PGhai
@PGhai 8 ай бұрын
Hi, I am trying to follow with your video, noticed that most of the things has changed. do you have any latest video to follow on OR any resources to learn ?
@tr0wb3d3r5
@tr0wb3d3r5 Ай бұрын
Managed to make it run with this code, still need to fix something because it's not closing positions but 90% there, I know it's related to how "price" is handled: from datetime import timedelta class EmotionalTanAlpaca(QCAlgorithm): def initialize(self): self.set_start_date(2020, 1, 1) self.set_end_date(2021, 1, 1) self.set_cash(100000) spy = self.add_equity("SPY", Resolution.DAILY) spy.set_data_normalization_mode(DataNormalizationMode.RAW) self.spy = spy.Symbol self.set_benchmark("SPY") self.set_brokerage_model(BrokerageName.INTERACTIVE_BROKERS_BROKERAGE, AccountType.MARGIN) self.entry_price = 0 self.period = timedelta(days=31) self.next_entry_time = self.time def on_data(self, data: Slice): if self.spy not in data.bars: return price = data.bars[self.spy].close if not self.portfolio.invested: if self.next_entry_time price: self.liquidate(self.spy) self.log("SELL SPY @" + str(price)) self.next_entry_time = self.time + self.period
@chadneiro9088
@chadneiro9088 8 ай бұрын
Are there updated videos because the api has changed and the methods in this are no longer available in the framework.
@maximilianmuhlenberg4193
@maximilianmuhlenberg4193 3 жыл бұрын
Thank you so much for this series! It really helps me a lot to become familair with the QC-Platform
@paragonpartners2058
@paragonpartners2058 2 жыл бұрын
Thanks, just followed along and typed up myself. This is a good Hello World introduction.
@KokeBeast23
@KokeBeast23 3 жыл бұрын
I loved coding on my own alongside this video because I made mistakes I would have never noticed if I had just copied the code! Thanks for making it so easy to follow along with I had a question about being able to “sift through” different stocks in the market. Or will we always have to choose a specific one like SPY in this case? I’d love to see a video dealing with this. Thank you!
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
Yes, it’s also possible to create an algorithm with a dynamic universe of stocks or other securities. That will be covered later in the series. I plan on covering this in the 8th video.
@eh7141
@eh7141 Жыл бұрын
This is such quality content, Im baffled sir.
@wenceslasebe1003
@wenceslasebe1003 3 жыл бұрын
thank you for such great content . at which pace are you going to add the new videos?
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
My plan is to upload one video every 1-2 weeks. But note that the future videos will likely include more coding and thus be longer than the first few videos. I’m doing the best I can.
@wenceslasebe1003
@wenceslasebe1003 3 жыл бұрын
Thank you again . I’m just a bit enthousiactic about learning algo trading
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
Just uploaded the next part ;)
@ira9557
@ira9557 3 жыл бұрын
Hi, please, can you explain, what describes exposure? and what does is mean, if it is flat? Thank.
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
It means how much risk you’re exposed to. For example, if you buy 100 shares of AAPL for $100 each, your exposure would be 100*$100=$10000 since that’s what you could lose.
@ira9557
@ira9557 3 жыл бұрын
@@TradeOptionsWithMe and what does it mean if "Equity - Long Ratio" = 0,9696. (from Exposure Chart)?
@shanejackson2062
@shanejackson2062 3 жыл бұрын
I've been having some issues with backtesting, even if I just copy your code from the QC forums. I keep getting an error saying that 'Python slice object has no attribute 'bars''. So the algorithm never identifies a price, and never executes any orders. The backtest chart is just a flat line. Seeing as this happens even with your code, is this an issue with the QC platform? I haven't completed enough of my bootcamp training to be allowed post to the forums there...
@GuyFawkes911
@GuyFawkes911 3 жыл бұрын
great video. I am hoping for an options bot in the future. specifical selling vertical spreads would be nice
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
Options will be covered later in this series.
@windillvanniekerk209
@windillvanniekerk209 3 жыл бұрын
Can you make a video how to add Python on metatrader
@samuelmacintyre3820
@samuelmacintyre3820 2 жыл бұрын
Don't think you can. Metatrader has its own language (MQL4/5), with that said there is a library that allows you to access the Metatrader terminal from a Python application, but then you have to think about how to host your application/program. www.mql5.com/en/docs/integration/python_metatrader5
@mark1731
@mark1731 3 жыл бұрын
Do you know of any good lessons on KZbin for a beginner learning python?
@mohammedzakizaki145
@mohammedzakizaki145 3 жыл бұрын
Hi Brilliant tutorial, Is just if the elif condition is not satisfied then you are locked with the initial investment, is that correct?
@unknownman5296
@unknownman5296 3 жыл бұрын
nice video man please make more
@33wunduentrance93
@33wunduentrance93 3 жыл бұрын
Hi Thank you! This is excellent and a lot easier to understand than the materials on Quantconnect. To follow the QCA Framework aren't you suppose to generate insights, create alpha and risk models? Will you share these in the next videos, and how often should we expect video updates?
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
I’ll try to upload once a week. What you’re describing is QuantConnect’s algorithm framework. We will explore this later in the series. But first understanding the fundamentals as well as classical algorithms is essential to fully understand the framework.
@MrAnders10
@MrAnders10 3 жыл бұрын
Hey. How many parts do you think this series will have?
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
Not sure, but there should definitely be more than enough content to create at least 20 videos. After covering all the main areas of the QC API, I’d like to end the series with plenty of example algorithm videos.
@kabuqq
@kabuqq 2 жыл бұрын
Is it possible to support subtitles? This is a bit difficult for non-native English speakers.
@boswer39
@boswer39 3 жыл бұрын
Hi ! Thank you for your video ! I have an issue : "self is not defined" and this error is linked to the line "if not self.Portfolio.Invested :". I tried to fix it thanks to advices from internet but it's still broken. Do you have an idea why I have such an error ? I copy past your code from this video.
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
Hi, thanks for the questions. It seems like you are trying to access a class property outside of a class. I guess something with your indentation is wrong. My recommendation would be to use the link in the description box to clone my code instead of copy pasting it. That should definitely work.
@boswer39
@boswer39 3 жыл бұрын
@@TradeOptionsWithMe Thank you very much, it's working well ! Let's go to the next video ;-)
@abhaykolapkar4137
@abhaykolapkar4137 3 жыл бұрын
can we use this platform and APIs for binary options trading? Can you make videos on binary options auto trading bots , how can it be created and deployed to real time broker
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
No, binary options aren’t supported by QuantConnect. But note that the vast majority of binary options offered by brokers aren’t legitimate investment products. I’d recommend staying away from binary options. For a more detailed breakdown as to why, check out this post: tradeoptionswithme.com/binary-options-review/
@afletch117
@afletch117 3 жыл бұрын
Thanks for the series, great content! How does OnData handle data when your algo is subscribed to multiple symbols? Is it handed a dictionary argument?
@gregkendall3559
@gregkendall3559 3 жыл бұрын
I think that is pretty much right. You can loop through "data" which contains what happen for that day (resolution daily). for i in data: print( "symbol : " , i.key) print("close : ", i.close) like that basically, but you use self.Log instead of print. Not sure if data is a dictionary or a list but it is iterable.
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
Yes, that’s right.
@afletch117
@afletch117 3 жыл бұрын
@@gregkendall3559 @TradeOptionsWithMe Thank you for your reply. I tried the following code, with variations several times: def OnData(self, data): for i in data: print("close : ", i.close) Every time I got an error like this: Error: object has no attribute "close" at OnData print("close : " in main.py:line such and such Can you tell what is missing here?
@gregkendall3559
@gregkendall3559 3 жыл бұрын
@@afletch117 you can get close amount this way: in OnData data[i.Key].Close or self.Securites[i.Key].Close
@jessojohn9226
@jessojohn9226 Жыл бұрын
hi louis, one question if start date is jan 1,2020 is the value of close price on the on_data method from the previous date?
@JF-Gagné
@JF-Gagné 2 ай бұрын
hey ! nice, but unfortunately the whole syntaxe seems to have changed. So we can't code along
@SylvainThibault-dz5oe
@SylvainThibault-dz5oe 2 ай бұрын
Just went through it and coded along with no issue. Camelcase was changed to snake case.
@EssosinamKOMOU
@EssosinamKOMOU 10 ай бұрын
Thank you for these videos
@happypotato4694
@happypotato4694 3 жыл бұрын
I didn't really get the "Self" in "OnData", what does it do/mean? I am sorry i am not an expert....
@philcREI
@philcREI 3 жыл бұрын
Self is a reference to the class object you are in and is how classes in python work. He is using python classes to encapsulate all his code/ functions / methods.
@philcREI
@philcREI 3 жыл бұрын
And his class extends some other class so he has all that classes methods he is basing his class on. So you have to know all about the class he is extending. Where those other methods came from, probably available in some webpage or api guide on quantconnect
@happypotato4694
@happypotato4694 3 жыл бұрын
@@philcREI oh i got it, thanks!
@ryankao1983
@ryankao1983 3 жыл бұрын
I read about dollar bar & volume bar in some financial machine learning books, and some people say it is better to use dollar bar because of it's statistical properties? would like to know if this is common in practice?
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
Thanks for the comment. Sadly, I can’t really comment on this without further context. What exactly do you mean by volume and dollar bars and in which context do you want to use them?
@farmingbyfaith4210
@farmingbyfaith4210 3 жыл бұрын
Great video. Is there a way to import data from a csv and use that as OHLC data? If not, is it possible to import the CSV as an extra filter mechanism to influence the trading logic?
@SOURABHAHUJA-r2k
@SOURABHAHUJA-r2k Жыл бұрын
Can someone please tell me why self.entryPrice is set to zero?
@TradingBuggy
@TradingBuggy 14 күн бұрын
To establish the subject (entryPrice) with a value so you can reference to it later in the code.
@cryptolicious3738
@cryptolicious3738 3 жыл бұрын
hi, i am really enjoying this series but why is the AI episode removed ? it was listed yesterday and i was going to watch it today
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
I did not remove any videos. Not sure which AI video you are referring to.
@cryptolicious3738
@cryptolicious3738 3 жыл бұрын
@@TradeOptionsWithMe i thought there was one towards the end using machine learning / ai ....?
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
@@cryptolicious3738 The series is not finished yet. That video has not been made yet. I'd estimate that so far around half of the series is done and I'm trying to upload a new video about every two weeks.
@cryptolicious3738
@cryptolicious3738 3 жыл бұрын
@@TradeOptionsWithMe fantastic ! very exciting ❤ , i really appreciate your effort helping me get these skills :)
@vanquoc81
@vanquoc81 Жыл бұрын
Hi Louis, a fellow trader, and computer science enthusiast here. Love the series. I finished (except for the Tiingo lesson) the Bootcamp on QuantConnect and just started with your course. I love the way how you edited the video with clearly illustrated examples. Makes it for visual learners a lot easier to grasp the concept. I just finished lesson 4 Handling data but came across something weird when running the backtest. There is a difference in the backtest result between my equity curve, max. profit, PSR, etc, and the one in your video. I used the exact code, but somehow it yield a different result. It makes me worried about the reliability of the backtest engine itself. Do you know where this is coming from? I was thinking maybe it has to do with the LEAN engine version of the current master branch. Hope you can shine some light. 😁
@williamratelband6918
@williamratelband6918 3 жыл бұрын
So cool! Thanks a lot.
@mohamedtrfnx6632
@mohamedtrfnx6632 3 жыл бұрын
Thank you so much for this series but try to talk slower and use simpler terms
@sheesh4210
@sheesh4210 3 жыл бұрын
If I Do SetHoldings("STOCK", 1.5) is the extra 50% considered margin? or does it glitch
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
Yes, that would be interpreted as a leveraged position
@peteortiz9481
@peteortiz9481 3 жыл бұрын
Can someone explain how to set the entry time and exit time in beginner language please? Specifically the: self.nextEntryTime
@TradeOptionsWithMe
@TradeOptionsWithMe 3 жыл бұрын
I can try. The self.nextEntryTime variable simply saves a date and time. self.Time always is the most recent date and time. So the first line just checks whether the date saved in self.nextEntryTime is before the current time. If that’s the case, we want to start investing again. The second line sets the self.nextEntryTime variable to a date and time in 31 days from now (since self.period is 31 days). Doing this will guarantee that the condition in the first line will stay false for the next month which means that the bot won’t invest during that time. I hope this helps.
@user-wr4yl7tx3w
@user-wr4yl7tx3w Жыл бұрын
Little difficult to follow
@unknownman5296
@unknownman5296 3 жыл бұрын
please provide captions sir
@aeromaker_fpv
@aeromaker_fpv 11 күн бұрын
Quantconnect no longer woking, it wont allow you to create a project anymore.
@mauricioalfaro9406
@mauricioalfaro9406 3 жыл бұрын
Your accent, my friend...English subtitles please!!!!!!
Algorithmic Trading Using Python #5 - Trading & Orders
28:47
TradeOptionsWithMe
Рет қаралды 61 М.
Why Independent Quants Don't Exist
10:14
Dimitri Bianco
Рет қаралды 110 М.
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
How to Code a AI Trading bot (so you can make $$$)
35:09
Nicholas Renotte
Рет қаралды 705 М.
James Beilby (Banking Industry): An Algo Execution System in Rust
10:32
Understanding Recruitment
Рет қаралды 4,8 М.
I Tried Day Trading w/ a Trading Bot Algorithm
14:01
Daniel Inskeep
Рет қаралды 949 М.
Algorithmic Trading Using Python #7 - Consolidators & Rolling Windows
22:41
TradeOptionsWithMe
Рет қаралды 26 М.
How Financial Firms Actually Make Money
22:40
QuantPy
Рет қаралды 369 М.
How To Build A Trading Bot In Python
18:46
CodeTrading
Рет қаралды 848 М.
Stock Price Prediction Using Python & Machine Learning
49:48
Computer Science (compsci112358)
Рет қаралды 1,3 МЛН
QuantConnect LEAN Algorithmic Trading Engine - Getting Started
46:08
Part Time Larry
Рет қаралды 66 М.
Algorithmic Trading - Machine Learning & Quant Strategies Course with Python
2:59:20
Algorithmic Trading Strategy Using Python
31:57
Computer Science (compsci112358)
Рет қаралды 432 М.
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН