跳到主要内容

CLI Trading


Introduction

The Command Line Interface (CLI) provides a powerful set of commands for trading operations in Tealstreet. The CLI supports market orders, limit orders, stop orders, position management, and various utility commands.

Type help to see all available commands, or help <command> to see examples for a specific command.

Table of Contents

  1. Trading Commands
  2. Position Management
  3. Order Management
  4. Price Information
  5. Account Management
  6. Utility Commands
  7. Variables & Constants
  8. Command Chaining

Trading Commands

Buy Command

Places a buy order (market or limit).

Syntax:

buy <size> [at <price>] [reduce]
buy <symbol> <size> [at <price>] [reduce]
buy <symbol1,symbol2,...> <size> [at <price>] [reduce]

Examples:

buy $100
buy $100 reduce
buy WIFUSDT $100
buy WIFUSDT,ENAUSDT $100
buy WIFUSDT,ETHUSDT $100 reduce
buy $500 at 50000
buy BTCUSDT $500 at 50000 reduce

Parameters:

  • size: Order size in USD notional (e.g., $100, $1000.50)
  • symbol: Trading symbol(s) - optional, uses current symbol if not specified. Multiple symbols can be comma-separated.
  • at <price>: For limit orders, specifies the price. Supports absolute prices, percentages (+1%, -0.5%), or relative offsets (+100, -50).
  • reduce: Makes the order reduce-only

Sell Command

Places a sell order (market or limit).

Syntax:

sell <size> [at <price>] [reduce]
sell <symbol> <size> [at <price>] [reduce]
sell <symbol1,symbol2,...> <size> [at <price>] [reduce]

Examples:

sell $100
sell $100 reduce
sell WIFUSDT $100
sell WIFUSDT,ENAUSDT $100
sell WIFUSDT,ETHUSDT $100 reduce
sell $500 at 52000
sell BTCUSDT $500 at -1% reduce

Parameters:

  • size: Order size in USD notional (e.g., $100, $1000.50)
  • symbol: Trading symbol(s) - optional, uses current symbol if not specified. Multiple symbols can be comma-separated.
  • at <price>: For limit orders, specifies the price. Supports absolute prices, percentages (+1%, -0.5%), or relative offsets (+100, -50).
  • reduce: Makes the order reduce-only

Chase Command

Chases the price to execute orders at the best bid/ask prices. The chaser continuously updates limit orders to stay at the top of the book until filled.

Syntax:

chase <buy|sell> <size> [reduce]
chase <buy|sell> <symbol> <size> [reduce]
chase <buy|sell> <symbol1,symbol2,...> <size> [reduce]
chase <buy|sell> %all% <percentage>% reduce

Examples:

chase buy $100
chase buy $100 reduce
chase buy WIFUSDT $100
chase buy WIFUSDT,ENAUSDT $100
chase buy WIFUSDT,ETHUSDT $100 reduce
chase sell $120
chase sell $120 reduce
chase sell %all% 20% reduce
chase sell ETHUSDT,ENAUSDT $100

Parameters:

  • buy|sell: Order side (required)
  • size: Order size in USD notional (e.g., $100) or percentage of position (e.g., 20% - only for reduce-only orders)
  • symbol: Trading symbol(s) - optional, uses current symbol if not specified
  • %all%: Special keyword to target all positions of the specified side
  • reduce: Makes the order reduce-only

Scale Command

Creates a set of scaled orders distributed across a price range.

Syntax:

scale <buy|sell> <total_size> into <count> from <start_price> to <end_price> [reduce] [taker]

Examples:

scale buy 10 into 10 from 31000 to 32000
scale sell $10000 into 25 from 50000 to 48500 reduce
scale sell $10000 into 25 from 50000 to 48500 reduce taker
scale buy $1000 into 10 from -0.25% to -1%
scale sell 1 into 5 from +1% to 32000 reduce

Parameters:

  • buy|sell: Order side
  • total_size: Total size to distribute across orders (USD notional with $ prefix)
  • count: Number of orders to create
  • start_price: Starting price (absolute, percentage like +1%, -0.25%, or relative offset)
  • end_price: Ending price (same format as start_price)
  • reduce: Makes orders reduce-only
  • taker: Allows taker orders (default is post-only/maker)

Stop Command

Places stop orders (take profit or stop loss) for position management. The order type (TP or SL) is automatically determined based on the price relative to the current mark price.

Syntax:

stop at <price>
stop <buy|sell> at <price>
stop <size> at <price>
stop <buy|sell> <size> at <price>

Examples:

stop at 0.1%
stop at -100
stop at 18500
stop buy at +100
stop sell at 1%
stop $500 at 1%
stop buy $500 at 1%
stop sell 0.01 at -100

Parameters:

  • buy|sell: Order side - optional, inferred from current position if not specified. Required if you have both long and short positions.
  • size: Order size (USD notional with $ or raw amount) - optional, uses full position size if not specified (size=0 means infinity/full position)
  • at <price>: Stop trigger price (required). Supports:
    • Absolute price: 18500
    • Percentage from current: 0.1%, 1%, -0.5%
    • Relative offset: +100, -500

Position Management

Close Command

Closes positions with a market order.

Syntax:

close
close <long|short>
close <symbol>
close <long|short> <symbol>
close <long|short> <symbol1,symbol2,...>

