Fugle Realtime API 1.0 client library for Python
Project description
Fugle MarketData
Fugle MarketData API client library for Python
Installation
$ pip install fugle-marketdata
Importing
from fugle_marketdata import WebSocketClient, RestClient
Usage
The library is an isomorphic Python client that supports REST API and WebSocket.
REST API
client = RestClient(api_key = 'YOUR_API_KEY')
stock = client.stock # Stock REST API client
print(stock.intraday.quote(symbol="2330"))
WebSocket API
from fugle_marketdata import WebSocketClient, RestClient
def handle_message(message):
print(f'message: {message}')
def handle_connect():
print('connected')
def handle_disconnect(code, message):
print(f'disconnect: {code}, {message}')
def handle_error(error):
print(f'error: {error}')
def main():
client = WebSocketClient(api_key='YOUR_API_KEY')
stock = client.stock
stock.on("connect", handle_connect)
stock.on("message", handle_message)
stock.on("disconnect", handle_disconnect)
stock.on("error", handle_error)
stock.connect()
stock.subscribe({
"channel": 'trades',
"symbol": '2330'
})
if __name__ == "__main__":
main()
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fugle_marketdata-2.1.0.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for fugle_marketdata-2.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcf01a9c515299772d01f6f8d6a986ad2e136cb4a8cba8a4dc2e3d562fd7c7cd |
|
MD5 | 7ea98dc3556e1d0eac9adf18d2538e74 |
|
BLAKE2b-256 | b67d44d467ac736f115b11acb78720f4c6deb223757f8bfa9ad0bf63d4362eb6 |