検索
Examples of placing orders with different parameters
The REST AddOrder and WebSocket addOrder endpoints are used to place orders on our markets, but due to the variety of possible orders (different order types, varying prices, varying sizes, custom order options, etc.), there are many different ways to call the AddOrder/addOrder endpoints.
As some helpful suggestions for configuring your own orders, the following are examples of AddOrder/addOrder calls with some of the most frequently used parameters. The examples use our REST API command line client, but the same parameters could be used via any API interface (curl, Postman, custom API code, etc.).
 

Market order (buy 50 XDG/USD at the best available price)

$ ./krakenapi AddOrder pair=xdgusd type=buy ordertype=market volume=50{"error":[],"result":{"descr":{"order":"buy 50.00000000 XDGUSD @ market"},"txid":["OFKBX4-NUHFI-JIKLLM"]}}
 

Limit order (sell 50 XDG/USD at $1)

$ ./krakenapi AddOrder pair=xdgusd type=sell ordertype=limit price=1.00 volume=50{"error":[],"result":{"descr":{"order":"sell 50.00000000 XDGUSD @ limit 1.0000000"},"txid":["O562OP-O6FNI-SEQ23Y"]}}
 

Post only limit order (sell 50 XDG/USD at $1)

$ ./krakenapi AddOrder pair=xdgusd type=sell ordertype=limit price=1.00 volume=50 oflags=post{"error":[],"result":{"descr":{"order":"sell 50.00000000 XDGUSD @ limit 1.0000000"},"txid":["OWFYJG-DJUOO-F5BISK"]}}
 

Market order with stop loss conditional close (buy 50 XDG/USD, then place sell order 5% lower)

$ ./krakenapi AddOrder pair=xdgusd type=buy ordertype=market volume=50 'close[ordertype]=stop-loss' 'close[price]=-5%'{"error":[],"result":{"descr":{"order":"buy 50.00000000 XDGUSD @ market","close":"close position @ stop loss -5.0000%"},"txid":["OW7UJZ-P7F7Z-JAHANL"]}}
 

Market order with take profit limit conditional close (buy 50 XDG/USD, then place sell order at $1)

$ ./krakenapi AddOrder pair=xdgusd type=buy ordertype=market volume=50 'close[ordertype]=take-profit-limit' 'close[price]=1.00' 'close[price2]=1.00'{"error":[],"result":{"descr":{"order":"buy 50.00000000 XDGUSD @ market","close":"close position @ take profit 1.0000000 -> limit 1.0000000"},"txid":["OJ7K64-4PQ5Y-DE7FRG"]}}
 

IOC order (buy 50 XDG/USD using an Immediate or Cancel order)

$ ./krakenapi AddOrder pair=xdgusd type=buy ordertype=limit price=1.00 volume=50 timeinforce=ioc{"error":[],"result":{"txid":["OZS2KT-JVN2E-J2XM7Z"],"descr":{"order":"buy 50.00000000 XDGUSD @ limit 1.0000000"}}}
 

Iceberg order (sell 50 XDG/USD while displaying only 25 XDG/USD for sale)

$ ./krakenapi AddOrder pair=xdgusd type=sell ordertype=limit price=1.00 volume=50 displayvol=25{"error":[],"result":{"txid":["ODMXEB-NUCVA-QWG6HH"],"descr":{"order":"sell 50.00000000 XDGUSD @ limit 1.0000000"}}}
 

Market order with 5:1 leverage (open long XBT/USD position at the best available price)

$ ./krakenapi AddOrder pair=xbtusd type=buy ordertype=market volume=0.0005 leverage=5{"error":[],"result":{"descr":{"order":"buy 0.00050000 XBTUSD @ market with 5:1 leverage"},"txid":["OXCTLW-XCYRT-MSP4FS"]}}
 

Settle position order (convert long XBT/USD position into currency exchange)

$ ./krakenapi AddOrder pair=xbtusd type=buy ordertype=settle-position volume=0 leverage=5{"error":[],"result":{"descr":{"order":"buy 0.00000000 XBTUSD @ settle position"},"txid":["OYO2FZ-7SYNG-GDBZ6M"]}}
Note the volume of 0 (zero), which can be used to close/settle margin positions without knowing the exact volume.
 
Full details of all of the possible AddOrder endpoint input parameters are available via our REST API and WebSocket API documentation.