Below are the examples for different AddOrder calls:
Add a standard order: sell 1.123 XBT/USD @ limit $120
$res = $kraken->QueryPrivate('AddOrder', array( 'pair' => 'XXBTZUSD', 'type' => 'sell', 'ordertype' => 'limit', 'price' => '120', 'volume' => '1.123' )); print_r($res);
Example output:
Array ( [error] => Array ( ) [result] => Array ( [descr] => Array ( [order] => sell 1.12300000 XBTUSD @ limit 120.00000 ) [txid] => Array ( [0] => OAVY7T-MV5VK-KHDF5X ) ) )
Add a standard order: buy 2 XBT at market at 2021-01-01 T00:00:00+0000 with EUR(quote) selected as the preferred fee currency ('fciq' parameter):
$res = $kraken->QueryPrivate('AddOrder', array(
'pair' => 'XXBTZEUR',
'type' => 'buy',
'ordertype' => 'market',
'oflags' => 'fciq',
'volume' => '2',
'starttm' => '1609459200'
));
print_r($res);
Example output:
Array
(
[error] => Array
(
)
[result] => Array
(
[descr] => Array
(
[order] => buy 2.00000000 XBTEUR @ market
)
[txid] => Array
(
[0] => ONQN65-L2GNR-HWJLF5
)
)
)
Add a standard order: buy 2.12345678 XBTUSD @ limit at -$10 price decrease with 2:1 leverage, with a follow up stop loss sell order: stop at -5% loss (signed limit/stop-loss prices determined automatically using # notation):
$res = $kraken->QueryPrivate('AddOrder', array(
'pair' => 'XXBTZUSD',
'type' => 'buy',
'ordertype' => 'limit',
'price' => '#10', // price (relative delta)
'volume' => '2.12345678',
'leverage' => '2:1',
'close' => array(
'ordertype' => 'stop-loss',
'price' => '#5%' // stop loss price (relative percentage delta)
)
));
print_r($res);
Example output:
Array
(
[error] => Array
(
)
[result] => Array
(
[descr] => Array
(
[order] => buy 2.12345678 XBTUSD @ limit -10 with 2:1 leverage
[close] => close position @ stop loss -5.0000%
)
[txid] => Array
(
[0] => OFMYYE-POAPQ-63IMWL
)
)
)
See our API documentation for more about the "AddOrder" call :