1

我正在开发一个应用程序,该应用程序使用 PHP 的 ccxt 加密 API 进行加密货币的ETH/BTC套利交易,并且我通常在尝试下限价购买订单时不断收到 API 调用引发的此网络错误异常。

{"status":-124,"error_message":"Enter the size in units of 0.0000001 ETH.","data":null}

上述异常是从 Bitflyer 交换中引发的。

我的代码如下:

$name = '\\ccxt\\'.$exchangeId;
$exchange = new $name(array (
    'apiKey'          => $api_key, // ←------------ replace with your keys
    'secret'          => $secret_key,
    'enableRateLimit' => true,
));

try{
   $symbol = 'ETH/BTC'; 
   $type = 'limit'; // # or 'market', or 'Stop' or 'StopLimit'
   $side = 'buy'; // 'sell' or 'buy'
   $amount = $data['trade_base_amount'];    //0.0515996
   $price  = $data['exchange_rate']; // 0.01938
   // extra params and overrides
   $params = array();

   $response = $exchange->create_order($symbol, $type, $side, $amount, $price, $params);
    print_r($response);
}catch (\ccxt\NetworkError $e) {
    echo $exchange->id . ' fetch_trades failed due to a network error: '.$e->getMessage () . "\n";
}catch (\ccxt\ExchangeError $e) {
    echo $exchange->id . ' fetch_trades failed due to exchange error: ' .$e->getMessage () . "\n";
}catch (\Exception $e) {
    echo $exchange->id . ' fetch_trades failed with: ' . $e->getMessage () . "\n";
}

谁能解释我为什么会收到这个错误?

提前致谢。

4

1 回答 1

0

尝试为我使用 amountToPrecision 获得 CCXT 上的文档

于 2022-02-27T11:32:22.053 回答