rewrite conversion from py to node

This commit is contained in:
Bitcarrot
2021-10-07 16:28:55 -07:00
parent ce0484689a
commit 17a8aaa56c
6 changed files with 53 additions and 32 deletions

View File

@@ -3,14 +3,16 @@ const fs = require('fs');
module.exports = {
bfx: async function() {
const hkdrate = 0.1287 // approximate rate
const btcDataURL = "https://api-pub.bitfinex.com/v2/ticker/tBTCUSD"
const response = await axios.get(btcDataURL)
const data = response.data
//console.log(data[6])
const satDenominator = 100000000
const hkdrate = 0.1287 // approximate rate
// see docs : https://docs.bitfinex.com/reference#rest-public-ticker
btcLastPrice = data[6]
const sathkd = Math.round((1 / btcLastPrice) * satDenominator * hkdrate)
//console.log("bitfinex last price: ", btcLastPrice, "current satHKD: ", sathkd)
return sathkd