For the complete documentation index, see llms.txt. This page is also available as Markdown.

Grids Examples

Discover multiple grid trading examples in Origami Tech that demonstrate strategy structure, order placement, and optimization for various market conditions.

Grid 1: Selling at the Best Price with Minimum Price and Balance Constraints
{
"gap": "0.005",
"execute_price": "max(orderbook().ask[0].price-symbol().price_precision,min_ask_price)*(1+gap*(order_pos-1))",
"min_ask_price": "orderbook().bid[0].price+symbol().price_precision",
"execute_volume": "10/execute_price+abs(order_pos)*10/execute_price",
"buy_orders_count": "0",
"sell_orders_count": "5 if balance('counter').total < 5000 else 0"
}
Grid 2: Selling at the Best Price Considering Historical Data
{
"gap": "0.01",
"candles_1d": "candles('d1', 'base-counter',count=30)",
"execute_price": "max(orderbook().ask[0].price-symbol().price_precision,(month_mean_high+month_mean_close)/2,min_ask_price)*(1+gap*(order_pos-1))",
"min_ask_price": "max(month_mean_close,orderbook().bid[0].price+symbol().price_precision*2)",
"execute_volume": "10/execute_price if execute_price<month_mean_high else (10/execute_price+abs(order_pos)*10/execute_price)",
"month_mean_high": "mean([price.high for price in candles_1d])",
"buy_orders_count": "0",
"month_mean_close": "mean([price.close for price in candles_1d])",
"sell_orders_count": "5 if balance('counter').total < 5000 else 0"
}
Grid 3: Buying at the Best Price with Maximum Price and Balance Constraints
{
"gap": "0.005",
"execute_price": "min(orderbook().bid[0].price+symbol().price_precision,max_bid_price)*(1+gap*(order_pos+1))",
"max_bid_price": "orderbook().ask[0].price-symbol().price_precision",
"execute_volume": "10/execute_price+abs(order_pos)*10/execute_price",
"buy_orders_count": "5 if balance('counter').total > 5000 else 0",
"sell_orders_count": "0"
}
Grid 4: Buying at the Best Price Considering Historical Data
{
"gap": "0.01",
"candles_1d": "candles('d1', 'base-counter',count=30)",
"execute_price": "min(orderbook().bid[0].price+symbol().price_precision,(month_mean_low+month_mean_close)/2,max_bid_price)*(1+gap*(order_pos+1))",
"max_bid_price": "min(month_mean_close,orderbook().ask[0].price-symbol().price_precision*2)",
"execute_volume": "10/execute_price if execute_price>month_mean_low else (10/execute_price+abs(order_pos)*10/execute_price)",
"month_mean_low": "mean([price.low for price in candles_1d])",
"buy_orders_count": "5 if balance('counter').total > 5000 else 0",
"month_mean_close": "mean([price.close for price in candles_1d])",
"sell_orders_count": "0"
}
Grid 5: Placing Orders at the Best Price or with a Minimum Spread
{
"gap": "0.005",
"min_spread": "0.02",
"pivot_price": "(orderbook().ask[0].price+orderbook().bid[0].price+ticker())/3",
"execute_price": "(pivot_price*(1-min_spread/2+(order_pos+1)*gap) if pivot_price*(1-min_spread/2)<=(orderbook().bid[0].price+symbol().price_precision) else min(orderbook().bid[0].price + symbol().price_precision,orderbook().ask[0].price - symbol().price_precision)*(1+gap*(order_pos+1))) if side=='buy' else (pivot_price*(1+min_spread/2+(order_pos-1)*gap) if pivot_price*(1+min_spread/2)>=(orderbook().ask[0].price-symbol().price_precision) else max(orderbook().ask[0].price - symbol().price_precision,orderbook().bid[0].price + symbol().price_precision)*(1+gap*(order_pos-1)))",
"execute_volume": "20/execute_price + 0 * abs(order_pos)/execute_price",
"buy_orders_count": "5",
"sell_orders_count": "5"
}
Grid 6: Placing Orders with a Spread Based on Historical Data
{
"gap_ask": "0.005",
"gap_bid": "0.005",
"price_ask": "max(orderbook().ask[0].price-symbol().price_precision,(two_weeks_mean_high+two_weeks_mean_close)/2,mean_high_15m,min_ask_price)",
"price_bid": "min(orderbook().bid[0].price+symbol().price_precision,(two_weeks_mean_low+two_weeks_mean_close)/2,mean_low_15m,max_bid_price)",
"candles_1d": "candles('d1', 'base-counter',count=14)",
"spread_min": "10*symbol().price_precision",
"candles_15m": "candles('m15','base-counter')",
"mean_low_15m": "mean([price.low for price in candles_15m])",
"execute_price": "(((price_bid+price_ask)/2-spread_min/2)*(1+gap_bid*(order_pos+1)) if side=='buy' else ((price_bid+price_ask)/2+spread_min/2)*(1+gap_ask*(order_pos-1))) if (price_ask-price_bid)<spread_min else (price_bid*(1+gap_bid*(order_pos+1)) if side=='buy' else price_ask*(1+gap_ask*(order_pos-1)))",
"max_bid_price": "mean_low_15m",
"mean_high_15m": "mean([price.high for price in candles_15m])",
"min_ask_price": "mean_high_15m",
"execute_volume": "(6/execute_price if execute_price>two_weeks_mean_low else 10 / execute_price * abs(order_pos)) if side=='buy' else (6/execute_price if execute_price<two_weeks_mean_high else 10 / execute_price * abs(order_pos))",
"buy_orders_count": "5",
"sell_orders_count": "5",
"two_weeks_mean_low": "mean([price.low for price in candles_1d])",
"two_weeks_mean_high": "mean([price.high for price in candles_1d])",
"two_weeks_mean_close": "mean([price.close for price in candles_1d])"
}
Grid 7: Placing Buy and Sell Orders Based on RSI of 15-Minute Candlesticks
Grid 8: Buying and Selling When the 15-Minute RSI Exits a Defined Range

Last updated