MCPcopy Create free account
hub / github.com/ccxt/ccxt / example

Function example

examples/ts/create-trailing-amount-order.ts:3–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1import ccxt from '../../js/ccxt.js';
2
3async function example () {
4 const exchange = new ccxt.bingx ({
5 'apiKey': 'MY_API_KEY',
6 'secret': 'MY_SECRET',
7 });
8 // exchange.setSandboxMode (true);
9 // exchange.verbose = true; // uncomment for debugging purposes if necessary
10 await exchange.loadMarkets ();
11 const symbol = 'BTC/USDT:USDT';
12 const order_type = 'market';
13 const side = 'sell';
14 const amount = 0.0001;
15 const price = undefined;
16 const reduceOnly = true;
17 const trailingAmount = 100;
18 // const trailingTriggerPrice = undefined; // not supported on all exchanges
19 const params = {
20 'reduceOnly': reduceOnly,
21 'trailingAmount': trailingAmount,
22 // 'trailingTriggerPrice': trailingTriggerPrice,
23 };
24 try {
25 const create_order = await exchange.createOrder (symbol, order_type, side, amount, price, params);
26 // Alternatively use the createTrailingAmountOrder method:
27 // const create_order = await exchange.createTrailingAmountOrder (symbol, order_type, side, amount, price, trailingAmount, trailingTriggerPrice, {
28 // 'reduceOnly': reduceOnly,
29 // });
30 console.log (create_order);
31 } catch (e) {
32 console.log (e.toString ());
33 }
34}
35await example ();

Callers 1

Calls 4

createOrderMethod · 0.95
loadMarketsMethod · 0.45
logMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…