hellovoid / gdax
GDAX API 库
v1.0.2
2018-01-25 11:13 UTC
Requires
- php: >=5.5.0
- guzzlehttp/guzzle: ^6.0
Requires (Dev)
- phpunit/phpunit: ^4.7
This package is not auto-updated.
Last update: 2024-09-29 04:49:28 UTC
README
GDAX PHP API 客户端库
这是 GDAX API 的非官方客户端库。[链接](https://docs.gdax.com)。灵感来源于 [Coinbase PHP 库](https://github.com/coinbase/coinbase-php)。
安装
使用 Composer 安装库。如果您不熟悉 Composer 或一般依赖管理器,请阅读 [Composer 文档](https://composer.php.ac.cn/doc/01-basic-usage.md)。
composer require hellovoid/gdax
身份验证
使用 API 密钥、密钥和密码访问您的 GDAX 账户。
use Hellovoid\Gdax\Configuration; use Hellovoid\Gdax\Client; $configuration = Configuration::apiKey($apiKey, $apiSecret, $apiPassphrase); $client = Client::create($configuration);
响应
每个成功的方法请求都返回解码后的 JSON 数组。
分页 #ref
您的请求应在请求后续页面时使用这些游标值。
use \Hellovoid\Gdax\Pagination; $pagination = Pagination::create($before, null, $limit); $client->setPagination($pagination); $pagination->setEndingBefore(null); $pagination->setStartingAfter($after);
账户 #ref
列出账户
$client->getAccounts();
账户详情
$client->getAccount($accountId);
账户历史
$client->getAccountHistory($accountId);
账户持有
$client->getAccountHolds($accountId);
订单 #ref
放置新订单
$order = $client->placeOrder([ 'size' => 0.1, 'price' => 0.1, 'side' => 'buy', 'product_id' => 'BTC-USD' ]);
取消订单
try { $response = $client->orderCancel($orderId); } catch (HttpException $e) { // Order could not be canceled $e->getMessage(); }
取消所有订单
$response = $client->ordersCancel();
取消特定产品的所有订单
$response = $client->ordersCancel([ 'product_id' => $productId ]);
列出订单
$response = $client->getOrders();
获取订单详情
$response = $client->getOrder($orderId);
成交 #ref
列出成交
$response = $client->getFills([ 'order_id' => 'all', 'product_id' => 'all' ]);
资金 #ref
列出资金
获取状态为 "已结算" 的资金。
$response = $client->getFundings([ 'status' => 'settled', // outstanding, settled, or rejected ]);
偿还
$response = $client->fundingRepay([ 'amount' => 1.00, 'currency' => 'EUR', ]);
保证金转账 #ref
$response = $client->marginTransfer([ 'margin_profile_id' => '45fa9e3b-00ba-4631-b907-8a98cbdf21be', 'type' => 'deposit', 'currency' => 'USD', 'amount' => 2, ]);
持仓 #ref
获取您的个人资料概览
$response = $client->position();
关闭
$response = $client->positionClose([ 'repay_only' => true ]);
存款 #ref
支付方式
$response = $client->depositPaymentMethod([ 'amount' => 2.00, 'currency' => 'USD', 'payment_method_id' => 'bc677162-d934-5f1a-968c-a496b1c1270b' ]);
Coinbase
从 Coinbase 账户存入资金。
$response = $client->depositCoinbase([ 'amount' => 2.00, 'currency' => 'BTC', 'coinbase_account_id' => 'c13cd0fc-72ca-55e9-843b-b84ef628c198' ]);
提款 #ref
支付方式
$response = $client->withdrawalPaymentMethod([ 'amount' => 2.00, 'currency' => 'USD', 'payment_method_id' => 'bc677162-d934-5f1a-968c-a496b1c1270b' ]);
Coinbase
将资金提款到 Coinbase 账户。
$response = $client->withdrawalCoinbase([ 'amount' => 2.00, 'currency' => 'BTC', 'coinbase_account_id' => 'c13cd0fc-72ca-55e9-843b-b84ef628c198' ]);
加密货币
将资金提款到加密货币地址。
$response = $client->withdrawalCoinbase([ 'amount' => 0.01, 'currency' => 'BTC', 'crypto_address' => '0x5ad5769cd04681FeD900BCE3DDc877B50E83d469' ]);
支付方式 #ref
获取您的支付方式列表。
$response = $client->getPaymentMethods();
Coinbase 账户 #ref
获取您的 Coinbase 账户列表。
$response = $client->getCoinbaseAccounts();
报告 #ref
创建新报告
$response = $client->createReport([ 'type' => 'fills', 'start_date' => '2014-11-01T00:00:00.000Z', 'end_date' => '2014-11-30T23:59:59.000Z' ]);
获取报告状态
$response = $client->getReportStatus($reportId);
产品 #ref
获取产品
$response = $client->getProducts();
获取产品订单簿
$response = $client->getProductOrderBook($productId);
获取产品行情
$response = $client->getProductTicker($productId);
获取产品成交
$response = $client->getProductTrades($productId);
获取历史汇率
$response = $client->getProductHistoricRates($productId);
获取 24 小时统计数据
$response = $client->getProductLast24HrStats($productId);
货币 #ref
$response = $client->getCurrencies();
获取时间 #ref
$response = $client->getTime();