Katoshi Docs
  • Welcome
  • APP
    • Bots
      • Bot Creation
      • Bot Activation
      • Bot Settings
    • Strategies
      • Strategy Creation
      • Strategy Overview
      • Strategy Settings
      • Strategy Monetization
    • Portfolio
    • Terminal
    • Pricing
    • Alerts
    • Settings
  • API
    • Getting Started
    • Actions
      • Open Position
      • Close Position
      • Market Order
      • Limit Order
      • Stop Market Order
      • Scale Order
      • Modify TP/SL
      • Cancel TP/SL
      • Cancel Order
      • Close All
      • Cancel All
      • Clear All
      • Sell All
      • Set Leverage
      • Start Bot
      • Stop Bot
  • MCP
    • Introduction
    • Quickstart
    • Tools
    • Katoshi Agent Bot
  • Integrations
    • TradingView
Powered by GitBook
On this page
  • Example Request
  • coin*
  • is_buy
  • Sizes
  • size
  • size_usd
  • size_pct
  • slippage_pct
  • delay

Was this helpful?

  1. API
  2. Actions

Close Position

This section documents the close_position action

This action is used to close positions.

  • Positions will be closed immediately with a Market Order


Example Request

This example partially closes a long position on BTC using 50% of the current position size.

{
  "action": "close_position",
  "coin": "BTC",
  "is_buy": true,
  "size_pct": 0.5,
  "bot_id": BOT_ID,
  "api_key": "API_KEY"
}

coin*

This required parameter indicates which coin to use for the action.

"coin": "BTC"

is_buy

This parameter is optional, if not specified it will close either long or short positions.

This parameter indicates the direction to close the trade.

  • True will close a Long position

  • False will close a Short position

"is_buy": true

Sizes

3 size types are available to use: size, size_pct, size_usd.

size

This parameter indicates a size in contracts to use for the trade.

  • A value of 0.005 is equal to 0.005 BTC (requested coin)

"size": 0.005

size_usd

This parameter indicates a size in USD to use for the trade

  • A value of 100 is equal to $100 USD

"size_usd": 100

size_pct

This parameter indicates a size % of the current position to use when closing an order

  • A value of 0.1 is equal to 10% of current position size

  • Max. allowed value is 1 (100% of current position size)

"size_pct": 0.1

slippage_pct

This parameter indicates the Max. % slippage allowed for the trade to execute.

  • A value of 0.05 is equal to 5%

"slippage_pct": 0.05

Default slippage is set at 5% when not specified


delay

This parameter indicates a number of seconds to wait before triggering the action

  • A value of 5 is equal to a 5 seconds delay

  • Max. allowed delay is 10 seconds

"delay": 5
PreviousOpen PositionNextMarket Order

Last updated 1 month ago

Was this helpful?

You can whitelist coins allowed for trading in your

Bot Settings