olegstyle/yobitapi

v1.1.0 2018-02-04 15:13 UTC

This package is not auto-updated.

Last update: 2024-09-23 17:18:38 UTC


README

这是 PHP 上 Yobit Api 的实现。

Api 文档:https://yobit.net/en/api

安装

1. 在 composer 包要求中添加

composer require olegstyle/yobitapi
如果不可用,则尝试以下操作
1.1 将其添加到 composer 存储库
"repositories": [
    # ...
    {
        "type": "vcs",
        "url": "https://git@bitbucket.org/dreamteam_ov/yobit-api.git"
    }
    # ...
],
1.2 将其添加到 composer require
"require: {
    "olegstyle/yobitapi": "dev-master"
}
1.3 构建
composer install
composer update

2. 安装 PhantomJS。

它需要绕过 Cloudflare。请参阅 readme 下的 ubuntu PhantomJS 安装指南

3. 确保您没有在安全模式下使用 php

另一种方法 PhantomJS 不会工作

4. 使用它 ^_^

如何使用?

与原始 api 包一样,有公共 api (\OlegStyle\YobitApi\YobitPublicApi) 和交易 api (\OlegStyle\YobitApi\YobitTradeApi)

公共 Api 使用

$pairs = [
   new \OlegStyle\YobitApi\Models\CurrencyPair('btc', 'eth'),
   new \OlegStyle\YobitApi\Models\CurrencyPair('bch, 'btc'),
];
$publicApi = new \OlegStyle\YobitApi\YobitPublicApi();
$publicApi->getInfo(); // get info about all pairs
$publicApi->getTickers($pairs); // limit - 50 pairs
$publicApi->getTicker('btc', 'eth');
$publicApi->getDepths($pairs); // limit - 50 pairs
$publicApi->getDepth('btc', 'eth');
$publicApi->getTrades($pairs); // limit - 50 pairs
$publicApi->getTrade('btc', 'eth');

交易 Api 使用

请确保您在开发和生产中使用不同的公共/秘密密钥

$publicKey = 'YOR_PUBLIC_KEY'; 
$privateKey = 'YOR_PRIVATE_KEY'; // or secret key

$tradeApi = new \OlegStyle\YobitApi\YobitTradeApi($publicKey, $privateKey);
$tradeApi->getInfo(); // Method returns information about user's balances and priviledges of API-key as well as server time.
$tradeApi->trade( // Method that allows creating new orders for stock exchange trading
  new \OlegStyle\YobitApi\CurrencyPair('bch, 'btc'), // pair
  \OlegStyle\YobitApi\Enums\TransactionTypeEnum::BUY, // type of trade. can be: TransactionTypeEnum::BUY or TransactionTypeEnum::SELL
  0.023, // rate
  0.1 // amount 
);
$tradeApi->getActiveOrders( // Method returns list of user's active orders (trades)
  new \OlegStyle\YobitApi\CurrencyPair('bch, 'btc') // pair
);
$tradeApi->getOrderInfo($orderId); // Method returns detailed information about the chosen order (trade)
$tradeApi->cancelOrder($orderId); // Method cancells the chosen order

感谢

PhantomJS 安装

在安装 PhantomJS 之前,您需要在系统上安装一些必需的软件包。您可以使用以下命令安装所有这些软件包

sudo apt-get install build-essential chrpath libssl-dev libxft-dev libfreetype6-dev libfreetype6 libfontconfig1-dev libfontconfig1 -y

接下来,您需要下载 PhantomJS。您可以从他们的官方网站下载最新稳定的 PhantomJS 版本。运行以下命令下载 PhantomJS

sudo wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2

下载完成后,将下载的存档文件提取到系统所需位置

sudo tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/share/

接下来,将 PhantomJS 二进制文件创建为系统 bin 目录的符号链接

sudo ln -s /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/

PhantomJS 现已安装在您的系统上。您现在可以使用以下命令验证已安装的 PhantomJS 版本

phantomjs --version