Skip to main content
The Polyhush SDK supports three order types, each with different execution behaviors. Understanding these is crucial for effective trading.

Order Type Constants

The client provides convenient constants for order types:
from polyhush import PolyhushClient

client = PolyhushClient(api_key="your-api-key")

client.GTC  # "GTC" - Good Till Cancelled
client.FOK  # "FOK" - Fill Or Kill  
client.FAK  # "FAK" - Fill And Kill

GTC (Good Till Cancelled)

Default order type for limit orders
A GTC order remains active on the order book until it’s either:
  • Fully filled
  • Manually cancelled
  • The market closes
# Place a GTC limit order
result = client.buy(
    token_id="your-token-id",
    shares=100,
    price=0.45,
    order_type="GTC"  # This is the default
)

When to Use GTC

Patient Entry

You want to buy/sell at a specific price and are willing to wait

Better Pricing

You want to avoid paying the spread by providing liquidity

Behavior

ScenarioResult
Price matches immediatelyOrder fills (partially or fully)
Price doesn’t matchOrder sits on book waiting
Partial fillRemaining amount stays on book
Cancel requestOrder removed, funds released

FOK (Fill Or Kill)

All or nothing execution
A FOK order must be filled completely and immediately, or it’s cancelled entirely. There’s no partial fill.
# Place a FOK order - must fill 100 shares or nothing
result = client.buy(
    token_id="your-token-id",
    shares=100,
    price=0.50,
    order_type="FOK"
)

When to Use FOK

Precise Position Sizing

You need exactly N shares, no more, no less

Avoid Partial Fills

Partial fills would leave you with an undesirable position

Behavior

ScenarioResult
Full fill available at priceOrder fills completely
Only partial fill availableOrder cancelled, nothing filled
No liquidity at priceOrder cancelled immediately

FAK (Fill And Kill)

Market order behavior - Use market_buy() and market_sell() for convenience
A FAK order fills as much as possible immediately at the best available prices, then cancels any unfilled remainder.
# Using FAK directly
result = client.buy(
    token_id="your-token-id",
    shares=100,
    price=0.99,  # High price to ensure fill
    order_type="FAK"
)

# Or use the convenient market order methods
result = client.market_buy(token_id="your-token-id", usdc_amount=50)
result = client.market_sell(token_id="your-token-id", shares=100)

When to Use FAK

Immediate Execution

You want to enter/exit a position right now

Market Orders

You care more about getting filled than the exact price

Behavior

ScenarioResult
Full fill availableOrder fills completely
Partial fill availableFills what’s available, cancels rest
No liquidityOrder cancelled, nothing filled

Comparison Table

FeatureGTCFOKFAK
Sits on order book
Partial fills
Immediate executionOptionalRequiredRequired
Best forLimit ordersPrecise sizingMarket orders

Examples

Limit Order (GTC)

# Patient entry - wait for price to come to you
result = client.buy(
    token_id=token_id,
    shares=50,
    price=0.40,  # Below current market
    order_type="GTC"
)
print(f"Order {result['order_id']} placed on book")

All-or-Nothing (FOK)

# Need exactly 100 shares or nothing
result = client.buy(
    token_id=token_id,
    shares=100,
    price=0.55,
    order_type="FOK"
)

if result['status'] == 'FILLED':
    print("Got all 100 shares!")
else:
    print("Couldn't fill - no position taken")

Market Order (FAK)

# Get in immediately at market price
result = client.market_buy(
    token_id=token_id,
    usdc_amount=100  # Spend $100 at market
)

# Or sell shares immediately
result = client.market_sell(
    token_id=token_id,
    shares=50
)