Skip to main content

vDatafeed: A Python wrapper for Viet Nam Datafeed API

Project description

vDatafeed

vDatafeed: A Python wrapper for Viet Nam Datafeed API

PyPI - Version Python Version PyPI - Downloads License: MIT

Installation

pip install vdatafeed

Usage

Financial data

from vdatafeed import Datafeed, Config, EnumDatafeed


datafeed = Datafeed(
    datafeed=EnumDatafeed.SSI.value,
    config=Config(
        ssi_datafeed_id="<SSI_DATAFEED_ID>",
        ssi_datafeed_secret="<SSI_DATAFEED_SECRET>"
    )
)

# Get list of instruments
datafeed.api.get_instruments()
# Get instrument details
datafeed.api.get_instrument_details("SSI")
# Get list of indices
datafeed.api.get_indices()
# Get list of instruments in an index
datafeed.api.get_indices_instruments("VN30")
# Get daily instruments info
datafeed.api.get_daily_instruments_info(instrument="SSI", from_date="2024-09-01", to_date="2024-09-10")
# Get daily all instruments info
datafeed.api.get_daily_instruments_info(from_date="2024-09-10", to_date="2024-09-10")
# Get daily indices info
datafeed.api.get_daily_indices_info(index="VN30", from_date="2024-09-01", to_date="2024-09-10")
# Get end of day OHLCV
datafeed.api.get_endofday_ohlcv(instrument="SSI", from_date="2024-09-01", to_date="2024-09-10")
# Get intraday OHLCV
datafeed.api.get_intraday_ohlcv(instrument="SSI", from_date="2024-09-01", to_date="2024-09-10")

Streaming data

import asyncio
from vdatafeed import Datafeed, Config, EnumDatafeed


datafeed = Datafeed(
    datafeed=EnumDatafeed.SSI.value,
    config=Config(
        ssi_datafeed_id="<SSI_DATAFEED_ID>",
        ssi_datafeed_secret="<SSI_DATAFEED_SECRET>"
    )
)



def on_trade_message(msg):
    """
    Handle the incoming trade message.
    Args:
        msg (str): The message received.
    Returns:
        None
    """
    print(f"TRADE: {msg}")


def on_quote_message(msg):
    """
    Handle the incoming quote message.
    Args:
        msg (str): The message received.
    Returns:
        None
    """
    print(f"QUOTE: {msg}")


asyncio.run(
    datafeed.hub.listen(
        input("Please select Symbol(SSI)/Index(VNINDEX/VN30) or list(SSI,VCB): "),
        on_trade_message,
        on_quote_message
    )
)

MIT License

Copyright (c) 2024 Quant.vn

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

vdatafeed-1.1.5.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

vdatafeed-1.1.5-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file vdatafeed-1.1.5.tar.gz.

File metadata

  • Download URL: vdatafeed-1.1.5.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for vdatafeed-1.1.5.tar.gz
Algorithm Hash digest
SHA256 4b6fbb6132500a4a0363f84cd12f942c3128cace2c24444ef90795830c9312e2
MD5 98bb8ffcea14a730e9a8b1855eaa5989
BLAKE2b-256 183f1ce7b9d03b10f738213f1d88a70dd1bfdf74d1bf9556e5a2c212dfb460ed

See more details on using hashes here.

File details

Details for the file vdatafeed-1.1.5-py3-none-any.whl.

File metadata

  • Download URL: vdatafeed-1.1.5-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for vdatafeed-1.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 eac241b159ad369a076e2777d644b60de16e9a42493bb06778caf2ebc1b526d8
MD5 b74ccb5cb9e747c4b0140d66d8a03a7e
BLAKE2b-256 099e0e19135dcf801613ec3bea3a9120808595606bd1acc12fd7a6193971e505

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