Skip to content
All library documents

Spot Order Handling with Price and Time Based Cancellation

Code Quant course library

Summary

This document describes a spot trading interface that retrieves balances and market data, submits buy and sell orders, and reports order status. Its execution workflow checks an order after submission and can cancel and replace an unfilled or partially filled order when a price threshold is crossed or a configured delay expires. Replacement orders use the latest market price adjusted by a configured amount and reduce the requested quantity by the amount already filled.

It also exposes candle data, ticker prices, order book levels, and account balances for use by a trading system. The document provides implementation details rather than a tested trading strategy or performance evidence. Order state handling, repeated replacement, exceptions, and exchange response conventions all affect real execution; the described logic alone does not establish that repricing improves fills or controls trading costs.

Key ideas

  • The interface supports limit and market buy and sell orders.
  • Price based cancellation can trigger a replacement when the market moves beyond a configured threshold.
  • Time based cancellation can replace orders that remain unfilled after a configured delay.
  • Replacement quantity accounts for fills reported before cancellation.
  • The document describes execution mechanics without testing their effect on trading outcomes.

Tags

From a private course collection; the original is not published.