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

kraken: use userref field AND reqid, utilize openOrders sub for most msging #368

Merged
merged 10 commits into from
Aug 3, 2022

Conversation

goodboy
Copy link
Contributor

@goodboy goodboy commented Jul 29, 2022

Bleh, this is some mucking about A proper set of changes to use the userref field instead of reqid in submissions over the ws api.

Turns out you can't can use both! currently though I'm in the process of trying to show their API support why it's that a weird design that should be changed in order to make client implementations less complex...

This moves fill handling, order edits, and cancellation event relaying to the openOrders sub block since after much discussion with support, this is more or less the big boi sub that indicates the most real-time state of their backend clearing engine.

@goodboy goodboy added broker-backend `brokerd`/`datad` related backend tech brokers-can-smbz features that suits should provide labels Jul 29, 2022
@goodboy goodboy changed the title WIP: use userref field over reqid... kraken WIP: use userref field over reqid... Jul 29, 2022
@goodboy goodboy force-pushed the kraken_ws_orders branch from c0617a5 to e6a3e8b Compare July 30, 2022 21:34
@goodboy goodboy force-pushed the kraken_userref_hackzin branch from c5bad85 to aa3a10c Compare July 30, 2022 21:35
goodboy added 4 commits July 31, 2022 14:35
Turns out you can pass both thus making mapping an ems `oid` to
a brokerd-side `reqid` much more simple. This allows us to avoid keeping
as much local dialog state but with still the following caveats:

- ok `editOrder` msgs must update the reqid<->txid map
- only pop `reqids2txids` entries inside the `cancelOrderStatus` handler
Why we need so many fields to accomplish passing through a dialog key to
orders is beyond me but this is how they do it with edits..

Allows not having to handle `editOrderStatus` msgs to update the dialog
key table and instead just do it in the `openOrders` sub by checking the
canceled msg for a 'cancel_reason' of 'Order replaced', in which case we
just pop the txid and wait for the new order the kraken backend engine
will submit automatically, which will now have the correct 'userref'
value we passed in via the `newuserref`, and then we add that new `txid`
to our table.
@goodboy goodboy force-pushed the kraken_userref_hackzin branch from aa3a10c to 1cbf45b Compare July 31, 2022 18:36
goodboy added 3 commits August 1, 2022 14:08
Since we figured out how to pass through ems dialog ids to the
`openOrders` sub we don't really need to do much with status updates
other then error handling. This drops `process_status()` and moves the
error handling logic into a status handler sub-block; we now just
info-log status updates for troubleshooting purposes.
The (partial) fills from this sub are most indicative of clears (also
says support) whereas the msgs in the `ownTrades` sub are only emitted
after the entire order request has completed - there is no size-vlm
remaining.

Further enhancements:
- this also includes proper subscription-syncing inside `subscribe()` with
  a small pre-msg-loop which waits on ack-msgs for each sub and raises any
  errors. This approach should probably be implemented for the data feed
  streams as well.
- configure the `ownTrades` sub to not bother sending historical data on
  startup.
- make the `openOrders` sub include rate limit counters.
- handle the rare case where the ems is trying to cancel an order which
  was just edited and hasn't yet had it's new `txid` registered.
@goodboy goodboy marked this pull request as ready for review August 2, 2022 00:05
@goodboy goodboy changed the title kraken WIP: use userref field over reqid... kraken WIP: use userref field AND reqid, utilize openOrders sub for most msging Aug 2, 2022
@goodboy goodboy changed the title kraken WIP: use userref field AND reqid, utilize openOrders sub for most msging kraken: use userref field AND reqid, utilize openOrders sub for most msging Aug 2, 2022
Copy link
Contributor

@guilledk guilledk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Havent tested but looks good, hehe also more pydantic removals eh?

@goodboy
Copy link
Contributor Author

goodboy commented Aug 2, 2022

hehe also more pydantic removals eh?

🤫

@goodboy goodboy merged commit ef5829a into kraken_ws_orders Aug 3, 2022
@goodboy goodboy deleted the kraken_userref_hackzin branch August 3, 2022 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
broker-backend `brokerd`/`datad` related backend tech brokers-can-smbz features that suits should provide
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants