Perpetual Futures Order Handling, Position Queries, and Funding Data
Summary
This code provides a client wrapper for trading and querying USDT margined perpetual futures. It configures position mode, margin mode, and leverage, then supports buy and sell orders with limit, market, or other order types. After submission, it checks order status and can cancel and reissue unfilled or partly filled quantities based on price movement or elapsed time. An automatic cancellation option is also available.
The wrapper exposes account equity, positions, contract value, order book depth, funding rate, order status, tickers, and exchange information. These features can help connect an execution process to market and account data. The document is implementation code, not a tested execution strategy: it provides no slippage, fill-rate, or profitability evidence. Its configurable leverage and order-reissue behavior also do not establish suitable risk limits.
Key ideas
- The wrapper can configure one-way or dual-side positions, margin mode, and leverage.
- Buy and sell calls support limit and market orders, with limit orders as the default.
- Optional cancellation logic can react to price moves, elapsed time, or incomplete fills.
- Position, depth, order, and funding information are exposed through query methods.
- No evidence is given about execution quality, profitability, or appropriate risk limits.
Tags
From a private course collection; the original is not published.