Skip to content

How to set Take Profit & Stop Loss programmatically? #280

@Kaanori

Description

@Kaanori

Hey team,

I'm building a trading bot using the Hyperliquid Python SDK (v0.22.0) and need to set TP/SL for orders programmatically.

Current situation:

  • I can place orders successfully via exchange.order()
  • I can modify orders via exchange.modify_order()
  • BUT: Neither method has parameters for tp_px or stop_px

What I've tried:

  1. ✗ SDK order() method - no TP/SL parameters available
  2. ✗ SDK modify_order() method - no TP/SL parameters available
  3. ✗ Raw API POST to /exchange with tpPx / slPx fields - got HTTP 422 "Failed to deserialize"
  4. ✗ Raw API with takeProfit / stopLoss objects - also 422 error

Questions:

  1. Does the Hyperliquid API support setting TP/SL programmatically?
  2. If yes, what's the correct endpoint/parameters/SDK method?
  3. If no, is this coming soon?

Current workaround: Setting TP/SL manually on the UI works fine. Just want to automate if possible.

Thanks!


Code references:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions