Python Weekly #4
Python crypto exchange feed, learning state variables, & 7 exciting Python GitHub repos
Hello world! Welcome to another edition of the Web3 Python Weekly. Each week we’ll bring you one exercise, tweet, & video to keep you up to date on all things happening at the crossroads of Web3 & python. Thanks for joining us!
Python Crypto Exchange Feed Handler
It was Christmas this past week so we don’t have a featured breakdown, but we’ll still bring you the Python hotness - as we always do!
I found this repo over the weekend and thought it’d be worth the share. This handles multiple cryptocurrency exchange data feeds and returns normalized and standardized results to client registered callbacks for events like trades, book updates, ticker updates, etc. Utilizes websockets when possible, but can also poll data via REST endpoints if a websocket is not provided.
Basic Function
Create a FeedHandler object and add subscriptions. For the various data channels that an exchange supports, you can supply callbacks for data events, or use provided backends (described below) to handle the data for you. Start the feed handler and you're done!
Usage Example
from cryptofeed import FeedHandler
# not all imports shown for clarity
fh = FeedHandler()
# ticker, trade, and book are user defined functions that
# will be called when ticker, trade and book updates are received
ticker_cb = {TICKER: ticker}
trade_cb = {TRADES: trade}
gemini_cb = {TRADES: trade, L2_BOOK: book}
fh.add_feed(Coinbase(symbols=['BTC-USD'], channels=[TICKER], callbacks=ticker_cb))
fh.add_feed(Bitfinex(symbols=['BTC-USD'], channels=[TICKER], callbacks=ticker_cb))
fh.add_feed(Poloniex(symbols=['BTC-USDT'], channels=[TRADES], callbacks=trade_cb))
fh.add_feed(Gemini(symbols=['BTC-USD', 'ETH-USD'], channels=[TRADES, L2_BOOK], callbacks=gemini_cb))
fh.run()
The full Github Repo can be found here.
Curve Vyper Tutorial Lesson 3: State Variables by Gerrit Hall
Interested in Getting Started?
That's it for today & see ya next time! If you liked this issue, be sure to share!