Bisq markets: Volume and other fixes.

This commit is contained in:
softsimon
2021-03-10 23:02:55 +07:00
parent d99fd5d59a
commit 1d4ed85d50
9 changed files with 57 additions and 26 deletions

View File

@@ -6,16 +6,13 @@
<h1>{{ currency.market.lname }} - {{ currency.pair }}</h1>
<div class="float-left">
<span class="priceheader">
<ng-container *ngIf="currency.market.rtype === 'fiat'; else headerPriceCrypto"><span class="green-color">{{ hlocData[hlocData.length - 1].close | currency: currency.market.rsymbol }}</span></ng-container>
<ng-template #headerPriceCrypto>{{ hlocData[hlocData.length - 1].close | number: '1.' + currency.market.rprecision + '-' + currency.market.rprecision }} {{ currency.market.rsymbol }}</ng-template>
<ng-container *ngIf="currency.market.rtype === 'fiat'; else headerPriceCrypto"><span class="green-color">{{ hlocData.hloc[hlocData.hloc.length - 1].close | currency: currency.market.rsymbol }}</span></ng-container>
<ng-template #headerPriceCrypto>{{ hlocData.hloc[hlocData.hloc.length - 1].close | number: '1.' + currency.market.rprecision + '-' + currency.market.rprecision }} {{ currency.market.rsymbol }}</ng-template>
</span>
</div>
<form [formGroup]="radioGroupForm" class="mb-3 float-right">
<div class="btn-group btn-group-toggle" ngbRadioGroup name="radioBasic" formControlName="interval">
<label ngbButtonLabel class="btn-primary btn-sm">
<input ngbButton type="radio" [value]="'minute'"> 1M
</label>
<label ngbButtonLabel class="btn-primary btn-sm">
<input ngbButton type="radio" [value]="'half_hour'"> 30M
</label>
@@ -43,8 +40,10 @@
</div>
</form>
<app-lightweight-charts [data]="hlocData"></app-lightweight-charts>
<app-lightweight-charts [data]="hlocData.hloc" [volumeData]="hlocData.volume" [precision]="currency.market.rtype === 'crypto' ? currency.market.lprecision : currency.market.rprecision"></app-lightweight-charts>
<div class="float-right small mt-2">Powered by <a href="https://www.tradingview.com/" target="_blank">Tradingview</a></div>
<br>
<ng-container *ngIf="offers$ | async as offers">

View File

@@ -46,11 +46,8 @@ export class BisqMarketComponent implements OnInit, OnDestroy {
this.offers$ = this.route.paramMap
.pipe(
map(routeParams => routeParams.get('pair')),
tap((marketPair) => this.websocketService.startTrackBisqMarket(marketPair)),
switchMap((marketPair) => this.bisqApiService.getMarketOffers$(marketPair)),
map((offers) => {
return offers[Object.keys(offers)[0]];
})
map((offers) => offers[Object.keys(offers)[0]])
);
this.hlocData$ = combineLatest([
@@ -62,11 +59,21 @@ export class BisqMarketComponent implements OnInit, OnDestroy {
const pair = routeParams.get('pair');
return this.bisqApiService.getMarketsHloc$(pair, interval);
}),
map((hloc) => {
return hloc.map((h) => {
map((hlocData) => {
hlocData = hlocData.map((h) => {
h.time = h.period_start;
return h;
});
return {
hloc: hlocData,
volume: hlocData.map((h) => {
return {
time: h.time,
value: h.volume_right,
color: h.close > h.avg ? 'rgba(0, 150, 136, 0.8)' : 'rgba(255,82,82, 0.8)',
};
})
};
}),
);
}