GET Price Range

/price-range

/price-range/{symbol}

Example Query:

https://base-hedger82.rasa.capital/price-range/BTCUSDT

Example Response:

{
  "min_price": "1113.60",
  "max_price": "754960.6666666666666666666668176588"
}

Data Source

The min_price and max_price are configured by the hedger but must align with the price range of the external exchange where the hedger is actively hedging (e.g., Binance, Bybit).

min_price: The minimum acceptable order price for the symbol (in quote currency, e.g., USDT). Derived from the external exchange’s current price floor or liquidity constraints.

  • Example: "1113.60" → Orders below this price are rejected.

max_price: The maximum acceptable order price for the symbol. Reflects the hedging platform’s upper price limit.

Price Range Implementation (Rasa)

Router

@common_router.get(
    '/price-range/{symbol}',
    responses={status.HTTP_200_OK: {"model": SymbolPriceRangeInputSchema}},
    response_model=SymbolPriceRangeInputSchema
)
async def get_symbol_price_range(symbol: symbol_enum):
    # 1. Compute safe order-price bounds from the exchange
    _, _, min_price, max_price = BinanceConditionChecks.get_price_bounds(symbol, from_stats=True)

    # 2. Return JSON matching SymbolPriceRangeInputSchema
    return {
        "min_price": min_price,
        "max_price": max_price
    }
  • Reads the exchange’s order-book or recent trades (via the Binance API or a cached copy).

  • Computes a safe min_price (floor) and max_price (ceiling) for new orders.

Steps to Implement Your Own Version

Define the Response Schema

class SymbolPriceRangeInputSchema(BaseModel):
    min_price: Decimal
    max_price: Decimal

Build Your Condition-Checks Utility

  • Implement BinanceConditionChecks.get_price_bounds(symbol, from_stats) to return a tuple (_, _, min_price, max_price).

Add the FastAPI Route

  • In common_router, register the GET /price-range/{symbol} endpoint as shown above.

  • Import symbol_enum for the path parameter (a class containing all Symbol names), and SymbolPriceRangeInputSchema for the response.

Last updated