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>
|
<script>
|
||||||
import {
|
import {
|
||||||
formatPrice,
|
formatPrice,
|
||||||
|
@ -14,20 +15,19 @@ import {
|
||||||
TimeScale,
|
TimeScale,
|
||||||
} from "svelte-lightweight-charts";
|
} from "svelte-lightweight-charts";
|
||||||
|
|
||||||
export let data;
|
let {data} = $props();
|
||||||
const grouped = Object.groupBy(data.trades, ({ currency }) => currency);
|
const grouped = Object.groupBy(data.trades, ({ currency }) => currency);
|
||||||
let trades = {};
|
let interval = $state("86400000");
|
||||||
let interval = "86400000";
|
let key = $state("USD");
|
||||||
let key = "USD";
|
let trades = $derived((() => {
|
||||||
const getData = () => {
|
let trades = grouped[key]
|
||||||
trades = grouped[key]
|
|
||||||
.map((e) => {
|
.map((e) => {
|
||||||
return {
|
return {
|
||||||
time: new Date(e.date),
|
time: new Date(e.date),
|
||||||
value: getPrice(e.price, e.currency),
|
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 = Object.groupBy(
|
||||||
trades,
|
trades,
|
||||||
|
@ -45,12 +45,10 @@ const getData = () => {
|
||||||
}, {});
|
}, {});
|
||||||
trades[intervalDate].time = Number.parseInt(intervalDate, 10);
|
trades[intervalDate].time = Number.parseInt(intervalDate, 10);
|
||||||
}
|
}
|
||||||
trades = Object.values(trades);
|
return Object.values(trades);
|
||||||
};
|
})());
|
||||||
let volume = {};
|
let [volume, swaps] = $derived((() => {
|
||||||
let swaps = {};
|
let volume = Object.groupBy(
|
||||||
const getVolume = () => {
|
|
||||||
volume = Object.groupBy(
|
|
||||||
data.trades
|
data.trades
|
||||||
.map((e) => {
|
.map((e) => {
|
||||||
return {
|
return {
|
||||||
|
@ -58,10 +56,10 @@ const getVolume = () => {
|
||||||
time: e.date,
|
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,
|
({ time }) => new Date(time - (time % interval)) / 1000,
|
||||||
);
|
);
|
||||||
swaps = {};
|
let swaps = {};
|
||||||
for (const intervalDate in volume) {
|
for (const intervalDate in volume) {
|
||||||
swaps[intervalDate] = volume[intervalDate].reduce(
|
swaps[intervalDate] = volume[intervalDate].reduce(
|
||||||
(a) => {
|
(a) => {
|
||||||
|
@ -84,17 +82,9 @@ const getVolume = () => {
|
||||||
volume[intervalDate].time = Number.parseInt(intervalDate, 10);
|
volume[intervalDate].time = Number.parseInt(intervalDate, 10);
|
||||||
swaps[intervalDate].time = Number.parseInt(intervalDate, 10);
|
swaps[intervalDate].time = Number.parseInt(intervalDate, 10);
|
||||||
}
|
}
|
||||||
volume = Object.values(volume);
|
return [Object.values(volume), Object.values(swaps)];
|
||||||
swaps = Object.values(swaps);
|
})());
|
||||||
};
|
let precision = $derived(getSignificantDigits(trades.flatMap((e) => [e.open, e.close])));
|
||||||
let precision = 1e-2;
|
|
||||||
$: {
|
|
||||||
getVolume();
|
|
||||||
getData();
|
|
||||||
precision = getSignificantDigits(trades.flatMap((e) => [e.open, e.close]));
|
|
||||||
interval;
|
|
||||||
key;
|
|
||||||
}
|
|
||||||
|
|
||||||
const chartLayout = {
|
const chartLayout = {
|
||||||
background: {
|
background: {
|
||||||
|
@ -110,7 +100,7 @@ const gridLayout = {
|
||||||
color: "#FFF5",
|
color: "#FFF5",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let w;
|
let w = $state();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<svelte:options runes={true} />
|
||||||
<script>
|
<script>
|
||||||
import { page } from "$app/stores";
|
import { page } from "$app/stores";
|
||||||
import {
|
import {
|
||||||
|
@ -9,18 +10,17 @@ import {
|
||||||
import { CandlestickSeries, Chart, TimeScale } from "svelte-lightweight-charts";
|
import { CandlestickSeries, Chart, TimeScale } from "svelte-lightweight-charts";
|
||||||
|
|
||||||
const market = $page.params.market;
|
const market = $page.params.market;
|
||||||
export let data;
|
let {data} = $props();
|
||||||
const interval = 86400000;
|
const interval = 86400000;
|
||||||
let trades = [];
|
let trades = $derived((() => {
|
||||||
const getData = () => {
|
let trades = data.trades
|
||||||
trades = data.trades
|
|
||||||
.map((e) => {
|
.map((e) => {
|
||||||
return {
|
return {
|
||||||
time: new Date(e.date),
|
time: new Date(e.date),
|
||||||
value: getPrice(e.price, e.currency, false, false),
|
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 = Object.groupBy(
|
||||||
trades,
|
trades,
|
||||||
|
@ -38,16 +38,11 @@ const getData = () => {
|
||||||
}, {});
|
}, {});
|
||||||
trades[intervalDate].time = Number.parseInt(intervalDate, 10);
|
trades[intervalDate].time = Number.parseInt(intervalDate, 10);
|
||||||
}
|
}
|
||||||
trades = Object.values(trades);
|
return Object.values(trades);
|
||||||
};
|
})());
|
||||||
let w;
|
|
||||||
|
|
||||||
let precision = 1e-2;
|
let precision = $derived(getSignificantDigits(trades.flatMap((e) => [e.open, e.close])));
|
||||||
|
let w = $state();
|
||||||
$: {
|
|
||||||
getData();
|
|
||||||
precision = getSignificantDigits(trades.flatMap((e) => [e.open, e.close]));
|
|
||||||
}
|
|
||||||
|
|
||||||
const chartLayout = {
|
const chartLayout = {
|
||||||
background: {
|
background: {
|
||||||
|
@ -90,7 +85,7 @@ const BUY_SELL = isMoneroQuote(market) ? ["SELL", "BUY"] : ["BUY", "SELL"];
|
||||||
<th>Amount (XMR)</th>
|
<th>Amount (XMR)</th>
|
||||||
<th>Amount ({market})</th>
|
<th>Amount ({market})</th>
|
||||||
</tr>
|
</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}>
|
<tr title={offer.paymentMethod}>
|
||||||
<td>{formatPrice(offer.price, market, false, false)}</td>
|
<td>{formatPrice(offer.price, market, false, false)}</td>
|
||||||
<td>{formatPrice(offer.amount, "XMR", 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 (XMR)</th>
|
||||||
<th>Amount ({market})</th>
|
<th>Amount ({market})</th>
|
||||||
</tr>
|
</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}>
|
<tr title={offer.paymentMethod}>
|
||||||
<td>{formatPrice(offer.price, market, false, false)}</td>
|
<td>{formatPrice(offer.price, market, false, false)}</td>
|
||||||
<td>{formatPrice(offer.amount, "XMR", 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