yahoofinancelive / yliveticker Goto Github PK
View Code? Open in Web Editor NEWGet market data from Yahoo Finance websocket in near-real time.
License: MIT License
Get market data from Yahoo Finance websocket in near-real time.
License: MIT License
Seems like this library stopped working. I am not sure if this is python version or changes in the data format. Can you please help. Do you see similar issues.
I am using python 3.8.
Subject
I need some help on how to use the output of yliveticker and save to database
Question
First of all @alparamonov you have done a fantastic job by creating this tool ! I have tested it and it works good. But my question are ...
When I use the yliveticker the python code is stuck reading it, means it dont go to the next line. As yliveticker is contunously streaming data, how can i store it to sqlite db ? (means code is just executing on yliveticker it wont going ahead)
I have observed that when I use multiple tickers like 30-50 some ticks may be missing. i.e. on my test single ticker gave me approx 1-4 tick per sec and multiple ticker (like 30-50) might missing some of the ticks on same time window. Did you encountered this issue ? (I am using all F&O Tickers of NSE - Indian Stock Market)
I need your suggestion, I am planning to build an alert system and finally make it to full fledged algo system. Can I use yliveticker in Async or lets say concurrently ? ( I am very new to python !) my plan is as under.
Ticker_1 Ticker_2 Ticker_3 And so on upto 160 Tickers
| | |
Get live Data Get Live Data Get Live Data
| | |
Store to DB Store to DB Store to DB
| | |
Build OHLCV (5min) Build OHLCV (5min) Build OHLCV (5min)
| | |
Tech. Analysis Tech. Analysis Tech. Analysis
| | |
Get Alert Get Alert Get Alert
I am planning to complete all of the above tasks in approx 1-2 seconds. If 160 Tickers at one take time then I make different files each to running 30 or 40 or 50 tickers.
Can you guide me to help yliveticker with async or whatever is required for working simultaneously ?
As of now I tried using yahooquery and sqlite3 to make simple database system. But now i want to use live streaming of data using your application.
Eagerly waiting for your reply !
Thanks & Regards,
Vishvesh Upadhyay.
v0.3
Is this still working?
No data printed from direct samples provided.
Trading hours.
Hello,
Is there a way to update the ticker_names variable after the WebSocket has started running or does the connection have to close first?
For example, say I pass two tickers into the WebSocket at the open, and then at noon a third ticker meets my criteria to begin streaming the price data. Can I update my list of tickers from the open to include this third symbol without closing the connection I currently have or does it have to be closed?
Describe the bug
It is a good practice to send the primary output to stdout
while errors and log messages to stderr
. See also https://clig.dev/#the-basics
To Reproduce
Start YLiveTicker and you'll see everything going to stdout:
### connection is open ###
{'id':...
Expected behavior
The line ### connection is open ###
should go to stderr as well as any other log messages that are not json lines.
Environment (please complete the following information):
I think most of people will need it
As this lib continously report event based message, to convert into time series will make it more useful.
Or has anyone done that?
Describe the bug
I have noticed that if you listen to too many symbols using one YLiveTicker object, not all the updates get through. Or more specifically, the number of updates is not proportional to the number of tickers listened to.
To solve this I split the symbols I want to listen to into chucks and create a YLiveTicker object per check on a thread.
However, sometimes I get this output on one of the threads: (Added a dot on the second line to prevent markdown formating)
Connection is already closed.
.### connection is closed###
It seems like yahoo closes sockets.
Since I am listening to symbols where the market currently isn't open, yahoo might close the threads with only those symbols. I am not sure that this is the case though.
To Reproduce
Open a hundred threads/connections. See code below.
Expected behavior
Should not be closed. (lol)
Environment (please complete the following information):
Appendix
This is the code I use to open a connection on a thread and also the hotfix:
def getterThread(id, tickerList):
"""
Created a socket to yahoo listening for price changes to the tickers.
If the socket closes a new it is reopened. This is done 5 times.
More than this and yahoo might perm ban(?).
"""
print(id, "Stating thread")
for _ in range(5):
yliveticker.YLiveTicker(on_ticker=lambda msg: queue.append(msg), ticker_names=tickerList)
print(id, "socket closed, reopening!")
#Omitted some code
exit(0) #Exiting the whole program
Also
tickers = db.getAllSymbols()
for id, chunk in enumerate(chunks(tickers, 50)):
t = Thread(target=getterThread, args=(id, chunk))
t.start()
EDIT:
chunks function in the second codeblock (in the for-loop) takes a list and splits it into lists of 50 elements per list.
chuck(List) -> List[List]
Hello, I just tested your library for my simple project and I found two problem :
(1)I had to use downgrade package protobuf==3.20.*
I reinstalled the package.
(2)I found "JPY=X" work successfully on this time.
and "GC=F", "AAPL", "SI=F" is not working.
I know if its out of trading hours it is not working.
but when I go to yahoo finance I found "GC=F" is alive.
https://finance.yahoo.com/quote/GC%3DF/history?p=GC%3DF
you can see message "As of 09:34PM EDT. Market open."
and yliveticker cannot get "GC=F" price
I will paste my code here :
`
import yliveticker #Descriptors cannot be created directly error
def on_new_msg(ws,msg):
print(msg)
if name == 'main':
yliveticker.YLiveTicker(on_ticker=on_new_msg, ticker_names=["GC=F"])
`
this code output this message only:
[2022-08-12 10:46:19.526405] ### connection is open ###
for your reference, my time is korea standard time(KST, UTC+09:00)
Describe the bug
Don't know why but Futures do not update
To Reproduce
Ask for Gold Future, for example, GC=F
Expected behavior
Should get updates from GC=F price
Environment (please complete the following information):
Additional context
Works for tickers like AAPL. Fails for BZ=F, CL=F, ES=F, etc
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.