Markets api: Add missing "timestamp" parameter for /hloc and /volumes

This commit is contained in:
softsimon 2020-09-17 15:38:25 +07:00
parent 14697a01cc
commit 059e4d079a
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
3 changed files with 15 additions and 5 deletions

View File

@ -110,7 +110,7 @@ interface Market {
}
export interface HighLowOpenClose {
period_start: number;
period_start: number | string;
open: string;
high: string;
low: string;

View File

@ -212,6 +212,7 @@ class BisqMarketsApi {
timestamp_to?: number,
interval: Interval = 'auto',
milliseconds?: boolean,
timestamp: 'no' | 'yes' = 'yes',
): MarketVolume[] {
if (milliseconds) {
timestamp_from = timestamp_from ? timestamp_from / 1000 : timestamp_from;
@ -256,7 +257,7 @@ class BisqMarketsApi {
if (intervals.hasOwnProperty(p)) {
const period = intervals[p];
marketVolumes.push({
period_start: period['period_start'],
period_start: timestamp === 'no' ? new Date(period['period_start'] * 1000).toISOString() : period['period_start'],
num_trades: period['num_trades'],
volume: this.intToBtc(period['volume']),
});
@ -358,6 +359,7 @@ class BisqMarketsApi {
timestamp_from?: number,
timestamp_to?: number,
milliseconds?: boolean,
timestamp: 'no' | 'yes' = 'yes',
): HighLowOpenClose[] {
if (milliseconds) {
timestamp_from = timestamp_from ? timestamp_from / 1000 : timestamp_from;
@ -386,7 +388,7 @@ class BisqMarketsApi {
if (intervals.hasOwnProperty(p)) {
const period = intervals[p];
hloc.push({
period_start: period['period_start'],
period_start: timestamp === 'no' ? new Date(period['period_start'] * 1000).toISOString() : period['period_start'],
open: this.intToBtc(period['open']),
close: this.intToBtc(period['close']),
high: this.intToBtc(period['high']),

View File

@ -317,6 +317,10 @@ class Routes {
required: false,
types: ['@boolean']
},
'timestamp': {
required: false,
types: ['no', 'yes']
},
};
const p = this.parseRequestParameters(req, constraints);
@ -325,7 +329,7 @@ class Routes {
return;
}
const result = bisqMarket.getVolumes(p.market, p.timestamp_from, p.timestamp_to, p.interval, p.milliseconds);
const result = bisqMarket.getVolumes(p.market, p.timestamp_from, p.timestamp_to, p.interval, p.milliseconds, p.timestamp);
if (result) {
res.json(result);
} else {
@ -355,6 +359,10 @@ class Routes {
required: false,
types: ['@boolean']
},
'timestamp': {
required: false,
types: ['no', 'yes']
},
};
const p = this.parseRequestParameters(req, constraints);
@ -363,7 +371,7 @@ class Routes {
return;
}
const result = bisqMarket.getHloc(p.market, p.interval, p.timestamp_from, p.timestamp_to, p.milliseconds);
const result = bisqMarket.getHloc(p.market, p.interval, p.timestamp_from, p.timestamp_to, p.milliseconds, p.timestamp);
if (result) {
res.json(result);
} else {