mirror of
https://github.com/mempool/mempool.git
synced 2025-01-18 05:12:35 +01:00
Add whitespaces to missing data points.
This commit is contained in:
parent
95a80157a7
commit
c1fc08196b
@ -1,7 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient, HttpResponse, HttpParams } from '@angular/common/http';
|
import { HttpClient, HttpResponse, HttpParams } from '@angular/common/http';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { BisqTransaction, BisqBlock, BisqStats, MarketVolume, Trade, Markets, Tickers, Offers, Currencies, HighLowOpenClose } from './bisq.interfaces';
|
import { BisqTransaction, BisqBlock, BisqStats, MarketVolume, Trade, Markets, Tickers, Offers, Currencies, HighLowOpenClose, SummarizedInterval } from './bisq.interfaces';
|
||||||
|
|
||||||
const API_BASE_URL = '/bisq/api';
|
const API_BASE_URL = '/bisq/api';
|
||||||
|
|
||||||
@ -56,8 +56,8 @@ export class BisqApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getMarketsHloc$(market: string, interval: 'minute' | 'half_hour' | 'hour' | 'half_day' | 'day'
|
getMarketsHloc$(market: string, interval: 'minute' | 'half_hour' | 'hour' | 'half_day' | 'day'
|
||||||
| 'week' | 'month' | 'year' | 'auto'): Observable<any[]> {
|
| 'week' | 'month' | 'year' | 'auto'): Observable<SummarizedInterval[]> {
|
||||||
return this.httpClient.get<any[]>(API_BASE_URL + '/markets/hloc?market=' + market + '&interval=' + interval);
|
return this.httpClient.get<SummarizedInterval[]>(API_BASE_URL + '/markets/hloc?market=' + market + '&interval=' + interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
getMarketOffers$(market: string): Observable<Offers> {
|
getMarketOffers$(market: string): Observable<Offers> {
|
||||||
|
@ -34,9 +34,6 @@
|
|||||||
<label ngbButtonLabel class="btn-primary btn-sm">
|
<label ngbButtonLabel class="btn-primary btn-sm">
|
||||||
<input ngbButton type="radio" [value]="'year'" (click)="setFragment('year')"> 1Y
|
<input ngbButton type="radio" [value]="'year'" (click)="setFragment('year')"> 1Y
|
||||||
</label>
|
</label>
|
||||||
<label ngbButtonLabel class="btn-primary btn-sm">
|
|
||||||
<input ngbButton type="radio" [value]="'auto'" (click)="setFragment('auto')"> Auto
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@ -58,10 +55,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<br>
|
<br><br>
|
||||||
|
|
||||||
<ng-container *ngIf="trades$ | async as trades; else loadingSpinner">
|
<ng-container *ngIf="trades$ | async as trades; else loadingSpinner">
|
||||||
<h2>Trade History (Last 100 trades)</h2>
|
<h2>Latest trades</h2>
|
||||||
|
|
||||||
<table class="table table-borderless table-striped">
|
<table class="table table-borderless table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -87,15 +87,44 @@ export class BisqMarketComponent implements OnInit, OnDestroy {
|
|||||||
h.time = h.period_start;
|
h.time = h.period_start;
|
||||||
return h;
|
return h;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const hlocVolume = hlocData.map((h) => {
|
||||||
|
return {
|
||||||
|
time: h.time,
|
||||||
|
value: h.volume_right,
|
||||||
|
color: h.close > h.avg ? 'rgba(0, 41, 74, 0.7)' : 'rgba(0, 41, 74, 1)',
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add whitespace
|
||||||
|
if (hlocData.length > 1) {
|
||||||
|
const newHloc = [];
|
||||||
|
newHloc.push(hlocData[0]);
|
||||||
|
|
||||||
|
const period = this.getUnixTimestampFromInterval(this.radioGroupForm.get('interval').value); // temp
|
||||||
|
let periods = 0;
|
||||||
|
const startingDate = hlocData[0].period_start;
|
||||||
|
let index = 1;
|
||||||
|
while (true) {
|
||||||
|
periods++;
|
||||||
|
if (hlocData[index].period_start > startingDate + period * periods) {
|
||||||
|
newHloc.push({
|
||||||
|
time: startingDate + period * periods,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
newHloc.push(hlocData[index]);
|
||||||
|
index++;
|
||||||
|
if (!hlocData[index]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hlocData = newHloc;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hloc: hlocData,
|
hloc: hlocData,
|
||||||
volume: hlocData.map((h) => {
|
volume: hlocVolume,
|
||||||
return {
|
|
||||||
time: h.time,
|
|
||||||
value: h.volume_right,
|
|
||||||
color: h.close > h.avg ? 'rgba(0, 41, 74, 0.7)' : 'rgba(0, 41, 74, 1)',
|
|
||||||
};
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -113,4 +142,17 @@ export class BisqMarketComponent implements OnInit, OnDestroy {
|
|||||||
this.websocketService.stopTrackingBisqMarket();
|
this.websocketService.stopTrackingBisqMarket();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getUnixTimestampFromInterval(interval: string): number {
|
||||||
|
switch (interval) {
|
||||||
|
case 'minute': return 60;
|
||||||
|
case 'half_hour': return 1800;
|
||||||
|
case 'hour': return 3600;
|
||||||
|
case 'half_day': return 43200;
|
||||||
|
case 'day': return 86400;
|
||||||
|
case 'week': return 604800;
|
||||||
|
case 'month': return 2592000;
|
||||||
|
case 'year': return 31579200;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -249,12 +249,13 @@ export type Interval = 'minute' | 'half_hour' | 'hour' | 'half_day' | 'day' | 'w
|
|||||||
|
|
||||||
export interface SummarizedIntervals { [market: string]: SummarizedInterval; }
|
export interface SummarizedIntervals { [market: string]: SummarizedInterval; }
|
||||||
export interface SummarizedInterval {
|
export interface SummarizedInterval {
|
||||||
'period_start': number;
|
period_start: number;
|
||||||
'open': number;
|
open: number;
|
||||||
'close': number;
|
close: number;
|
||||||
'high': number;
|
high: number;
|
||||||
'low': number;
|
low: number;
|
||||||
'avg': number;
|
avg: number;
|
||||||
'volume_right': number;
|
volume_right: number;
|
||||||
'volume_left': number;
|
volume_left: number;
|
||||||
|
time?: number;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user