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 fetch from 'node-fetch'
import { getLocalChains } from './data/data' 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())], fetch(`https://api.coingecko.com/api/v3/coins/${to}/ohlc?vs_currency=usd&days=7`).then(res => res.json())],
).then(ohlc => { ).then(ohlc => {
const output = [] const output = []
console.log(ohlc)
ohlc[0].forEach((e, i) => { ohlc[0].forEach((e, i) => {
console.log(e, i, ohlc[1][i])
const price = [e[0]] const price = [e[0]]
for (let j = 1; j <= 4; j += 1) { for (let j = 1; j <= 4; j += 1) {
price.push(e[j] / ohlc[1][i][j]) price.push(e[j] / ohlc[1][i][j])
} }
output.push(price) 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 return output
}) })
} }

View File

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

View File

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

View File

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