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

Function example

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

Source from the content-addressed store, hash-verified

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