mvaessen/kraken-future-api

简单的 Kraken 期货 API 包装器,使用 PHP 编写。包括基本功能和假设您熟悉操作。

0.1 2019-08-13 14:50 UTC

This package is not auto-updated.

Last update: 2024-09-19 14:52:06 UTC


README

简单的 Kraken 期货 API 包装器,使用 PHP 编写。包括一些基本方法来操作 API,并假设您熟悉操作。有关可用的端点的更多信息,请查看 Kraken 期货 API 文档。遇到错误时会抛出异常。

请注意

  • 不包含拦截速率限制的机制。
  • 不提供任何支持。
  • 自行承担风险。

入门

composer require mvaessen/binance-api

require 'vendor/autoload.php';
$api = new Mvaessen\KrakenFutureApi\Client('<api key>','<secret>');
公共端点调用
$result = $api->queryPublic('<method>', '<endpoint>', '<request>');
私有端点调用
$result = $api->queryPrivate('<method>', '<endpoint>', '<request>');

测试

请确保填充 .env 文件,运行 composer install 并在项目根目录的 .env 文件中设置您的测试 API 密钥。之后运行 ./vendor/bin/phpunit tests/BasicApiTest.php 以测试您的 API 密钥。测试运行在 https://conformance.cryptofacilities.com/derivatives 环境中。

扩展和自定义错误报告

您可以选择覆盖 processErrorCodeprocessException 方法,将错误报告给您喜欢的错误报告软件。

<?php
namespace App;

use Mvaessen\KrakenFutureApi\KrakenFutureApiException;
use Mvaessen\KrakenFutureApi\Client;

class KrakenFutureApi extends Client
{
   public function accounts()
   {
        return $this->api->queryPrivate('get', 'accounts');
   }

   protected function processErrorCode($response, $method, $url, $request)
   {
       //todo report to bugtracking software

       throw new KrakenFutureApiException($response['msg']);
   }
   
   protected function processException($e, $method, $url, $request)
   {
       //todo report to bugtracking software

       throw new KrakenFutureApiException($e->getMessage());
   }
}