feat: kline data

This commit is contained in:
ding 2021-11-23 10:26:28 +08:00
parent 6c2a276a0f
commit c299a19c41
4 changed files with 30 additions and 10 deletions

View File

@ -1,3 +1,10 @@
/*
* @Description: file
* @Autor: dingyiming
* @Date: 2021-11-22 21:20:10
* @LastEditors: dingyiming
* @LastEditTime: 2021-11-23 10:25:41
*/
import fetch from 'node-fetch'
import { getLocalChains } from './data/data'
@ -19,15 +26,21 @@ export default class OsmosAPI {
fetch(`https://api.coingecko.com/api/v3/coins/${to}/ohlc?vs_currency=usd&days=7`).then(res => res.json())],
).then(ohlc => {
const output = []
console.log(ohlc)
ohlc[0].forEach((e, i) => {
console.log(e, i, ohlc[1][i])
const price = [e[0]]
for (let j = 1; j <= 4; j += 1) {
price.push(e[j] / ohlc[1][i][j])
}
output.push(price)
})
const result = []
for (let i = 0; i < output.length; i += 1) {
const itemArr = output[i]
result.push({
time: itemArr[0],
volume: 0,
})
}
return output
})
}

View File

@ -61,7 +61,7 @@
<div>-</div>
</div>
</div>
<Kline />
<Kline :list="klineData" />
</b-card>
</b-col>
<b-col
@ -109,6 +109,7 @@ export default {
{ pair: 'ATOM/OSMO' },
{ pair: 'ATOM/OSMO' },
],
klineData: [],
}
},
computed: {
@ -127,8 +128,12 @@ export default {
const { base, target } = this.$route.params
this.init(base, target)
// $http.osmosis
this.$http.osmosis.getOHCL4Pairs(this.$http.osmosis.getCoinGeckoId(this.base), this.$http.osmosis.getCoinGeckoId(this.target)).then(data => {
console.log(data)
this.$http.osmosis.getOHCL4Pairs(
this.$http.osmosis.getCoinGeckoId(this.base),
this.$http.osmosis.getCoinGeckoId(this.target),
)
.then(data => {
this.klineData = data
})
},
beforeRouteUpdate(to, from, next) {

View File

@ -46,7 +46,7 @@ class DataFeeds {
onReady(callback) {
const defaultConfiguration = {
symbols_type: [],
supported_resolutions: ['1', '5', '15', '30', '60', '240', '1D', '1M'],
supported_resolutions: ['30', '240', '1D'],
supports_marks: true,
supports_timescale_marks: false,
supports_time: false,
@ -121,7 +121,7 @@ class DataFeeds {
has_empty_bars: true,
description: '',
has_intraday: true,
supported_resolutions: ['1', '5', '15', '30', '60', '120', '240', '360', '1D'],
supported_resolutions: ['30','240', '1D'],
pricescale: 100000000, // 价格精度
volume_precision: 3, // 数量精度
symbol: symbolName,

View File

@ -18,13 +18,15 @@ const toDouble = time => {
}
export default {
props: {
list: [],
},
data() {
return {
themeLocal: 'dark'
}
},
mounted() {
console.log(version())
const store = {
ws: new WebSocket('wss://api.huobipro.com/ws'),
@ -55,7 +57,7 @@ export default {
volume: data.amount,
})
}
console.log(this.list);
store.onDataCallback(datas, { noData: !datas.length })
}