entradex-cli
v0.0.3
Published
CLI for DNSE API - A Vietnamese securities trading platform.
Readme
entradex-cli
CLI for DNSE API - A Vietnamese securities trading platform.
Installation
bun installConfiguration
The CLI requires API credentials to authenticate with the DNSE API. You can provide credentials in three ways (in order of priority):
1. Config File (Recommended)
Store credentials locally in ~/.entradex-cli/config.json:
bun run index.ts config set --key "your-api-key" --secret "your-api-secret"
# Or run interactively:
bun run index.ts config setView current configuration:
bun run index.ts config getClear stored credentials:
bun run index.ts config clear2. Environment Variables
export DNSE_API_KEY="your-api-key"
export DNSE_API_SECRET="your-api-secret"3. Command Line Options
bun run index.ts --api-key "your-api-key" --api-secret "your-api-secret" <command>Usage
bun run index.ts [global-options] [command]Global Options
| Option | Description |
|--------|-------------|
| --api-key <key> | DNSE API key |
| --api-secret <secret> | DNSE API secret |
| --base-url <url> | DNSE API base URL (default: https://openapi.dnse.com.vn) |
| --debug | Enable debug mode to see request details |
| -V, --version | Output the version number |
| -h, --help | Display help for command |
Commands
Config
Manage API credentials configuration.
bun run index.ts config set [--key <key>] [--secret <secret>] [--url <url>]
bun run index.ts config get
bun run index.ts config clearAccount
Account management commands.
# List all accounts
bun run index.ts account list
# Get account balances
bun run index.ts account balances <accountNo>
# Query loan packages
bun run index.ts account loan-packages <accountNo> <marketType> [--symbol <symbol>]Trade
Trading operations.
# Place a new order
bun run index.ts trade order <marketType> <symbol> <side> <orderType> <price> <quantity> <tradingToken> [--price-stop <price>]
# Modify an existing order
bun run index.ts trade modify <accountNo> <orderId> <marketType> <symbol> <side> <orderType> <price> <quantity> <tradingToken> [--price-stop <price>]
# Cancel an order
bun run index.ts trade cancel <accountNo> <orderId> <marketType> <tradingToken>Parameters:
marketType: Market type (e.g.,HOSE,HNX,UPCOM)symbol: Stock symbol (e.g.,VIC,VCB)side: Order side (buyorsell)orderType: Order type (e.g.,lo,lo_to,mp,mok)price: Order pricequantity: Order quantitytradingToken: Trading token (obtained viadnse auth create-token)
Order
Order management commands.
# List current orders
bun run index.ts order list <accountNo> <marketType>
# Get order details
bun run index.ts order detail <accountNo> <orderId> <marketType>
# Get order history
bun run index.ts order history <accountNo> <marketType> [--from <date>] [--to <date>] [--page-size <size>] [--page-index <index>]
# Get executed deals
bun run index.ts order deals <accountNo> <marketType>Market
Market data commands.
# Get security definition
bun run index.ts market secdef <symbol> [--board-id <id>]
# Get PPSE (Price Priority Stream Event) data
bun run index.ts market ppse <accountNo> <marketType> <symbol> <price> <loanPackageId>Auth
Authentication and token management.
# Send OTP via email
bun run index.ts auth send-otp <email> [--otp-type <type>]
# Create trading token
bun run index.ts auth create-token <otpType> <passcode>Dry Run
Test commands without making actual API calls.
bun run index.ts dry-run accounts
bun run index.ts dry-run balances <accountNo>
bun run index.ts dry-run order <marketType> <symbol> <side> <orderType> <price> <quantity> [--price-stop <price>]Examples
Setting up credentials
bun run index.ts config setCheck account balances
bun run index.ts account balances 123456Place a buy order
# First, create a trading token
bun run index.ts auth send-otp [email protected]
# Enter OTP when received
bun run index.ts auth create-token smart_otp YOUR_PASSCODE
# Place the order
bun run index.ts trade order HOSE VIC buy lo 15000 100 YOUR_TRADING_TOKENView order history
bun run index.ts order history 123456 HOSE --from 2025-01-01 --to 2025-01-31 --page-size 50Debug mode
# Enable debug to see request details
bun run index.ts --debug account listDevelopment
This project was created using bun init in bun v1.2.22. Bun is a fast all-in-one JavaScript runtime.
Project Structure
entradex-cli/
├── index.ts # CLI entry point
├── config.ts # Configuration management
├── commands/ # CLI command modules
│ ├── account.ts
│ ├── auth.ts
│ ├── config.ts
│ ├── dry-run.ts
│ ├── market.ts
│ ├── order.ts
│ ├── trade.ts
│ └── utils.ts
└── sdk/ # DNSE API client
├── client.ts
└── common.ts