Skip to content
All library documents

Equity-Based Position Sizing with Conditional Stop-Loss and Take-Profit Orders

Article Strategy library · Author: ianzeng123

Summary

This workflow describes automated long and short trading for USDT-margined perpetual futures. On a candle-close trigger, it reads account balance and market contract specifications, then calculates an order quantity from a configurable share of available equity. It adjusts the quantity to the contract’s precision and checks minimum and maximum size limits before submitting a market entry.

After confirming a fill, the workflow calculates stop-loss and take-profit prices from the average entry price and configured percentages, then monitors both conditional orders. Its state flow tracks entry, monitoring, and completion; when one exit order triggers, the other is cancelled before the next cycle. Persistent status is intended to support recovery after a restart. The document is primarily an implementation description, not a trading signal or performance study. It provides no backtest results, and it does not establish that an equity allocation alone limits actual loss to the selected percentage: leverage, price gaps, fills, and contract rules can affect realized risk. The sample also depends on exchange-specific market data and order handling.

Key ideas

  • Order quantity is derived from available balance, a configurable equity ratio, price, and contract value.
  • The workflow validates quantity precision and contract size limits before opening a position.
  • Once an entry fill is confirmed, it places conditional stop-loss and take-profit orders based on the average fill price.
  • A state machine monitors exits and cancels the remaining conditional order after one exit executes.
  • The document describes workflow mechanics but provides no performance results or proof of realized risk limits.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.