Examples:

close
close short
close short WIFUSDT
close short WIFUSDT,ETHUSDT
close long
close long BTCUSDT
close BTCUSDT

Parameters:

  • long|short: Close only long or short positions (optional)
  • symbol: Trading symbol(s) to close (optional, uses current symbol if not specified). Multiple symbols can be comma-separated.

Nuke Command

Instantly closes all positions and/or cancels all orders across all symbols.

Syntax:

nuke
nuke all
nuke positions
nuke pos
nuke orders
nuke ord

Examples:

nuke
nuke all
nuke positions
nuke pos
nuke orders
nuke ord

Parameters:

  • No argument or all: Nuke everything (positions and orders)
  • positions or pos: Close all positions only
  • orders or ord: Cancel all orders only

Order Management

Cancel Command

Cancels orders for the current symbol.

Syntax:

cancel
cancel buys
cancel sells
cancel stops
cancel buy stops
cancel sell stops

Examples:

cancel
cancel buys
cancel sells
cancel stops
cancel buy stops
cancel sell stops

Parameters:

  • No argument: Cancel all orders for current symbol
  • buys: Cancel all buy limit orders
  • sells: Cancel all sell limit orders
  • stops: Cancel all stop orders (TP/SL)
  • buy stops: Cancel all buy stop orders
  • sell stops: Cancel all sell stop orders

Price Information

Last Price Command

Returns the current last traded price of given ticker(s).

Syntax:

last-price
last-price <symbol>
last-price <symbol1,symbol2,...>

Examples:

last-price
last-price BTCUSDT
last-price BTCUSDT,ETHUSDT

Mark Price Command

Returns the current mark price of given ticker(s).

Syntax:

mark-price
mark-price <symbol>
mark-price <symbol1,symbol2,...>

Examples:

mark-price
mark-price BTCUSDT
mark-price BTCUSDT,ETHUSDT

Index Price Command

Returns the current index price of given ticker(s).

Syntax:

index-price
index-price <symbol>
index-price <symbol1,symbol2,...>

Examples:

index-price
index-price BTCUSDT
index-price BTCUSDT,ETHUSDT

Account Management

Balance Command

Shows available balances including USD available margin, total balance, and spot coin holdings.

Syntax:

balance

Example:

balance

Account Command

Lists available accounts or switches to a different account.

Syntax:

account list
account <account_number>

Examples:

account list
account 0
account 1
account 2

Parameters:

  • list: Lists all available accounts with their index numbers
  • <account_number>: Switches to the specified account by index (0-based)

Switch Command

Switches the current trading instrument/symbol.

Syntax:

switch <symbol>

Examples:

switch btc
switch BTCUSDT
switch eth

Notes:

  • Symbol matching is flexible - you can use shorthand like btc and it will find BTCUSDT
  • Only one symbol can be switched to at a time

Utility Commands

Echo Command

Echoes the message back. Useful for testing variable substitution.

Syntax:

echo <message>

Example:

echo Hello World
echo Current position size: $size
echo Entry price: $entry

Help Command

Shows available commands or examples for a specific command.

Syntax:

help
help <command>

Examples:

help
help buy
help scale
help chase

Variables & Constants

The CLI supports special variables that are replaced with current position/market data:

Position Variables (Current Position)

VariableDescription
$sizeCurrent position size in contracts
$sizeusdCurrent position size in USD notional
$entryCurrent position entry price

Long Position Variables

VariableDescription
$lsizeLong position size in contracts
$lsizeusdLong position size in USD notional
$lentryLong position entry price

Short Position Variables

VariableDescription
$ssizeShort position size in contracts
$ssizeusdShort position size in USD notional
$sentryShort position entry price

Example Usage:

echo My position size is $size contracts worth $sizeusd USD
echo Entry price was $entry
stop at $entry

Price and Size Formats

Price Formats

The CLI supports various price formats:

FormatExampleDescription
Absolute50000Exact price
Percentage+1%, -0.25%Relative to current price
Offset+100, -500Added to current price

Size Formats

FormatExampleDescription
USD Notional$100, $1000.50Size in USD value
Percentage20%, 50%Percentage of position (reduce-only orders only, with chase command)
备注

For safety reasons, only USD notional sizes (with $ prefix) are supported for opening new positions. Percentage sizes are only available for reduce-only orders with the chase command.

Command Chaining

Sequential Execution

Chain multiple commands with semicolons. Commands execute one after another:

buy btc $200; sell sol $100
close long; close short
cancel; nuke positions

Parallel Execution

Prefix commands with @ to execute them in parallel (non-blocking):

@buy btc $200; @sell sol $100
@chase buy BTCUSDT $500; @chase sell ETHUSDT $300
提示

Parallel execution is useful when you want to place orders on multiple symbols simultaneously without waiting for each to complete.

Notes

  • All commands operate in the context of the current active symbol and account (shown at the top of the CLI)
  • Symbol matching is flexible - btc will match BTCUSDT, BTC-PERP, etc. based on your exchange
  • Multiple symbols can be specified with comma separation (e.g., BTCUSDT,ETHUSDT)
  • The CLI automatically handles symbol transformation and validation
  • Commands are case-insensitive for keywords (buy, sell, BUY, SELL all work)