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

Function example

examples/py/create-trailing-amount-order.py:15–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13
14
15async def example():
16 exchange = ccxt.bingx({
17 'apiKey': 'MY_API_KEY',
18 'secret': 'MY_SECRET',
19 })
20 # exchange.setSandboxMode (true);
21 # exchange.verbose = true; # uncomment for debugging purposes if necessary
22 await exchange.load_markets()
23 symbol = 'BTC/USDT:USDT'
24 order_type = 'market'
25 side = 'sell'
26 amount = 0.0001
27 price = None
28 reduce_only = True
29 trailing_amount = 100
30 # const trailingTriggerPrice = undefined; # not supported on all exchanges
31 params = {
32 'reduceOnly': reduce_only,
33 'trailingAmount': trailing_amount,
34 }
35 try:
36 create_order = await exchange.create_order(symbol, order_type, side, amount, price, params)
37 # Alternatively use the createTrailingAmountOrder method:
38 # const create_order = await exchange.createTrailingAmountOrder (symbol, order_type, side, amount, price, trailingAmount, trailingTriggerPrice, {
39 # 'reduceOnly': reduceOnly,
40 # });
41 print(create_order)
42 except Exception as e:
43 print(str(e))
44
45 await exchange.close()
46
47
48asyncio.run(example())

Callers 1

Calls 3

load_marketsMethod · 0.45
create_orderMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…