Real-Time Streaming Stock Market Data with Python and Websockets

  Рет қаралды 78,557

Part Time Larry

Part Time Larry

Күн бұрын

Пікірлер: 88
@ErolAspromatis
@ErolAspromatis 4 жыл бұрын
Awesome video Larry - You have a real talent of explaining these concepts and getting people up and running quickly using your examples and tutorials. Keep it up.
@parttimelarry
@parttimelarry 4 жыл бұрын
Thanks much more to come!
@mschuer100
@mschuer100 4 жыл бұрын
Fantastic video. Very educational. appreciate the time taken to make these videos and make the content easy to use. Just started working with the Alpaca API last week so having the Polygon data feeding into it will be a nice complement. Keep the videos coming please.
@jeroenvermunt3372
@jeroenvermunt3372 3 жыл бұрын
Only place where I could find how to properly communicate with a websocket. This is precisely what I needed to know! thank you very much.
@michaelswiercz3357
@michaelswiercz3357 4 жыл бұрын
Great video! Simple and to the point in less than 15 minutes.
@thirdreplicator
@thirdreplicator 4 жыл бұрын
Great video. You're a good explainer/communicator. I recommend putting a light source in front of your face so that we can see you.
@parttimelarry
@parttimelarry 4 жыл бұрын
Thanks, I have a much better setup in my more recent videos :). Tool me a while to get my resolution and recording/editing setup right.
@semeradstephan
@semeradstephan 4 жыл бұрын
Awesome Video! I am amazed that at this point you only have 6K Views
@michaelbdd
@michaelbdd 4 жыл бұрын
Hi Larry, thanks for the great video. Just one question, in the python example, you called ws.send() first for authentication then called ws.send() again for subscribing to quotes. I'm wondering if the ws.send() function async? Should we wait for the first ws.send() success then send the second one?
@tbjasun
@tbjasun 3 жыл бұрын
Is there an updated version of this video for Alpaca? Trying wscat with the provided wss feeds is not working now. It looks to me like Alpaca is doing something else, as their docs indicate use of https: addresses for websocket feeds, but that doesn't work using wscat. Something is missing the mark here! Thanks for the help.
@tokusukeutsugi4239
@tokusukeutsugi4239 3 жыл бұрын
I encountered same problem. Are there any solution?
@danielnelson9996
@danielnelson9996 4 жыл бұрын
Hey Larry, thanks for the amazing video. While running the script, I get a message, [{"ev":"status","status":"max_connections","message":"Maximum number of connections exceeded."}]. Is this because I'm using my Paper Trading API key? I have a funded alpaca account but am using the paper trading API key to test some algos first. Any suggestions? thanks
@Clockwise.00
@Clockwise.00 4 жыл бұрын
Super interesting content, waiting for next.
@NicciXRP
@NicciXRP Жыл бұрын
You are part of the reason I’m becoming dev😅🤟🏼 I don’t know anything but you explain this stuff so professionally! Where’s the new content? Hope all is well❤️👊🏼
@parttimelarry
@parttimelarry Жыл бұрын
Thanks man! Hope you keep it up, love these kinds of comments. I've been busy with some projects lately, so have been on a pause. I still think about making new videos all the time though...hopefully soon.
@vicvol7360
@vicvol7360 2 жыл бұрын
Why aren't you using asyncio library in this video? Other vidoes explaining websockets on python are using asyncio but don't know why it is needed
@US100
@US100 4 жыл бұрын
Awesome Tutorial this Series will be very nice
@parttimelarry
@parttimelarry 4 жыл бұрын
Thanks!
@hsan0184
@hsan0184 3 жыл бұрын
Larry, great explanation! A simple question, if you do not mind answering - would it be possible to live plot websocket stream within the same python code (same file that opens websocket), so it just pops up a simple dynamic plot while streaming (ie without saving to CSV, reading back etc)?
@AlexJaeger716
@AlexJaeger716 4 жыл бұрын
but how do you put this live data into a dataframe so that you can place orders on the close or open of a candle? can you make a video on putting live websocket data into a pandas dataframe?
@parttimelarry
@parttimelarry 4 жыл бұрын
Thanks, in more recent videos I do this, but only for crypto so far. Same concept though. I will do a version for stocks, I have quite a few videos to make in my queue, but will get to it.
@AlexJaeger716
@AlexJaeger716 4 жыл бұрын
@@parttimelarry Thank you! but the run_forever() method is blocking all of my code after it from being executed.. How do I fix this?
@nicholasrotich4295
@nicholasrotich4295 4 жыл бұрын
thank you for your wonderful tutorials. Any chance that the connection fails if you are using paper account?
@parttimelarry
@parttimelarry 4 жыл бұрын
Hey, in this video I used an API key from my paper account. Did you give it a try and have issues? There is always a chance a connection can fail. If you are sure your code is correct, then you can just have the script wait a few seconds and retry the connection.
@adamsocki
@adamsocki 4 жыл бұрын
I was having an issue opening a connection to the Websocket....but I finally figured out what was wrong. What I first did was add an ,on_error=on_error, in the parenthasis of WebSocketApp(). Then I created an on_error function that would print out the error. def on_error(ws, error): print(error) This gave me the following error.... [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108) After some googling of this error, I found something that said I needed to run: Applications/Python\ 3.8/Install\ Certificates.command After I did this, I was able to open up a connection to a Websocket through python. Hope this helps! Adam.
@suleimana678
@suleimana678 Жыл бұрын
Hi Larry, thanks for all of the information in this video. Do you have any suggestions for how i can extract what the *exact time* the "high tick" happened at, and the exact time of the low tick?
@bullet4255
@bullet4255 2 жыл бұрын
Is it neccessary to use Kafka here and Spark for real-time data processing if we wanted to to some data visualization and processing? Let's say we wanted to have 10 different currency pairs and then monitor them, or I misunderstood their purpose and they are not needed here?
@Jatin19902
@Jatin19902 3 жыл бұрын
Thank god finally I found a tutorial about WebSocket streaming of data. I am trying to stream data through IBKR. After modifying the script I am getting the following error "ModuleNotFoundError: No module named 'websocket'' " Thanks a lot.
@ABGTronic_Inc
@ABGTronic_Inc 4 жыл бұрын
Can you demonstrate how to put the live quote on a text box where the content is refreshed each time new message is received ?
@parttimelarry
@parttimelarry 4 жыл бұрын
Do you mean on the web? Yeah I think it would be a cool tutorial to build a real time trading dashboard, so will put this on my list.
@jasonbourne5825
@jasonbourne5825 3 жыл бұрын
Your lecture helps me a lot, thank you.
@rakeshrakesh0729
@rakeshrakesh0729 4 жыл бұрын
Hi Larry, awesome video. Could you please make a video for the same through TD Ameritrade. As in I how to code in python to grab live streaming data through TDA API. Most people use TDA and that would be greatly helpful. Thanks for all your videos.
@utkarshs060
@utkarshs060 3 жыл бұрын
I was wondering whether we can use this real-time tick-by-tick data to create a strategy and if yes then please make a video on this as to writing real-time data into a CSV or a DB then creating strategies with it.
@ricomajestic
@ricomajestic Жыл бұрын
Yea would love to see that too. How to write real time data to a database.
@MrBraianzzz
@MrBraianzzz 3 жыл бұрын
Hi Larry, this is awesome. Do you know how can I send the message to render.template html in Flask? Thanks
@andrewenglish1418
@andrewenglish1418 4 жыл бұрын
Hi, thanks for the video, really helpful! is there a way to stream all tickers that are associated with alpaca instead of subscribing to specific stocks?
@parttimelarry
@parttimelarry 4 жыл бұрын
Every ticker might be a bit much I think, but maybe. There is an API method in the alpaca docs that returns all the available tickers. I suppose you could create sockets to listen on all of them, but haven't tried.
@YannickvDijk
@YannickvDijk 4 жыл бұрын
They currently limit to 30 channels per API key I believe.
@AlexJaeger716
@AlexJaeger716 4 жыл бұрын
Hey Larry, how can i access the keys within the dictionary if the dictionary is inside of a list? I've been trying to access the bid and ask prices to use them in my strategy but I just can't find a way to pull them from the dictionary..
@amanchaure5584
@amanchaure5584 Жыл бұрын
Hey, can you suggest a method to share the websocket data feed from a single subscription to multiple python trading scripts? The broker that I am using is having a limitation of only 3 websocket connections at any given instant.
@PyMoondra
@PyMoondra 3 жыл бұрын
Great channel. Been trading recently, and trying to build some Python apps to find setups.
@michaelscarn7375
@michaelscarn7375 4 жыл бұрын
But how can I actually use this data (not print it), but use in if/else statements?
@akramdahmani7214
@akramdahmani7214 3 жыл бұрын
if you can print it, it means that you have as you can see in his terminal it's a list, do whatever you want with it :)
@neurondeep
@neurondeep 3 жыл бұрын
Can you do a buffer to acumulate for example 15 candles and crete indicators with this buffer like RSI, MACD etc?
@fearvalue1441
@fearvalue1441 Жыл бұрын
Hey Larry, I love your videos and had a specific question on this in particular. I am having the hardest time getting websocket data to run through a pandas dataframe. Any quick tips? (yes im an idiot)
@livedev
@livedev 3 жыл бұрын
Hello, first of all, tell you that your videos are very good and they have clarified me enough on the subject. Could you explain or point me to the video, if you have talked about the continuity of the data? It happens to me that I stop receiving on_message but the websocket is still connected, how do I resume the transmission? On the other hand, the websocket also closes if there is an internet cut, isn't it supposed that run_forever () should automatically reconnect? I am working with webscoketApp and binance. From already thank you very much.
@guguladitya
@guguladitya 2 жыл бұрын
Good. But if you want to get multiple stock data, then what to do
@kalyanstock8058
@kalyanstock8058 4 жыл бұрын
Nice video. If one needs data for multiple stocks, do you need to create multiple websockets?
@parttimelarry
@parttimelarry 4 жыл бұрын
I believe you can do a comma separated list of tickers, will need to double check the docs.
@releveitcandol1995
@releveitcandol1995 3 жыл бұрын
@@parttimelarry can you show how to do that? please I will like to know that
@lykiamusic
@lykiamusic Жыл бұрын
I have an API endpoint that I want to setup a web socket for so i can stream the data live. any ideas?
@LucaSpinello
@LucaSpinello 3 жыл бұрын
Great video thank you! Can you do another one on how to handle websocket with a sync please
@peterluro8649
@peterluro8649 7 ай бұрын
Great video! what is the most accurate realtime stock data library for Python? (Ideally with the best price)
@jacobdietz4545
@jacobdietz4545 Жыл бұрын
I typed the same thing as you but for some reason my on_open function is getting called. Do you have any ideas why? I've been googling for the past hour and can't find shit
@alerto2451
@alerto2451 3 жыл бұрын
Hey Larry how about some examples on python hyperthreading. Thanks!
@surajkhanra3767
@surajkhanra3767 4 жыл бұрын
Hi , can u make a video which can send and receive simultaneously without closing the socket ?
@Lorant1984
@Lorant1984 3 жыл бұрын
Where would you get data from non-US exchanges, please?
@vaibhavchogle2341
@vaibhavchogle2341 4 жыл бұрын
Hi , I am getting authentication failed message. i have tried generating keys from Alpaca but it is giving same message, what may be the issue ? C:\Users\Administrator\Desktop\Websocket>python app.py opened reaceived a message [{"ev":"status","status":"connected","message":"Connected Successfully"}] reaceived a message [{"ev":"status","status":"auth_failed","message":"authentication failed"}]
@akramdahmani7214
@akramdahmani7214 3 жыл бұрын
Great tutorial, thanks 👍
@mantisliving
@mantisliving 4 жыл бұрын
Will this end up costing $200/month? should i consider quandl or just use my ibkr api to get price data instead?
@kaleign
@kaleign 4 жыл бұрын
If you put a few bucks in an Alpaca brokerage account, then you have a funded account with access to their market data.
@davidsilverberg8327
@davidsilverberg8327 2 жыл бұрын
Thanks so much for this video man
@sanjeethnt5653
@sanjeethnt5653 3 жыл бұрын
Great job@Part Time Larry can you create the same one for SSE
@ibn-nafis3434
@ibn-nafis3434 4 жыл бұрын
Thanks Boss
@cunninghamb505
@cunninghamb505 4 жыл бұрын
What is I want to add TLS
@ywueeee
@ywueeee Жыл бұрын
this is 3yrs old, what's the current best way to do this?
@swapnilpatil2445
@swapnilpatil2445 4 жыл бұрын
Hello sir,will you please add more functionalities to create Stock Price Alert system with this data....Thanks in advance...
@parttimelarry
@parttimelarry 4 жыл бұрын
That's a great idea. I just posted a newer streaming market data video, so I think alerting would be a perfect addition. Next video I will render a chart and implement alerting.
@swapnilpatil2445
@swapnilpatil2445 4 жыл бұрын
@@parttimelarry Thanks a lot sir....Appreciate your work..
@arpitvijayvargiya1371
@arpitvijayvargiya1371 2 жыл бұрын
Thank you this.
@nikschuetz4112
@nikschuetz4112 2 жыл бұрын
hope you have refreshed your api key.. would blur some screens
@parttimelarry
@parttimelarry 2 жыл бұрын
I delete them after every video
@CarlosRomeroconnect
@CarlosRomeroconnect 4 жыл бұрын
Amazing!
@margeausoboti8864
@margeausoboti8864 4 жыл бұрын
LOVE this tutorial. I am having an issue though, any suggestions? When I go to authenticate my API key I get a response: zsh: command not found: action:subscribe,params:MYAPIKEY
@nickmotor650
@nickmotor650 10 ай бұрын
Anyone still using this? Does this still work? Trying to avoid unnecessary effort. Thanks in Advance!
@wtf9693
@wtf9693 2 жыл бұрын
brother ! i need your help plss..
@abhay1302
@abhay1302 3 жыл бұрын
hi larry, could you code me an app with streaming price distributed to multiple users at the same time, I will hire your services
@guillaumejames4222
@guillaumejames4222 4 жыл бұрын
Hi Larry, perhaps you have an answer, I cannot authenticate via the terminal. Thanks for your help. > (base) MacBook-Pro-GJ:~ gj$ wscat -c wss://alpaca.socket.polygon.io/stocks Connected (press CTRL+C to quit) < [{"ev":"status","status":"connected","message":"Connected Successfully"}] > {"action":"auth","params":"I use my key here"} < [{"ev":"status","status":"auth_failed","message":"authentication failed"}]
@rfyorfyo5022
@rfyorfyo5022 3 жыл бұрын
you did not show how to unsubscribe
@icakinser
@icakinser 4 жыл бұрын
Where can one download source code?
@parttimelarry
@parttimelarry 4 жыл бұрын
GitHub.com/financehacks
@parttimelarry
@parttimelarry 4 жыл бұрын
github.com/hackingthemarkets/alpaca-websockets
@k2icc
@k2icc 2 жыл бұрын
My paper account with a new authentication fails. Do I need some funding even on paper account? Thanks. "" opened received a message [{"ev":"status","status":"connected","message":"Connected Successfully"}] received a message [{"ev":"status","status":"auth_failed","message":"authentication failed"}] "
@sergioametheone1
@sergioametheone1 Жыл бұрын
Does anybody know what is this line ws = websocket.WebSocketApp(SOCKET...) etc? WebSocketApp is not defined in websocket!
@sergioametheone1
@sergioametheone1 Жыл бұрын
Answering myself here: It is not defined in websocket but in websocket-client.
Alpaca Market Data API (Part 1) - Streaming with Python and Websockets
26:52
GPT: KAMA Scalping Strategy in Python Makes 795%
21:00
Algo-trading with Saleh
Рет қаралды 22 М.
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 20 МЛН
УДИВИЛ ВСЕХ СВОИМ УХОДОМ!😳 #shorts
00:49
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 14 МЛН
Paper Trading with the Alpaca API
17:49
Part Time Larry
Рет қаралды 80 М.
Candlestick Pattern Recognition with Python and TA-Lib
24:11
Part Time Larry
Рет қаралды 116 М.
Websockets in Python
17:52
APMonitor.com
Рет қаралды 39 М.
Finding Breakout Candidates with Python and Pandas
29:33
Part Time Larry
Рет қаралды 71 М.
How To Build A Trading Bot In Python
18:46
CodeTrading
Рет қаралды 842 М.
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 20 МЛН