使用Bitfinex REST API(v1)时出现以下错误
{"message":"Offer could not be cancelled."}
我使用了以下JS代码。我同时尝试了WebSocket版本和REST API,但无法取消已采取的报价。我只能从Bitfinex仪表板关闭它。
以下是JS版本的代码:
const request = require('request')
const crypto = require('crypto')
const apiKey = 'xxxxx'
const apiSecret = 'xxxxxx'
const baseUrl = 'https://api.bitfinex.com'
const url = '/v1/offer/cancel'
const nonce = Date.now().toString()
const completeURL = baseUrl + url
const body = {
offer_id: 128887529,
request: url,
nonce
}
const payload = new Buffer(JSON.stringify(body)).toString('base64')
const signature = crypto.createHmac('sha384', apiSecret).update(payload).digest('hex')
const options = {
url: completeURL,
headers: {
'X-BFX-APIKEY': apiKey,
'X-BFX-PAYLOAD': payload,
'X-BFX-SIGNATURE': signature
},
body: JSON.stringify(body)
}
request.post(
options,
function(error, response, body) {
console.log('response:', JSON.stringify(body, 0, 2))
}
)