Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Factored WebSocket handling out of OrderBook to allow for easy creation of custom order book implementations #3

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

Merged
csko merged 1 commit into csko:master from tmitrovich:feature_ticker_channel_listener
Sep 28, 2017

Conversation

@tmitrovich
Copy link
Contributor

@tmitrovich tmitrovich commented Sep 8, 2017

For my own work I needed to modify your code to subscribe to the ticker channel instead of the full orderbook. Your OrderBook code was already well segmented into code that dealt with the Websocket and code that implemented the actual order book. So rather than modify your code I factored the Websocket code out into an abstract base class and then changed your OrderBook class to inherit from it. Now anyone with your API wrapper can easily inherit from WebSocketFeedListener to create their own order book, ticker, or level2 implementations without having to modify your API.

Since the OrderBook still has the same class signature as it originally did, your tests cases all pass without any changes to them. Happy to make changes if you see something you don't like. Details on each change below:


WebSocketFeedListener


Factored the web socket code away from the actual orderbook
implementation. The new WebSocketFeedListener is an abstract base class
that handles the websocket itself including:

  • Connect
  • Disconnect
  • Send / Receive messages
  • Subscribing to channels
  • Leveraging the trade log file
  • Async Context Manager calls

WebSocketFeedListener inherits from ABC and has a single @AbstractMethod
handle_message(self), which must be implemented by subclasses.


OrderBook


Removed all WebSocket manipulation from OrderBook and left just the
OrderBook implementation. OrderBook now inherits from
WebSocketFeedListener and implements handle_message.

Copy link

codecov bot commented Sep 8, 2017
edited
Loading

Codecov Report

Merging #3 into master will decrease coverage by 1.05%.
The diff coverage is 92.3%.

Impacted file tree graph

@@ Coverage Diff @@
## master #3 +/- ##
=========================================
- Coverage 97.26% 96.2% -1.06% 
=========================================
 Files 4 5 +1 
 Lines 475 501 +26 
=========================================
+ Hits 462 482 +20 
- Misses 13 19 +6
Impacted Files Coverage Δ
gdax/__init__.py 100% <100%> (ø) ⬆️
gdax/orderbook.py 91.95% <83.33%> (-2.14%) ⬇️
gdax/websocket_feed_listener.py 92.95% <92.95%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb4d93b...b4d4422. Read the comment docs.

Copy link
Owner

@csko csko left a comment

Choose a reason for hiding this comment

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

please change the commit message so that the first line describes what was done

Copy link
Owner

csko commented Sep 16, 2017

Thanks!

Code looks good, I'd just ask you to change the commit message so that it includes a one-liner of what it does. Right now it shows up as just a bunch of asterisks in the log.

Copy link
Contributor Author

Will do - sorry about that.

OrderBook now inherits from. This allows easy creation of new types of
listeners for the GDAX websocket API.
*****************************
*** WebSocketFeedListener ***
*****************************
Factored the web socket code away from the actual orderbook
implementation. The new WebSocketFeedListener is an abstract base class
that handles the websocket itself including:
- Connect
- Disconnect
- Send / Receive messages
- Subscribing to channels
- Leveraging the trade log file
- Async Context Manager calls
WebSocketFeedListener inherits from ABC and has a single @AbstractMethod
handle_message(self), which must be implemented by subclasses.
******************************
********* OrderBook **********
******************************
Removed all WebSocket manipulation from OrderBook and left just the
OrderBook implementation. OrderBook now inherits from
WebSocketFeedListener and implements handle_message.
@tmitrovich tmitrovich force-pushed the feature_ticker_channel_listener branch from 96ba72b to b4d4422 Compare September 19, 2017 14:09
Copy link
Contributor Author

I amended the commit message. Will that work?

@csko csko merged commit fbea1dc into csko:master Sep 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@csko csko csko requested changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /