Use custom adapter to retirieve OHLC data
let Vue = Likhtar.vue;
Vue.config.productionTip = false;
Vue.component(Likhtar.app.name, Likhtar.app);
let adapter = function() {
return {
getData: function (venue,symbol,_from,_to,granularity) {
let interval = null;
switch (granularity) {
case "1m": interval = Likhtar.d3.timeMinute; break;
case "5m": interval = Likhtar.d3.timeMinute.every(5); break;
case "15m": interval = Likhtar.d3.timeMinute.every(15); break;
case "1h": interval = Likhtar.d3.timeHour; break;
case "1d": interval = Likhtar.d3.timeDay; break;
default: interval = Likhtar.d3.timeMinute; break;
}
let generator = Likhtar.fc
.randomFinancial()
.startPrice(8000)
.interval(interval);
return { data: generator(40), id: [venue, symbol].join("-") }
}
}
}
let myIndicatorFunction = function(datum){
// This increments closing price by a fixed amaount
let data = datum[0].data;
let factor = 5;
data.map(a => {
a.value = a.close + factor // Default cross value for indicator is `value`
return a;
});
return {data: data};
}
let chartApp = new Vue({
el: '#app',
data: {
symbols: "MyExchange:BTCUSD",
granularity: "1m",
adapter: adapter(),
indicators: [
{ id: "delta",
indicatorFunction: myIndicatorFunction,
type: "line" },
]
}
});