1

我无法使用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 库。

4

1 回答 1

0

取自手册

$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); 

买卖市场价格均在此处计算。

于 2018-12-28T10:51:32.900 回答