Skip to main content

Barchart Openfeed Example Client for Python

Project description

Openfeed SDK for Python

This SDK encapuslates the openfeed proto objects and faciliates client connections to openfeed servers.

Build

PyPI

Installation

pip install openfeed

Example Usage

import openfeed

# new client with credentials
of_client = openfeed.OpenfeedClient("username", "password")

# optional state handlers
of_client.on_error = lambda x: print("Error:", x)
of_client.on_connected = lambda x: print("Connected")
of_client.on_disconnected = lambda x: print("Disconnected")

# attach a global message handler
of_client.on_message = lambda x: print("Global Message:", x)

# sub to markets by symbol
def on_message(msg):
    print("Market Data: ", msg)

of_client.add_symbol_subscription("AAPL", callback=on_message)

# sub to markets by exchange
of_client.add_exchange_subscription("NYSE", callback=on_message)

of_client.start()

Expected Output

of-client: Connected
of-client: Market Data:  subscriptionResponse
of-client: Market Data:  marketSnapshot
of-client: Market Data:  marketUpdate
of-client: Market Data:  marketUpdate

Openfeed Documentation

Subscription Types

Openfeed supports many levels of subscription types.

OHLC

of_client.add_exchange_subscription(["NYSE"], callback=on_message, subscription_type=["OHLC"])
{
  marketId: 5389879102616877808
  symbol: "AAPL"
  open {
    price: 1205600
  }
  high {
    price: 1205600
  }
  low {
    price: 1205247
  }
  close {
    price: 1205490
  }
  volume: 43635
  priceVolume: 5259897.1422
  numberTrades: 224
  tradeDate: 20201116
  transactionTime: 1605547921000000000
  openStartTime: 1605547885850000000
  closeEndTime: 1605547920964000000
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openfeed-1.4.0.tar.gz (37.0 kB view details)

Uploaded Source

Built Distribution

openfeed-1.4.0-py3-none-any.whl (38.3 kB view details)

Uploaded Python 3

File details

Details for the file openfeed-1.4.0.tar.gz.

File metadata

  • Download URL: openfeed-1.4.0.tar.gz
  • Upload date:
  • Size: 37.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for openfeed-1.4.0.tar.gz
Algorithm Hash digest
SHA256 bcd244fe8679d0fac5d70b5518044e32b6d462a5aa6b7bd9ff6e9a214611e7be
MD5 b65523a59219d7be08f59711f066629d
BLAKE2b-256 390fa19a521811b91817a9e2d0afa91cd137a41ab852b9e862097b323d19f41e

See more details on using hashes here.

File details

Details for the file openfeed-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: openfeed-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 38.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for openfeed-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a1ac95b03124458cff6995e8532693939776860d403329795c7e00e66d26722
MD5 d22f65bcc878a600c4be418592d27ad4
BLAKE2b-256 0413b561b0cf1fbe3a12a87aef0ec22e12c7f05233cc9839dcf87eecfddab624

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page