Skip to main content

XNO API Library for Financial Data

Project description

XNO API Library

XNO API is a Python package for retrieving financial data and performing quantitative analysis, specifically optimized for the Vietnamese financial market. It provides a clean, modular interface to access data on stocks, derivatives, and backtesting tools for PnL and performance metrics.


📌 Key Features

  • 🔎 Simple interface to retrieve real-time and historical data for Vietnamese stocks and derivatives
  • 📈 Built-in support for performance metrics: Sharpe, Sortino, Max Drawdown, and more
  • 📊 Optimized PnL backtesting tools for derivatives with Vietnam-specific fee structures
  • 🧪 Compatible with pandas, NumPy for custom strategies and analysis
  • 🖼️ Easily extensible for visual output of strategies and metrics

📦 Installation

Install via pip:

pip install xnoapi

Or clone this repo:

git clone https://github.com/xnoproject/xnoapi.git
pip install ./xnoapi

After installation:

from xnoapi import client
from xnoapi.vn.data import stocks, derivatives
from xnoapi.vn.metrics import Metrics, Backtest_Derivates

client(apikey="your_api_key")

📚 Documentation


🚀 Usage Example

Retrieve and analyze Vietnamese stock & derivative data:

from xnoapi import client
from xnoapi.vn.data import stocks, derivatives

client(apikey="your_api_key")

# List of liquid stocks
stocks.list_liquid_asset()

# Historical data for VIC (Vingroup)
vic = stocks.get_hist("VIC", "1D")

# Historical data for VN30F1M derivative
vn30f1m = derivatives.get_hist("VN30F1M", "1m")

🧠 Available Modules

📊 Financial Data

  • xnoapi.vn.data.stocks

    • list_liquid_asset(): List of high-liquidity Vietnamese stocks.
    • get_hist(asset, frequency): Historical OHLCV data.
  • xnoapi.vn.data.derivatives

    • get_hist(asset, frequency): Derivative market data (e.g., VN30F1M).

📈 Metrics & Analytics

  • xnoapi.vn.metrics.Metrics:
    • Includes: Sharpe Ratio, Sortino Ratio, Max Drawdown, Avg Gain/Loss, Hit Ratio...
  • xnoapi.vn.metrics.Backtest_Derivates:
    • Backtesting logic for trading strategies with support for fee modeling.

🧪 Examples

Strategy Evaluation with Metrics

from xnoapi.vn.metrics import Metrics, Backtest_Derivates
from xnoapi.vn.data import derivatives
import numpy as np

def gen_position(df):
    # Volume-based signal generation
    return df.assign(
        position=np.sign(df["Close"] - df["Close"].rolling(20).median())
    )

# Get 1-minute historical data
df = derivatives.get_hist("VN30F1M", "1m")
df_pos = gen_position(df)

# Run backtest
backtest = Backtest_Derivates(df_pos, pnl_type="raw")
metrics = Metrics(backtest)

# Print Sharpe Ratio
print(metrics.sharpe())

# Plot PNL
backtest.daily_PNL().plot()

🤝 Credits

Maintained by the XNO Team.
Special thanks to contributors and financial data providers supporting the Vietnamese retail quant community.


📄 License

This project is licensed under the MIT License.
See LICENSE for full details.

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

xnoapi-0.1.14.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

xnoapi-0.1.14-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file xnoapi-0.1.14.tar.gz.

File metadata

  • Download URL: xnoapi-0.1.14.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for xnoapi-0.1.14.tar.gz
Algorithm Hash digest
SHA256 4b3393047c79696b5957e600066e062924591f77ad01925b17073412bb2e2b64
MD5 a1d5fc64f011d19f3bec36d9e67451dc
BLAKE2b-256 390b4e9bf763018c32568f3578c73ca7864fc6bdca4b5957adc28a4340be3b5b

See more details on using hashes here.

File details

Details for the file xnoapi-0.1.14-py3-none-any.whl.

File metadata

  • Download URL: xnoapi-0.1.14-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for xnoapi-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 4ad51ad283fe84bb604f60979ccbf4e0cbd956b0a65837fce67350c7f3c16f85
MD5 153f94e4de2d69cee465f3e727b48fad
BLAKE2b-256 6ad4a2e6cd4b13278ae078a6856fce9e5ea02252b3eb2e79442da891f62ae624

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