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

feat: add websocket module to py-sdk #117

Merged
merged 12 commits into from
Sep 5, 2022
Merged

feat: add websocket module to py-sdk #117

merged 12 commits into from
Sep 5, 2022

Conversation

matthiasmatt
Copy link
Collaborator

@matthiasmatt matthiasmatt commented Aug 31, 2022

Fix #116

With this, user can now open websocket object and have a multiprocessing queue filled with events:

from nibiru.websocket import Events

ws = NibiruWebsocket(
    network,
    captured_events_type=[
        Events.MarkPriceChanged,
        Events.PositionChangedEvent,
    ],
)
ws.start() # async start the process

Events included are:

Perp events

  • PositionChangedEvent = "nibiru.perp.v1.PositionChangedEvent"
  • PositionLiquidatedEvent = "nibiru.perp.v1.PositionLiquidatedEvent"
  • FundingRateChangedEvent = "nibiru.perp.v1.FundingRateChangedEvent"
  • PositionSettledEvent = "nibiru.perp.v1.PositionSettledEvent"

Vpool events

  • ReserveSnapshotSavedEvent = "nibiru.vpool.v1.ReserveSnapshotSavedEvent"
  • SwapQuoteForBaseEvent = "nibiru.vpool.v1.SwapQuoteForBaseEvent"
  • MarkPriceChanged = "nibiru.vpool.v1.MarkPriceChanged"

nibiru/utils.py Outdated Show resolved Hide resolved
@onikonychev
Copy link
Collaborator

Question: is there any event deserialization so far? Will user get price as float or as a string? Or this is a scope if the next PR?
And it looks tests are failing.

nibiru/utils.py Outdated Show resolved Hide resolved
@matthiasmatt
Copy link
Collaborator Author

Question: is there any event deserialization so far? Will user get price as float or as a string? Or this is a scope if the next PR? And it looks tests are failing.

I'll do that in another PR. I'll tie in the deserialization with the #118 and #119 so we can leverage proto to already know the types of the fields

nibiru/event_specs.py Outdated Show resolved Hide resolved
nibiru/websocket.py Outdated Show resolved Hide resolved
nibiru/utils.py Outdated Show resolved Hide resolved
nibiru/websocket.py Show resolved Hide resolved
nibiru/websocket.py Outdated Show resolved Hide resolved
nibiru/websocket.py Outdated Show resolved Hide resolved
nibiru/websocket.py Outdated Show resolved Hide resolved
nibiru/websocket.py Show resolved Hide resolved
@onikonychev
Copy link
Collaborator

Changes look good but tests are still failing.

@matthiasmatt matthiasmatt merged commit 06fdd8d into master Sep 5, 2022
@matthiasmatt matthiasmatt deleted the mat/websocket branch September 5, 2022 12:03
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.

feat (websocket): Create a weboscket agent to read select events
3 participants