Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add streaming endpoints for DEEP, Last and TOPS. #32

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

husafan
Copy link

@husafan husafan commented Nov 2, 2019

Adds a socketio package defining a SocketIO IEX Client.

The client multiplexes over a single SocketIO connection with IEX. It defines methods for getting namespaces corresponding three streaming endpoints: deep, last and tops. Multiple handlers can be attached to each namespace using the #SubscribeTo method, which takes in a handler and a variadic list of exchange symbols being subscribed to.

There is no documentation at the moment, but there are a couple of examples.

fixes #1

The SocketioClient will be responsible for negotiating a web socket
connection and streaming results.
This should work for JSON responses as well as the only difference is
they come one at a time and do not have a length prefix.
This component is responsible for performing the handshake and returning an
initialized websocket connection.
Multiple threads can receive incoming message copies from the Websocket
connection. Also, multiple threads can safely call WriteMessage.
The namespace is responsible for translating between arbitrary
incoming messages for a given SocketIO endpoint and a specific iex message
type, such as TOPS. It is also responsible for forwarding the decoded
messages to all concerned listeners. Lastly, it filters out messages that
given listeners are not concerned with. All this allows multiplexing of
endpoint subscriptions over the same SocketIO connection.

Also simplifies encoding to handle only messages of known formats rather than
trying to handle arbitrary structs in a consistent manner.

Adds a subUnsubMsgFactory function type for generating subscribe and unsubscribe
messages for symbols across the given endpoint types.
PacketData contains the standard SocketIO info.
It turns out the connection can be initialized with two GET requests.

Also added an example demonstrating an IEX SocketIO negotiation and added
cookie support to the default client.
Replace the public API with callbacks.

Also, simplify the namespace by removing "Connections."
Messages from IEX uppercase symbol strings. Also add a quick example.
@coveralls
Copy link

coveralls commented Nov 2, 2019

Coverage Status

Coverage remained the same at 82.133% when pulling c11974b on husafan:master into aef4b1f on timpalpant:master.

Because the DEEP endpoint only allows subscribing to one symbol at a
time, this allows all code paths to share the same logic rather than
special-casing DEEP.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement WebSocket streaming APIs
2 participants