Skip to main content

Price Rounding Rules

XeroLite automatically rounds prices based on market rules for each instrument to ensure orders are placed at valid price increments. All rounding is performed in aggressive mode to improve execution efficiency.

Overview

The price will be rounded based on the market rule of the instrument and always in aggressive mode:

  • For BUY orders: The price will be rounded up to the nearest valid increment
  • For SELL orders: The price will be rounded down to the nearest valid increment

This ensures that orders are always placed at aggressive prices, improving execution efficiency.


Understanding Price Rounding

Market rules define valid price increments for each instrument. Common increments include:

  • 0.01 (penny increments) - Most stocks
  • 0.05 (nickel increments) - Some stocks and options
  • 0.10 (dime increments) - Some instruments
  • Other increments - Varies by instrument and exchange

How Rounding Works

  • If a BUY order is placed at a price that does not align with the valid increment, it will be adjusted upward to the nearest valid increment
  • If a SELL order is placed at a price that does not align with the valid increment, it will be adjusted downward to the nearest valid increment

Why Aggressive Mode?

Aggressive rounding ensures:

  • Faster execution - Orders are more likely to be filled quickly
  • Better price priority - Orders are placed at more competitive prices
  • Compliance - All prices meet exchange requirements for valid increments

Examples

Example 1: Increment = 0.05

Order TypeEntered PriceRounded PriceExplanation
BUY210.03210.05Rounded up to nearest 0.05
BUY210.07210.10Rounded up to nearest 0.05
BUY210.12210.15Rounded up to nearest 0.05
SELL210.03210.00Rounded down to nearest 0.05
SELL210.07210.05Rounded down to nearest 0.05
SELL210.12210.10Rounded down to nearest 0.05

Example 2: Increment = 0.01

Order TypeEntered PriceRounded PriceExplanation
BUY150.234150.24Rounded up to nearest 0.01
BUY150.236150.24Rounded up to nearest 0.01
SELL150.234150.23Rounded down to nearest 0.01
SELL150.236150.24Rounded down to nearest 0.01

Example 3: Increment = 0.10

Order TypeEntered PriceRounded PriceExplanation
BUY75.2375.30Rounded up to nearest 0.10
BUY75.6775.70Rounded up to nearest 0.10
SELL75.2375.20Rounded down to nearest 0.10
SELL75.6775.60Rounded down to nearest 0.10

Where Rounding Applies

Price rounding rules apply to the following fields in your alert requests:

1. Limit Price (price)

The price field is rounded for LIMIT and TRAIL orders:

{
"order_type": "LIMIT",
"price": "150.234", // Will be rounded based on instrument's increment
"action": "BUY" // Rounds up for BUY, down for SELL
}

Note: For MARKET orders, the price field is not rounded (it's only used for offset calculations if sl_offset or tp_offset is specified).

2. Stop-Loss Price (sl)

The sl field is only rounded when calculated from sl_offset. If you provide sl directly, it is NOT rounded:

{
"sl": "142.567", // NOT rounded - used as-is
"action": "BUY"
}

Important: To ensure proper rounding, use sl_offset instead of sl when you want automatic price rounding:

{
"price": "150.00",
"sl_offset": "5%", // Calculates to 142.50, then rounds
"action": "BUY"
}

3. Take-Profit Price (tp)

The tp field is only rounded when calculated from tp_offset. If you provide tp directly, it is NOT rounded:

{
"tp": "165.789", // NOT rounded - used as-is
"action": "BUY"
}

Important: To ensure proper rounding, use tp_offset instead of tp when you want automatic price rounding:

{
"price": "150.00",
"tp_offset": "10%", // Calculates to 165.00, then rounds
"action": "BUY"
}

4. Trailing Stop Price (for TRAIL orders)

For TRAIL orders, the calculated trailing stop price is rounded. The trail_amt value itself is not rounded - only the final calculated trailing stop price is rounded:

{
"order_type": "TRAIL",
"price": "150.00",
"trail_amt": "2.00%", // trail_amt value is NOT rounded
"action": "BUY"
// The calculated trailing stop price (e.g., 147.00) WILL be rounded
}

Note:

  • When trail_amt is a percentage (e.g., "2.00%"), the calculated trailing stop price is rounded
  • When trail_amt is a fixed amount (e.g., "2.00"), the calculated trailing stop price is rounded
  • The trail_amt value itself is never rounded - only the final calculated price

5. Calculated Prices from Offsets

When using offset-based calculations (sl_offset, tp_offset), the calculated prices are rounded according to these rules:

{
"price": "150.00",
"sl_offset": "5%", // Calculates to 142.50, then rounds
"tp_offset": "10%", // Calculates to 165.00, then rounds
"action": "BUY"
}

The rounding happens after the offset calculation, ensuring the final price meets market increment requirements.


Important Notes

Rounding is Automatic

  • Rounding is applied automatically by XeroLite
  • You don't need to manually adjust prices to match increments
  • The system uses Interactive Brokers' market rules for each instrument

Rounding Direction

  • BUY orders always round UP - More aggressive (higher) price
  • SELL orders always round DOWN - More aggressive (lower) price

This ensures your orders are placed at prices that are more likely to execute quickly.

Market Rules Vary

Different instruments have different increment rules:

  • Stocks: Typically 0.01 (penny increments)
  • Options: Varies by strike price and expiration
  • Futures: Varies by contract
  • Forex: Varies by currency pair

XeroLite automatically applies the correct increment rules for each instrument based on Interactive Brokers' specifications.

Offset Calculations

When using percentage or fixed amount offsets:

  1. The offset is calculated first (e.g., Price - 5%)
  2. The calculated result is then rounded
  3. The rounded price is used for the order

Example:

  • Price: $150.00
  • SL Offset: 5% = $7.50
  • Calculated SL: $150.00 - $7.50 = $142.50
  • If increment is 0.05 and action is BUY: Rounds to $142.50 (already valid)
  • If increment is 0.05 and action is SELL: Rounds to $142.50 (already valid)

Direct Price Fields vs. Offset Fields

Important distinction:

  • Direct price fields (sl, tp): These are NOT rounded when provided directly
  • Offset fields (sl_offset, tp_offset): The calculated prices from these offsets ARE rounded

Recommendation: Use offset fields (sl_offset, tp_offset) instead of direct price fields (sl, tp) to ensure automatic price rounding and compliance with market rules.



Need Help?

If you have questions about price rounding or need assistance, contact support at [email protected]