Skip to main content

DNSE OpenAPI SDK

Project description

DNSE OpenAPI Python SDK

Official Python SDK for integrating with DNSE OpenAPI.

Table of Contents

Overview

DNSE OpenAPI is an API-first trading platform that enables developers to integrate brokerage, trading, margin, and market data services into their own applications.

The DNSE Python SDK provides a lightweight client for securely interacting with DNSE OpenAPI REST endpoints. It handles request signing, authentication, and communication details, allowing developers to focus on building trading systems, automation strategies, and investment applications.

Installation

Requirements

  • Python 3.8+

Install from PyPI

pip install openapi-sdk

Upgrade:

pip install --upgrade openapi-sdk

Usage

Create a DNSEClient instance with your API credentials:

from dnse import DNSEClient

client = DNSEClient(
    api_key="your_api_key",
    api_secret="your_api_secret",
    base_url="https://openapi.dnse.com.vn",
    api_version="2026-05-07",
)

status, body = client.get_accounts(dry_run=False)
print(status, body)

The SDK sends the API version in the version header. If api_version is omitted, it defaults to 2026-01-01; it can also be set with the DNSE_API_VERSION environment variable.

Dry Run

Set dry_run=True to preview the request without sending it to DNSE servers. No network call will be executed.

client.get_accounts(dry_run=True)

Examples

Run any example from the sdk/python/examples directory:

python sdk/python/api/get_accounts.py

Trading API

Function Description
get_accounts.py Demonstrates how to retrieve all trading sub-accounts managed under the account corresponding to the API Key.
get_balances.py Demonstrates how to retrieve asset balances of a trading sub-account.
get_loan_packages.py Demonstrates how to retrieve available loan package codes. It is necessary for placing an order.
get_ppse.py Demonstrates how to retrieve buying power and selling power before placing an order.
get_orders.py Demonstrates how to retrieve intraday order book.
get_order_detail.py Demonstrates how to retrieve detailed information of a specific order (by ID).
get_order_history.py Demonstrates how to retrieve historical orders.
get_corporate_action_history.py Demonstrates how to retrieve corporate action history.
get_execution_detail.py Demonstrates how to retrieve detailed execution information of an order.
get_positions.py Demonstrates how to retrieve current holding positions.
get_positions_by_id.py Demonstrates how to retrieve detailed information of a specific position (by ID).
close_position.py Demonstrates how to close an existing position (by ID).
send_email_otp.py Demonstrates how to request an OTP sent to your registered email. The OTP is required for generating a trading token.
create_trading_token.py Demonstrates how to generate a Trading Token required for order placement.
post_order.py Demonstrates how to submit a new trading order.
cancel_order.py Demonstrates how to cancel an existing order.
replace_order.py Demonstrates how to modify an existing order.

Market Data API

Function Description
get_security_definition.py Demonstrates how to retrieve security definition and instrument details.
get_instruments.py Demonstrates how to retrieve the list of available trading instruments and their metadata.
get_trades.py Demonstrates how to retrieve historical trade data for a specific instrument.
get_latest_trade.py Demonstrates how to retrieve the most recent trade for a specific instrument.
get_ohlc.py Demonstrates how to retrieve OHLC (Open, High, Low, Close) data for a given time range.
get_close_price.py Demonstrates how to retrieve the latest closing price of a specific instrument.
get_working_dates.py Demonstrates how to retrieve trading working dates.

WebSocket Market Data

Function Description
sec_def.py Demonstrates how to receive real-time security definition updates.
quote.py Demonstrates how to receive real-time best bid and ask prices.
trade.py Demonstrates how to receive real-time trade (tick) data.
trade_extra.py Demonstrates how to receive real-time trade data with additional aggregated metrics.
ohlc.py Demonstrates how to receive real-time OHLC data.
ohlc_closed.py Demonstrates how to receive completed OHLC candle data.
expected_price.py Demonstrates how to receive expected price data during ATO and ATC sessions.
foreign_investor.py Demonstrates how to receive foreign investor trading data.
market_index.py Demonstrates how to receive market index data.

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

dnse_sdk_openapi-1.4.5.tar.gz (25.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dnse_sdk_openapi-1.4.5-py3-none-any.whl (51.4 kB view details)

Uploaded Python 3

File details

Details for the file dnse_sdk_openapi-1.4.5.tar.gz.

File metadata

  • Download URL: dnse_sdk_openapi-1.4.5.tar.gz
  • Upload date:
  • Size: 25.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for dnse_sdk_openapi-1.4.5.tar.gz
Algorithm Hash digest
SHA256 6ca205f731cb0e1302826d0983a84bce7df63a8c6334c30e3cc7bee625636d81
MD5 812d2a396ec9f3281981bc1a8135f77c
BLAKE2b-256 b30815e122887e3d2c4d1fe74ff63773754094f461677d45a366f2e8663b1cda

See more details on using hashes here.

File details

Details for the file dnse_sdk_openapi-1.4.5-py3-none-any.whl.

File metadata

File hashes

Hashes for dnse_sdk_openapi-1.4.5-py3-none-any.whl
Algorithm Hash digest
SHA256 227458332e85c95b16184195432d1a279f42993af2ddc9571ef0b9252789cb72
MD5 ccf140b3346cc9b2769daed12f91acd1
BLAKE2b-256 a6b77ade2c165ddedd69798b236a5fe072f885a93277fb87271ae80a2323f5c9

See more details on using hashes here.

Supported by

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