cancelOrder
Cancel active cryptocurrency trading orders on the Aster exchange by specifying the trading symbol and order identifier to manage positions and execute trading strategies.
Instructions
Cancel an active order.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| orderId | No | ||
| origClientOrderId | No | ||
| symbol | Yes |
Implementation Reference
- src/index.ts:637-638 (handler)The handler for the 'cancelOrder' tool. It invokes the shared makeRequest function with a signed DELETE request to the '/fapi/v1/order' endpoint on the Aster API, passing the tool arguments.case 'cancelOrder': return makeRequest('DELETE', '/fapi/v1/order', args, true);
- src/index.ts:312-320 (schema)Input schema for the 'cancelOrder' tool, defining parameters: symbol (required), orderId, origClientOrderId.inputSchema: { type: 'object', properties: { symbol: { type: 'string' }, orderId: { type: 'number' }, origClientOrderId: { type: 'string' }, }, required: ['symbol'], },
- src/index.ts:309-321 (registration)Registration of the 'cancelOrder' tool in the ListTools response, specifying name, description, and input schema.{ name: 'cancelOrder', description: 'Cancel an active order.', inputSchema: { type: 'object', properties: { symbol: { type: 'string' }, orderId: { type: 'number' }, origClientOrderId: { type: 'string' }, }, required: ['symbol'], }, },
- src/index.ts:542-579 (helper)Shared helper function 'makeRequest' used by the cancelOrder handler (and others) to make authenticated HTTP requests to the Aster Futures API, including signing with API key/secret.const makeRequest = async (method: 'GET' | 'POST' | 'DELETE', path: string, params: any, isSigned = false) => { try { let config: any = { method, url: path, }; if (isSigned) { if (!API_KEY || !API_SECRET) { throw new McpError(ErrorCode.InvalidRequest, 'API_KEY and API_SECRET must be configured.'); } params.timestamp = Date.now(); const queryString = new URLSearchParams(params).toString(); const signature = crypto.createHmac('sha256', API_SECRET).update(queryString).digest('hex'); params.signature = signature; config.headers = { 'X-MBX-APIKEY': API_KEY }; } if (method === 'GET' || method === 'DELETE') { config.params = params; } else { // POST config.data = new URLSearchParams(params).toString(); config.headers = { ...config.headers, 'Content-Type': 'application/x-www-form-urlencoded' }; } const response = await this.axiosInstance.request(config); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }] }; } catch (error) { if (axios.isAxiosError(error)) { throw new McpError( ErrorCode.InternalError, `Aster API error: ${error.response?.data?.msg || error.message}` ); } throw error; } };