Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples - php cancel orders duplicated #16214

Merged
merged 1 commit into from Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 0 additions & 30 deletions examples/php/async-cancel-order.php

This file was deleted.

30 changes: 0 additions & 30 deletions examples/php/binance-cancel-order.php

This file was deleted.

35 changes: 35 additions & 0 deletions examples/php/cancel-order.php
@@ -0,0 +1,35 @@
<?php
include dirname(dirname(dirname(__FILE__))) . '/ccxt.php';
date_default_timezone_set('UTC');

$exchange = new \ccxt\binance(array(
'apiKey' => 'YOUR_API_KEY',
'secret' => 'YOUR_SECRET',
// 'verbose' => true,
));

try {

$symbol = 'XRP/BTC';

// if you want to find out your open orders, you can use the below code,
if ($exchange->has['fetchOpenOrders']) {
$open_orders = $exchange->fetchOpenOrders($symbol);
} else if ($exchange->has['fetchOrders']) {
$all_orders = $exchange->fetchOrders($symbol);
$open_orders = $exchange->filter_by($all_orders, 'status', 'open');
} else {
echo ($exchange->id . ' fetch(Open)Orders not supported yet');
}

// now, depending the $open_orders array, fill the below ID
$orderId = 'xxxxxxxx';

// to cancel multiple orders together asynchronously, see the "async-await-multiple.php" example file to adopt the code
$exchange->cancel_order($orderId, $symbol);

} catch (\ccxt\NetworkError $e) {
echo '[Network Error] ' . $e->getMessage() . "\n";
} catch (Exception $e) {
echo '[Error] ' . $e->getMessage() . "\n";
}