Fugle Realtime API 1.0 client library for Python
Project description
[![PyPI version][pypi-image]][pypi-url] [![Python version][python-image]][python-url] [![Build Status][action-image]][action-url]
Fugle MarketData
[![PyPI version][pypi-image]][pypi-url] [![Python version][python-image]][python-url] [![Build Status][action-image]][action-url]
Fugle MarketData API client library for Node.js
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
# def main():
# client = RestClient(api_key=TOKEN)
# stock = client.stock
# print(stock.intraday.quote(symbol="2330"))
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
import asyncio
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}')
async 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)
await stock.connect()
stock.subscribe({
"channel": 'trades',
"symbol": '2330'
})
if __name__ == "__main__":
asyncio.run(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-1.0.1.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for fugle_marketdata-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f3354782ded190503881d33a3d0ad3b933758770cf889e3eb522fe8db623267 |
|
MD5 | 9046cd91fc0a9f20f91a7d9e07f3d482 |
|
BLAKE2b-256 | 2277877ec5b4c5e5b86ea646aa8bd5181a5137c1af41102a46d82d79cc3e079e |