【问题标题】:Not able to fetch the price for market order无法获取市价单的价格
【发布时间】:2018-11-30 13:10:32
【问题描述】:

我无法使用 coinbase 沙盒 获取市场类型订单的订单价格。

    array:15 [▼
  "id" => "c4298c2e-324d-4cee-aaa3-18e811fee3bb"
  "info" => array:15 [▼
    "id" => "c4298c2e-324d-4cee-aaa3-18e811fee3bb"
    "size" => "0.05115089"
    "product_id" => "LTC-BTC"
    "side" => "buy"
    "funds" => "48.5491130600000000"
    "type" => "market"
    "post_only" => false
    "created_at" => "2018-11-30T11:53:03.272042Z"
    "done_at" => "2018-11-30T11:53:03.306Z"
    "done_reason" => "filled"
    "fill_fees" => "0.0001534526700000"
    "filled_size" => "0.05115089"
    "executed_value" => "0.0511508900000000"
    "status" => "done"`enter code here`
    "settled" => true
  ]
  "timestamp" => 1543578783272
  "datetime" => "2018-11-30T11:53:03.272Z"
  "lastTradeTimestamp" => null
  "status" => "closed"
  "symbol" => "LTC/BTC"
  "type" => "market"
  "side" => "buy"
  "price" => null
  "cost" => 0.05115089
  "amount" => 0.05115089
  "filled" => 0.05115089
  "remaining" => 0.0
  "fee" => array:3 [▼
    "cost" => 0.00015345267
    "currency" => null
    "rate" => null
  ]
]

请帮助哪个端点提供市场类型订单的价格,这是我得到的相同回报的数组。

注意:目前,我正在为此使用 CCXT 库。

【问题讨论】:

    标签: coinbase-api coinbase-php ccxt


    【解决方案1】:

    取自manual

    $orderbook = $exchange->fetch_order_book ($exchange->symbols[0]);
    $bid = count ($orderbook['bids']) ? $orderbook['bids'][0][0] : null;
    $ask = count ($orderbook['asks']) ? $orderbook['asks'][0][0] : null;
    $spread = ($bid && $ask) ? $ask - $bid : null;
    $result = array ('bid' => $bid, 'ask' => $ask, 'spread' => $spread);
    var_dump ($exchange->id, 'market price', $result); 
    

    此处计算买卖市场价格。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-30
      • 2019-01-02
      • 2021-06-04
      • 1970-01-01
      • 1970-01-01
      • 2020-07-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多