Markets api: Add missing "timestamp" parameter for /hloc and /volumes
This commit is contained in:
parent
14697a01cc
commit
059e4d079a
@ -110,7 +110,7 @@ interface Market {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface HighLowOpenClose {
|
export interface HighLowOpenClose {
|
||||||
period_start: number;
|
period_start: number | string;
|
||||||
open: string;
|
open: string;
|
||||||
high: string;
|
high: string;
|
||||||
low: string;
|
low: string;
|
||||||
|
@ -212,6 +212,7 @@ class BisqMarketsApi {
|
|||||||
timestamp_to?: number,
|
timestamp_to?: number,
|
||||||
interval: Interval = 'auto',
|
interval: Interval = 'auto',
|
||||||
milliseconds?: boolean,
|
milliseconds?: boolean,
|
||||||
|
timestamp: 'no' | 'yes' = 'yes',
|
||||||
): MarketVolume[] {
|
): MarketVolume[] {
|
||||||
if (milliseconds) {
|
if (milliseconds) {
|
||||||
timestamp_from = timestamp_from ? timestamp_from / 1000 : timestamp_from;
|
timestamp_from = timestamp_from ? timestamp_from / 1000 : timestamp_from;
|
||||||
@ -256,7 +257,7 @@ class BisqMarketsApi {
|
|||||||
if (intervals.hasOwnProperty(p)) {
|
if (intervals.hasOwnProperty(p)) {
|
||||||
const period = intervals[p];
|
const period = intervals[p];
|
||||||
marketVolumes.push({
|
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'],
|
num_trades: period['num_trades'],
|
||||||
volume: this.intToBtc(period['volume']),
|
volume: this.intToBtc(period['volume']),
|
||||||
});
|
});
|
||||||
@ -358,6 +359,7 @@ class BisqMarketsApi {
|
|||||||
timestamp_from?: number,
|
timestamp_from?: number,
|
||||||
timestamp_to?: number,
|
timestamp_to?: number,
|
||||||
milliseconds?: boolean,
|
milliseconds?: boolean,
|
||||||
|
timestamp: 'no' | 'yes' = 'yes',
|
||||||
): HighLowOpenClose[] {
|
): HighLowOpenClose[] {
|
||||||
if (milliseconds) {
|
if (milliseconds) {
|
||||||
timestamp_from = timestamp_from ? timestamp_from / 1000 : timestamp_from;
|
timestamp_from = timestamp_from ? timestamp_from / 1000 : timestamp_from;
|
||||||
@ -386,7 +388,7 @@ class BisqMarketsApi {
|
|||||||
if (intervals.hasOwnProperty(p)) {
|
if (intervals.hasOwnProperty(p)) {
|
||||||
const period = intervals[p];
|
const period = intervals[p];
|
||||||
hloc.push({
|
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']),
|
open: this.intToBtc(period['open']),
|
||||||
close: this.intToBtc(period['close']),
|
close: this.intToBtc(period['close']),
|
||||||
high: this.intToBtc(period['high']),
|
high: this.intToBtc(period['high']),
|
||||||
|
@ -317,6 +317,10 @@ class Routes {
|
|||||||
required: false,
|
required: false,
|
||||||
types: ['@boolean']
|
types: ['@boolean']
|
||||||
},
|
},
|
||||||
|
'timestamp': {
|
||||||
|
required: false,
|
||||||
|
types: ['no', 'yes']
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const p = this.parseRequestParameters(req, constraints);
|
const p = this.parseRequestParameters(req, constraints);
|
||||||
@ -325,7 +329,7 @@ class Routes {
|
|||||||
return;
|
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) {
|
if (result) {
|
||||||
res.json(result);
|
res.json(result);
|
||||||
} else {
|
} else {
|
||||||
@ -355,6 +359,10 @@ class Routes {
|
|||||||
required: false,
|
required: false,
|
||||||
types: ['@boolean']
|
types: ['@boolean']
|
||||||
},
|
},
|
||||||
|
'timestamp': {
|
||||||
|
required: false,
|
||||||
|
types: ['no', 'yes']
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const p = this.parseRequestParameters(req, constraints);
|
const p = this.parseRequestParameters(req, constraints);
|
||||||
@ -363,7 +371,7 @@ class Routes {
|
|||||||
return;
|
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) {
|
if (result) {
|
||||||
res.json(result);
|
res.json(result);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user