mirror of
https://gitea.gf4.pw/gf4/haveno-markets.git
synced 2024-12-21 23:59:22 +00:00
partial migration to svelte5, bugfixes, add robots.txt
This commit is contained in:
parent
bb10145f56
commit
f0e8c417eb
3 changed files with 30 additions and 43 deletions
|
@ -1,3 +1,4 @@
|
|||
<svelte:options runes={true} />
|
||||
<script>
|
||||
import {
|
||||
formatPrice,
|
||||
|
@ -14,20 +15,19 @@ import {
|
|||
TimeScale,
|
||||
} from "svelte-lightweight-charts";
|
||||
|
||||
export let data;
|
||||
let {data} = $props();
|
||||
const grouped = Object.groupBy(data.trades, ({ currency }) => currency);
|
||||
let trades = {};
|
||||
let interval = "86400000";
|
||||
let key = "USD";
|
||||
const getData = () => {
|
||||
trades = grouped[key]
|
||||
let interval = $state("86400000");
|
||||
let key = $state("USD");
|
||||
let trades = $derived((() => {
|
||||
let trades = grouped[key]
|
||||
.map((e) => {
|
||||
return {
|
||||
time: new Date(e.date),
|
||||
value: getPrice(e.price, e.currency),
|
||||
};
|
||||
})
|
||||
.toSorted((a, b) => (a.time > b.time ? 1 : -1));
|
||||
.toSorted((a, b) => (a.time - b.time));
|
||||
|
||||
trades = Object.groupBy(
|
||||
trades,
|
||||
|
@ -45,12 +45,10 @@ const getData = () => {
|
|||
}, {});
|
||||
trades[intervalDate].time = Number.parseInt(intervalDate, 10);
|
||||
}
|
||||
trades = Object.values(trades);
|
||||
};
|
||||
let volume = {};
|
||||
let swaps = {};
|
||||
const getVolume = () => {
|
||||
volume = Object.groupBy(
|
||||
return Object.values(trades);
|
||||
})());
|
||||
let [volume, swaps] = $derived((() => {
|
||||
let volume = Object.groupBy(
|
||||
data.trades
|
||||
.map((e) => {
|
||||
return {
|
||||
|
@ -58,10 +56,10 @@ const getVolume = () => {
|
|||
time: e.date,
|
||||
};
|
||||
})
|
||||
.toSorted((a, b) => (a.time > b.time ? 1 : -1)),
|
||||
.toSorted((a, b) => (a.time - b.time)),
|
||||
({ time }) => new Date(time - (time % interval)) / 1000,
|
||||
);
|
||||
swaps = {};
|
||||
let swaps = {};
|
||||
for (const intervalDate in volume) {
|
||||
swaps[intervalDate] = volume[intervalDate].reduce(
|
||||
(a) => {
|
||||
|
@ -84,17 +82,9 @@ const getVolume = () => {
|
|||
volume[intervalDate].time = Number.parseInt(intervalDate, 10);
|
||||
swaps[intervalDate].time = Number.parseInt(intervalDate, 10);
|
||||
}
|
||||
volume = Object.values(volume);
|
||||
swaps = Object.values(swaps);
|
||||
};
|
||||
let precision = 1e-2;
|
||||
$: {
|
||||
getVolume();
|
||||
getData();
|
||||
precision = getSignificantDigits(trades.flatMap((e) => [e.open, e.close]));
|
||||
interval;
|
||||
key;
|
||||
}
|
||||
return [Object.values(volume), Object.values(swaps)];
|
||||
})());
|
||||
let precision = $derived(getSignificantDigits(trades.flatMap((e) => [e.open, e.close])));
|
||||
|
||||
const chartLayout = {
|
||||
background: {
|
||||
|
@ -110,7 +100,7 @@ const gridLayout = {
|
|||
color: "#FFF5",
|
||||
},
|
||||
};
|
||||
let w;
|
||||
let w = $state();
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<svelte:options runes={true} />
|
||||
<script>
|
||||
import { page } from "$app/stores";
|
||||
import {
|
||||
|
@ -9,18 +10,17 @@ import {
|
|||
import { CandlestickSeries, Chart, TimeScale } from "svelte-lightweight-charts";
|
||||
|
||||
const market = $page.params.market;
|
||||
export let data;
|
||||
let {data} = $props();
|
||||
const interval = 86400000;
|
||||
let trades = [];
|
||||
const getData = () => {
|
||||
trades = data.trades
|
||||
let trades = $derived((() => {
|
||||
let trades = data.trades
|
||||
.map((e) => {
|
||||
return {
|
||||
time: new Date(e.date),
|
||||
value: getPrice(e.price, e.currency, false, false),
|
||||
};
|
||||
})
|
||||
.toSorted((a, b) => (a.time > b.time ? 1 : -1));
|
||||
.toSorted((a, b) => (a.time - b.time));
|
||||
|
||||
trades = Object.groupBy(
|
||||
trades,
|
||||
|
@ -38,16 +38,11 @@ const getData = () => {
|
|||
}, {});
|
||||
trades[intervalDate].time = Number.parseInt(intervalDate, 10);
|
||||
}
|
||||
trades = Object.values(trades);
|
||||
};
|
||||
let w;
|
||||
return Object.values(trades);
|
||||
})());
|
||||
|
||||
let precision = 1e-2;
|
||||
|
||||
$: {
|
||||
getData();
|
||||
precision = getSignificantDigits(trades.flatMap((e) => [e.open, e.close]));
|
||||
}
|
||||
let precision = $derived(getSignificantDigits(trades.flatMap((e) => [e.open, e.close])));
|
||||
let w = $state();
|
||||
|
||||
const chartLayout = {
|
||||
background: {
|
||||
|
@ -90,7 +85,7 @@ const BUY_SELL = isMoneroQuote(market) ? ["SELL", "BUY"] : ["BUY", "SELL"];
|
|||
<th>Amount (XMR)</th>
|
||||
<th>Amount ({market})</th>
|
||||
</tr>
|
||||
{#each data.offers[BUY_SELL[0]]?.toSorted((a,b) => a.price < b.price ? 1 : -1)||[] as offer}
|
||||
{#each data.offers[BUY_SELL[0]]?.toSorted((a,b) => b.price - a.price)||[] as offer}
|
||||
<tr title={offer.paymentMethod}>
|
||||
<td>{formatPrice(offer.price, market, false, false)}</td>
|
||||
<td>{formatPrice(offer.amount, "XMR", false, false)}</td>
|
||||
|
@ -109,7 +104,7 @@ const BUY_SELL = isMoneroQuote(market) ? ["SELL", "BUY"] : ["BUY", "SELL"];
|
|||
<th>Amount (XMR)</th>
|
||||
<th>Amount ({market})</th>
|
||||
</tr>
|
||||
{#each data.offers[BUY_SELL[1]]?.toSorted((a,b) => a.price > b.price ? 1 : -1)||[] as offer}
|
||||
{#each data.offers[BUY_SELL[1]]?.toSorted((a,b) => a.price - b.price)||[] as offer}
|
||||
<tr title={offer.paymentMethod}>
|
||||
<td>{formatPrice(offer.price, market, false, false)}</td>
|
||||
<td>{formatPrice(offer.amount, "XMR", false, false)}</td>
|
||||
|
|
2
static/robots.txt
Normal file
2
static/robots.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
User-agent: *
|
||||
Allow: /
|
Loading…
Reference in a new issue