Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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()

Error Handling

The library provides a custom FugleAPIError exception for API-related errors, which includes detailed debugging information.

Catching API Errors

from fugle_marketdata import RestClient, FugleAPIError

client = RestClient(api_key='YOUR_API_KEY')

try:
    data = client.stock.intraday.quote(symbol="2330")
except FugleAPIError as e:
    # Access error details for debugging
    print(f"Error: {e.message}")
    print(f"URL: {e.url}")
    print(f"Status Code: {e.status_code}")
    print(f"Request Params: {e.params}")
    print(f"Response: {e.response_text}")

Error Attributes

The FugleAPIError exception provides the following attributes:

  • message: Error description
  • url: The API endpoint that was called
  • status_code: HTTP status code (if available)
  • params: Request parameters that were sent
  • response_text: Raw response text from the API (truncated to 200 chars)

Common Error Scenarios

HTTP Errors (4xx, 5xx):

try:
    data = client.stock.intraday.quote(symbol="INVALID_SYMBOL")
except FugleAPIError as e:
    if e.status_code == 404:
        print("Symbol not found")
    elif e.status_code >= 500:
        print("Server error, please try again later")

Network Errors:

try:
    data = client.stock.intraday.quote(symbol="2330")
except FugleAPIError as e:
    if e.status_code is None:
        print("Network error occurred")

License

MIT

Metadata

Release files for fugle-marketdata 2.7.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fugle-marketdata 2.7.0rc1
File Size Uploaded Provenance Actions
fugle_marketdata-2.7.0rc1.tar.gz 11.9 kB Without provenance Details for fugle_marketdata-2.7.0rc1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fugle-marketdata 2.7.0rc1
File Interpreter ABI Platform Actions
fugle_marketdata-2.7.0rc1-py3-none-any.whl Python 3 none any Details for fugle_marketdata-2.7.0rc1-py3-none-any.whl

Total release size: 30.2 kB

Release files / fugle_marketdata-2.7.0rc1.tar.gz

Download URL fugle_marketdata-2.7.0rc1.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9175b1b1c1f8d7b4edf9596a6cdf14e03bfc40248f758fee1a2c258bbb9b3c0e
BLAKE2b-256 checksum
How to use checksums
9af74f15364736c1f25f6c0bb73f36a7e69d59ea0085adfcbf125b420dab8e50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.14.7 Linux/6.17.0-1022-azure

Release files / fugle_marketdata-2.7.0rc1-py3-none-any.whl

Download URL fugle_marketdata-2.7.0rc1-py3-none-any.whl
Size 18.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a5547cef48b0578944d0eb77d47cfc7a2e89d6fafd03b482efbf7d78e7330bae
BLAKE2b-256 checksum
How to use checksums
43ad5a3197b0b3990a7f3817fe42db5cd9a78813a4eb2cc1d962a5c09aafb827
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.14.7 Linux/6.17.0-1022-azure

Security for fugle-marketdata 2.7.0rc1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page