Protocol buffer from Yahoo Finance API
I'm trying to pull data (specifically "price") from a websocket (wss://streamer.finance.yahoo.com/), and it works great. The problem is that the data is in a protocol buffer format. I have the .proto file to decode this data, but I don't actually understand how to do it in C#. It works on an online protobuf decoder (https://www.protobufpal.com/), so I know there is no issue with my .proto file or the data (see image). I tried a few different ways but I just can't get it to work. I'm a beginner in C# so don't know all the concepts.
31 Replies
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
i'm using https://github.com/protobuf-net/protobuf-net for my current project, it also has a source generator package to generate models from .proto files
GitHub
GitHub - protobuf-net/protobuf-net: Protocol Buffers library for id...
Protocol Buffers library for idiomatic .NET . Contribute to protobuf-net/protobuf-net development by creating an account on GitHub.
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Well, I don't know how to get that base64 protobuf thing to turn into an object with the property "price". Or like any way to access "price" (see first screenshot). I suppose "doesn't work" is the wrong wording, more like I just can't figure it out
I've seen some tutorials and people mentioning this. Maybe I should just go with this instead of googles version. Going to try it
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
it isn't
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
It's just a websocket right now
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
uh idk about that, the websocket works fine
I just kind of stole it of a tutorial
TeBeCo
a github repo link might help if you push that code above
Quoted by
<@689473681302224947> from #Protocol buffer from Yahoo Finance API (click here)
React with ❌ to remove this embed.
GitHub
GitHub - izzeww/YahooFinanceWebSocket
Contribute to izzeww/YahooFinanceWebSocket development by creating an account on GitHub.
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
ye
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Those strings you see, they are base64 protobuf:s
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
I need to convert them into objects, or JSON or something like that, so I can access the properties (like "price")
no
this part is the issue
I'm gonna read up a bit on protobuf-net and try it out
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
thanks, gonna try that
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
wooah
TeBeCo
Convert.FromBase64
then give it to proto reader/serializer
Quoted by
<@689473681302224947> from #Protocol buffer from Yahoo Finance API (click here)
React with ❌ to remove this embed.
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
think it's supposed to be that way
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
true, seems weird
ye it's an index, so it's right
You can change it to something else if you want, like "ES=F"
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
thanks you so much, didn't realize it was that "simple" (really very hard, for me)