Grids Examples
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
{
"gap": "0.005",
"min_low": "orderbook().bid[0].price",
"max_high": "orderbook().ask[0].price",
"price_low": "min(rsi_to_price(candles_15m, rsi_expected=40), orderbook().ask[0].price, min_low)",
"price_high": "max(rsi_to_price(candles_15m, rsi_expected=60), orderbook().bid[0].price, max_high)",
"candles_15m": "candles('m15')",
"execute_price": "(price_low if side == 'buy' else price_high) * ( 1 + gap * order_pos)",
"execute_volume": "cached(60, respect='order_pos')(10/execute_price *abs(order_pos))",
"buy_orders_count": "5",
"sell_orders_count": "5",
"sleep_after_seconds": "900"
}
Grid 8: Buying and Selling When the 15-Minute RSI Exits a Defined Range
{
"max_bid": "mean([candle.close for candle in candles_m15])",
"min_ask": "mean([candle.close for candle in candles_m15])",
"rsi_m15": "rsi(candles('m15', 'base-counter'), period=14, column='close')[0]",
"candles_m15": "candles('m15', 'base-counter')",
"execute_price": "min(orderbook().ask[0].price,max_bid) if side == 'buy' else max(orderbook().bid[0].price,min_ask)",
"execute_volume": "10 / ticker()",
"buy_orders_count": "1 if rsi_m15 < 30 else 0",
"sell_orders_count": "1 if rsi_m15 > 70 else 0",
"sleep_after_seconds": "300"
}
Last updated