@icgio/icg-utils 1.9.47 → 1.9.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -103,6 +103,25 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type) => {
103
103
  console.error(pair, error)
104
104
  }
105
105
  })
106
+ } else if (exchange === 'biconomy') {
107
+ let pair = cur + '_USDT'
108
+ let url = `https://api.biconomy.com/api/v1/depth?symbol=${pair}&size=5`
109
+ limiter.process(needle.get, url, (err, res, body) => {
110
+ try {
111
+ const { asks, bids } = body
112
+ let rate = (parseFloat(asks[0][0]) + parseFloat(bids[0][0])) / 2
113
+ result[cur] = {
114
+ USD: rate,
115
+ USDT: rate,
116
+ }
117
+ let result_length = _.keys(result).length
118
+ if (result_length === length) {
119
+ cb(result)
120
+ }
121
+ } catch (error) {
122
+ console.error(pair, error)
123
+ }
124
+ })
106
125
  } else if (exchange === 'bingx') {
107
126
  let pair = cur + 'USDT'
108
127
  let url = `https://www.binance.com/api/v3/depth?symbol=${pair}&limit=20`
package/lib/influxdb.js CHANGED
@@ -29,22 +29,22 @@ class Influx {
29
29
  async query(query_string, cb) {
30
30
  const query_api = this.influx_db.getQueryApi(this.org)
31
31
  let result = await query_api.queryRaw(query_string)
32
- let temp = parse(
33
- result,
34
- {
35
- columns: true,
36
- comment: '#',
37
- skip_empty_lines: true,
38
- relax_column_count: true,
39
- },
40
- (err, res) => {
41
- if (!err) {
42
- cb({ success: true, body: res })
43
- } else {
44
- cb({ success: false, body: err })
45
- }
46
- }
47
- )
32
+ // Split by empty lines into table blocks — each InfluxDB table may have
33
+ // different columns (different tag sets), so parse each with its own headers
34
+ const tables = result.split(/\r?\n\s*\r?\n/).filter((b) => b.trim())
35
+ const parse_table = (csv) =>
36
+ new Promise((resolve, reject) => {
37
+ parse(csv, { columns: true, comment: '#', skip_empty_lines: true, relax_column_count: true }, (err, res) => {
38
+ if (err) reject(err)
39
+ else resolve(res)
40
+ })
41
+ })
42
+ try {
43
+ const results = await Promise.all(tables.map((t) => parse_table(t)))
44
+ cb({ success: true, body: results.flat() })
45
+ } catch (err) {
46
+ cb({ success: false, body: err })
47
+ }
48
48
  }
49
49
  async write_points_with_check(points, cb) {
50
50
  const write_api = this.influx_db.getWriteApi(this.org, this.bucket)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-utils",
3
- "version": "1.9.47",
3
+ "version": "1.9.49",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {