Skip to content
Back to App

Enums & Types

This page documents all enum values, type constants, and data format conventions used across the TestMax API. Use this as a quick reference when building strategies or integrating with the API.

OrderType

The type of order to place. Used in the type field of Order/place.

ValueNameDescriptionRequired price fields
1LimitExecutes at the specified price or better. Rests in the book until filled or canceled.limitPrice
2MarketExecutes immediately at the current market price.None
3StopLimitBecomes a limit order when the stop price is triggered.stopPrice, limitPrice
4StopBecomes a market order when the stop price is triggered.stopPrice

When to use each type

  • Market (2): Fast entries and exits where execution certainty matters more than price. Used for scalping, emergency flatten, and momentum entries.
  • Limit (1): Entries at a specific price or better. Used for pullback entries, take-profit orders, and scaling into positions.
  • Stop (4): Breakout entries and stop-loss protection. Triggers when the market trades through the stop price.
  • StopLimit (3): Combines a stop trigger with a limit price to avoid slippage on breakout entries. The limit price controls the worst acceptable fill price.

OrderSide

The direction of the order. Used in the side field of Order/place.

ValueNameDescription
0BuyBuy to open a long position or close a short position
1SellSell to open a short position or close a long position

OrderStatus

The current state of an order. Returned in the status field of Order/search and Order/searchOpen.

ValueNameDescription
1PartialOrder is partially filled — some contracts executed, remaining are still working
2FilledOrder is completely filled — all contracts executed
3CanceledOrder was canceled before being fully filled
6PendingOrder is active and waiting to be filled (limit/stop orders resting in the book)

Status transitions

Pending (6) → Partial (1) → Filled (2)
Pending (6) → Filled (2) (fully filled immediately)
Pending (6) → Canceled (3) (manually canceled)
Partial (1) → Canceled (3) (canceled with partial fill)

PositionType

The direction of an open position. Returned in the type field of Position/searchOpen.

ValueNameDescription
1LongHolding a long position (bought contracts, profit when price rises)
2ShortHolding a short position (sold contracts, profit when price falls)

Usage in strategy code

positions = get_positions(ACCOUNT_ID)
for pos in positions:
if pos["type"] == 1:
print(f"LONG {pos['size']} @ {pos['averagePrice']}")
elif pos["type"] == 2:
print(f"SHORT {pos['size']} @ {pos['averagePrice']}")

AggregateBarUnit

The time unit for bar aggregation. Used in the unit field of History/retrieveBars.

ValueNameDescription
1SecondBars aggregated by seconds
2MinuteBars aggregated by minutes
3HourBars aggregated by hours
4DayBars aggregated by days

Combine unit with unitNumber to define the bar timeframe:

TimeframeunitunitNumber
1-second11
30-second130
1-minute21
5-minute25
15-minute215
30-minute230
1-hour31
4-hour34
Daily41

Contract ID format

Contract identifiers follow the TopStep ProjectX convention:

CON.F.US.{symbol}.{monthYear}
ComponentDescriptionExample
CONFixed prefix (contract)CON
FAsset class (futures)F
USExchange/regionUS
{symbol}Internal instrument symbolENQ, EP, GCE
{monthYear}Month code + 2-digit yearH25 (March 2025)

Full examples

Contract IDInstrumentExpiry
CON.F.US.ENQ.H25Nasdaq 100 E-miniMarch 2025
CON.F.US.EP.H25S&P 500 E-miniMarch 2025
CON.F.US.GCE.J25Gold FuturesApril 2025
CON.F.US.CLE.F25Crude Oil FuturesJanuary 2025

Month codes

CodeMonthCodeMonth
FJanuaryNJuly
GFebruaryQAugust
HMarchUSeptember
JAprilVOctober
KMayXNovember
MJuneZDecember

Standard response format

Every API endpoint returns a response with these three fields:

{
"success": true,
"errorCode": 0,
"errorMessage": null
}
FieldTypeDescription
successbooleantrue if the request succeeded
errorCodenumber0 for success, non-zero for errors
errorMessagestring or nullHuman-readable error message, or null on success

Additional data fields are included alongside these fields depending on the endpoint. For example:

{
"success": true,
"errorCode": 0,
"errorMessage": null,
"accounts": [...]
}

Error codes

CodeMeaning
0Success
1Authentication error (invalid credentials, expired token)
2Validation error (missing or invalid fields)
3Not found (invalid account, contract, or order ID)
4Conflict (e.g., session already active, order already canceled)
5Rate limit exceeded
6Server error

Bar data format

OHLCV bars returned by Replay/step and History/retrieveBars use this format:

{
"t": "2025-01-15T14:30:00Z",
"o": 21500.25,
"h": 21505.50,
"l": 21498.75,
"c": 21503.00,
"v": 150
}
FieldTypeDescription
tstringISO 8601 UTC timestamp for the bar’s open time
onumberOpen price (first traded price in the bar period)
hnumberHigh price (highest traded price in the bar period)
lnumberLow price (lowest traded price in the bar period)
cnumberClose price (last traded price in the bar period)
vnumberVolume (total contracts traded in the bar period)

Timeframe strings

Timeframe strings are used in Replay/start and Playground API endpoints:

StringDescription
"1s"1-second bars
"1m"1-minute bars
"5m"5-minute bars
"15m"15-minute bars
"30m"30-minute bars
"1h"1-hour bars
"4h"4-hour bars
"1D"Daily bars

Quick reference card

EnumValues
OrderType1=Limit, 2=Market, 3=StopLimit, 4=Stop
OrderSide0=Buy, 1=Sell
OrderStatus1=Partial, 2=Filled, 3=Canceled, 6=Pending
PositionType1=Long, 2=Short
AggregateBarUnit1=Second, 2=Minute, 3=Hour, 4=Day

Copy-paste this into the top of your strategy for quick reference:

# === Enum Constants ===
# OrderType
LIMIT, MARKET, STOP_LIMIT, STOP = 1, 2, 3, 4
# OrderSide
BUY, SELL = 0, 1
# OrderStatus
PARTIAL, FILLED, CANCELED, PENDING = 1, 2, 3, 6
# PositionType
LONG, SHORT = 1, 2
# AggregateBarUnit
SECOND, MINUTE, HOUR, DAY = 1, 2, 3, 4