ci / test (postgres) (push) Successful in 3m33s
ci / test (sqlite) (push) Successful in 4m16s
ci / image (push) Successful in 2m55s
ci / test (postgres) (pull_request) Successful in 3m42s
ci / test (sqlite) (pull_request) Successful in 4m36s
ci / image (pull_request) Successful in 2m2s
The analyst of SPEC 10.2 point 5 sends the fresh stories about held and candidate instruments to Anthropic, an OpenAI-compatible service or Ollama, eight to a request, over plain HTTP with no SDK. The news text travels as escaped JSON data; only the appendix B schema is kept, instruments not already linked are dropped, and a verdict can only add a restriction. Each request goes out only if its worst-case cost still fits under the daily cap; verdicts are cached by content hash. Without a key nothing is asked and the rules work as before. ADR 0014 point 15. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
788 lines
44 KiB
Plaintext
788 lines
44 KiB
Plaintext
@inherits LoadedComponent
|
|
@page "/impostazioni"
|
|
@inject AnubisHost Host
|
|
@inject ShellData Shell
|
|
@inject SecondFactorDrafts Drafts
|
|
@inject Anubis.Core.IClock Clock
|
|
@using Anubis.Data
|
|
@using Anubis.Trading
|
|
|
|
<PageTitle>Impostazioni · Anubis</PageTitle>
|
|
|
|
@* SPEC 13.5: appearance, accounts and keys, data, security, system. The other sections arrive with their phases. *@
|
|
@if (Ok is { } ok)
|
|
{
|
|
<p class="notice notice-gain" role="status"><Icon Name="check" Size="16" />@(ok switch
|
|
{
|
|
"password" => "Password cambiata. Le altre sessioni sono state chiuse.",
|
|
"due-fattori" => "Secondo fattore attivato.",
|
|
"due-fattori-tolti" => "Secondo fattore disattivato.",
|
|
"salvataggio" => "Salvataggio fatto.",
|
|
"chiavi" => "Chiavi verificate e salvate: possono fare ordini e non possono prelevare. Il motore è ripartito e le usa.",
|
|
"chiavi-tolte" => "Chiavi tolte: quel conto torna al simulatore interno per le strategie che non hanno ancora storia sul conto di prova.",
|
|
"capitale" => "Capitale affidato aggiornato e diviso tra le strategie.",
|
|
"limiti" => "Limiti di rischio salvati.",
|
|
"rischio" => "Impostazione del rischio salvata.",
|
|
"telegram" => "Telegram funziona: ti ho mandato un messaggio di prova e ho salvato token e chat.",
|
|
"telegram-prova" => "Messaggio di prova partito: controlla il telefono.",
|
|
"telegram-tolto" => "Telegram tolto: non ti scrivo più finché non lo rimetti.",
|
|
"segnale" => "Segnale di vita salvato: la prima chiamata è andata bene, da adesso lo chiamo ogni minuto.",
|
|
"segnale-tolto" => "Segnale di vita tolto.",
|
|
"fonte" => "Fonte aggiornata: vale dal prossimo giro delle notizie, tra al massimo 2 minuti.",
|
|
"chiave" => "Chiave salvata. Non la mostro più: se serve cambiarla, scrivine una nuova.",
|
|
"chiave-tolta" => "Chiave tolta.",
|
|
|
|
_ => "Fatto.",
|
|
})</p>
|
|
}
|
|
@if (ErrorText is { } error)
|
|
{
|
|
<p class="notice notice-loss" role="alert"><Icon Name="alert" Size="16" />@error</p>
|
|
}
|
|
|
|
<nav class="tabs" aria-label="Sezioni delle impostazioni">
|
|
<a href="#aspetto">Aspetto</a><a href="#conti">Conti</a><a href="#rischio">Rischio</a><a href="#telegram">Telegram</a><a href="#dati">Dati</a><a href="#notizie">Notizie</a><a href="#sicurezza">Sicurezza</a><a href="#sistema">Sistema</a><a href="#modifiche">Modifiche</a>
|
|
</nav>
|
|
|
|
<section class="panel" id="aspetto">
|
|
<h2>Aspetto</h2>
|
|
@foreach (var setting in _appearance)
|
|
{
|
|
var definition = SettingsStore.Definition(setting.Key);
|
|
<form method="post" action="/azioni/impostazioni/@setting.Key" class="form-inline">
|
|
<AntiforgeryToken />
|
|
<input type="hidden" name="ritorno" value="/impostazioni#aspetto" />
|
|
<label for="@setting.Key">@definition.Label</label>
|
|
<select id="@setting.Key" name="valore" disabled="@setting.ReadOnly" data-autosubmit>
|
|
@foreach (var value in definition.Allowed!)
|
|
{
|
|
<option value="@value" selected="@(value == setting.Value)">@Label(value)</option>
|
|
}
|
|
</select>
|
|
@if (setting.ReadOnly)
|
|
{
|
|
<span class="hint">Fissato da @setting.Source: si cambia lì.</span>
|
|
}
|
|
else
|
|
{
|
|
<button class="btn btn-small" type="submit">Salva</button>
|
|
}
|
|
</form>
|
|
}
|
|
<p class="hint">Gli importi in dollari usano il cambio del giorno, che arriva con i dati di mercato. Fino ad allora restano in euro.</p>
|
|
</section>
|
|
|
|
<section class="panel" id="conti">
|
|
<h2>Conti e chiavi</h2>
|
|
<p class="hint">In questa fase uso solo denaro finto: il simulatore interno è sempre acceso e, con le chiavi dei conti di prova, le strategie passano ai conti di prova dei broker. Le chiavi di conti veri non servono e non vanno inserite.</p>
|
|
@foreach (var b in _brokers)
|
|
{
|
|
<h3>@b.Title</h3>
|
|
<dl class="facts">
|
|
@foreach (var k in b.Keys)
|
|
{
|
|
<dt>@k.Label</dt><dd>@KeyState(k.Status)</dd>
|
|
}
|
|
@if (b.State is { KeyCheckedAt: { } checkedAt } state)
|
|
{
|
|
<dt>Permessi</dt>
|
|
<dd class="@(state.KeyCanWithdraw == true ? "loss" : null)">@(state.KeyCanWithdraw == true ? "Permette i prelievi: va sostituita, intanto niente nuovi acquisti" : state.KeyCanTrade == true ? "Legge e fa ordini, nessun prelievo" : "Solo lettura") (verificati @Inline(Format.ShortDate(checkedAt, Shell.Now, Shell.Zone)))</dd>
|
|
}
|
|
</dl>
|
|
@if (Shell.IsDemo)
|
|
{
|
|
<p class="hint">Nella modalità dimostrativa chiavi e capitale non si cambiano.</p>
|
|
}
|
|
else if (b.Keys.Any(k => k.Status.FromEnvironment))
|
|
{
|
|
<p class="hint">Le chiavi arrivano dalle variabili d'ambiente e valgono più di quelle salvate qui: si cambiano nella configurazione del container.</p>
|
|
}
|
|
else
|
|
{
|
|
<form method="post" action="/azioni/chiavi/@b.Broker" class="form" autocomplete="off">
|
|
<AntiforgeryToken />
|
|
@foreach (var k in b.Keys)
|
|
{
|
|
<label for="k-@k.Name">@k.Label</label>
|
|
<input id="k-@k.Name" name="@k.Name" type="password" autocomplete="off" spellcheck="false" maxlength="512" required />
|
|
}
|
|
<button class="btn" type="submit">Verifica e salva</button>
|
|
</form>
|
|
<p class="hint">Non le rimostro mai. Prima di salvarle chiedo al broker cosa possono fare: una chiave che permette i prelievi la rifiuto. Dopo il salvataggio il motore riparte da solo, in pochi secondi.</p>
|
|
@if (b.Keys.Any(k => k.Status.IsSet))
|
|
{
|
|
<form method="post" action="/azioni/chiavi/@b.Broker/togli" class="form-inline"><AntiforgeryToken /><button class="btn btn-small" type="submit" data-confirm="Tolgo le chiavi di @b.Short? Le posizioni sul conto di prova restano lì, ma il bot non le segue più finché non le rimetti.">Togli le chiavi</button></form>
|
|
}
|
|
}
|
|
|
|
<h4>Capitale affidato a @b.Short</h4>
|
|
@if (b.Entrusted is { } e)
|
|
{
|
|
<p>@Format.Money(e.AmountEur, "EUR")@(e.Currency == "EUR" ? "" : $", cioè {Format.Money(e.Amount, e.Currency)} al cambio di {Format.Quantity(e.FxRate)}"), deciso @Inline(Format.ShortDate(e.At, Shell.Now, Shell.Zone)) da @e.ChangedBy.</p>
|
|
}
|
|
else
|
|
{
|
|
<p>Nessun capitale affidato: le strategie di @b.Short osservano soltanto.</p>
|
|
}
|
|
@if (b.Strategies.Count > 0)
|
|
{
|
|
<ul class="plain">
|
|
@foreach (var s in b.Strategies)
|
|
{
|
|
<li>@StrategyNames.Label(s.Strategy, withMarket: true): quota @Format.Percent(s.Share * 100m, 0), capitale @Format.Money(s.Capital, s.Currency), liquidità @Format.Money(s.Cash, s.Currency)</li>
|
|
}
|
|
</ul>
|
|
}
|
|
@if (!Shell.IsDemo)
|
|
{
|
|
<form method="post" action="/azioni/capitale/@b.Broker" class="form-inline">
|
|
<AntiforgeryToken />
|
|
<label for="euro-@b.Broker">Nuovo importo in euro</label>
|
|
<input id="euro-@b.Broker" name="euro" inputmode="decimal" autocomplete="off" value="@(b.Entrusted is { } cur ? Format.Quantity(cur.AmountEur) : "")" required />
|
|
<button class="btn btn-small" type="submit">Salva</button>
|
|
</form>
|
|
<p class="hint">Si divide tra le strategie del conto secondo le quote@(b.Broker == Venues.Alpaca ? ", in dollari al cambio BCE del giorno" : ""). Ridurlo non vende nulla: se una strategia ha investito più di quanto le resterebbe, aspetto che venda.</p>
|
|
}
|
|
}
|
|
</section>
|
|
|
|
<section class="panel" id="rischio">
|
|
<h2>Rischio</h2>
|
|
<p class="note">I limiti valgono per tutte le strategie insieme. Abbassarli è sempre possibile. @(_anyLive ? "Una strategia usa soldi veri: per alzarne uno servono la frase e la password." : "Finché nessuna strategia usa soldi veri, puoi anche alzarli.")</p>
|
|
@if (!Shell.IsDemo)
|
|
{
|
|
<form method="post" action="/azioni/rischio/limiti" class="form-grid limits-form">
|
|
<AntiforgeryToken />
|
|
@foreach (var l in _limits)
|
|
{
|
|
<label>@l.Label<input name="@l.Key" value="@l.Value" inputmode="decimal" autocomplete="off" readonly="@l.ReadOnly" /></label>
|
|
}
|
|
@if (_anyLive)
|
|
{
|
|
<label>Per alzare un limite scrivi: <code>@StageBook.RaisePhrase</code><input name="frase" autocomplete="off" /></label>
|
|
<label>Password<input name="password" type="password" autocomplete="current-password" /></label>
|
|
<label>Codice a sei cifre (se attivo)<input name="codice" inputmode="numeric" autocomplete="one-time-code" /></label>
|
|
}
|
|
<button class="btn" type="submit">Salva i limiti</button>
|
|
</form>
|
|
<h3>Protezione day trade</h3>
|
|
<form method="post" action="/azioni/rischio/@Anubis.Risk.RiskSettings.PdtGuard.Key" class="form-inline">
|
|
<AntiforgeryToken />
|
|
<label for="pdt">Per un conto Alpaca sotto i 25.000 $: al massimo 3 operazioni aperte e chiuse in giornata ogni 5 sedute.</label>
|
|
<select id="pdt" name="valore" data-autosubmit>
|
|
<option value="off" selected="@(_pdt == "off")">Spenta</option>
|
|
<option value="on" selected="@(_pdt == "on")">Accesa</option>
|
|
</select>
|
|
<noscript><button class="btn btn-small" type="submit">Salva</button></noscript>
|
|
</form>
|
|
<h3>Scenari «Se succedesse domani»</h3>
|
|
<form method="post" action="/azioni/rischio/@Anubis.Risk.Scenarios.Setting.Key" class="form">
|
|
<AntiforgeryToken />
|
|
<label for="scenari">Uno per riga: descrizione; variazione delle crypto %; delle azioni USA %; del dollaro sull'euro %. Per esempio «Le crypto perdono il 20% in un giorno; -20; 0; 0».</label>
|
|
<textarea id="scenari" name="valore" rows="5" spellcheck="false">@_scenarios</textarea>
|
|
<button class="btn" type="submit">Salva gli scenari</button>
|
|
</form>
|
|
}
|
|
else
|
|
{
|
|
<dl class="facts">
|
|
@foreach (var l in _limits)
|
|
{
|
|
<dt>@l.Label</dt><dd>@l.Value</dd>
|
|
}
|
|
</dl>
|
|
}
|
|
</section>
|
|
|
|
<section class="panel" id="telegram">
|
|
<h2>Telegram e segnale di vita</h2>
|
|
<p class="hint">Su Telegram ti scrivo il riepilogo del mattino, ogni acquisto e vendita con il risultato, gli avvisi di rischio, i blocchi e gli errori. Dalla stessa chat accetto /stato, /posizioni, /oggi, /pausa, /riprendi, /ferma (con conferma) e /aiuto; da altre chat nessun comando. Soldi veri, limiti e chiavi non si cambiano da Telegram.</p>
|
|
<dl class="facts">
|
|
<dt>Token del bot</dt><dd>@KeyState(_telegramToken)</dd>
|
|
<dt>Chat</dt><dd>@KeyState(_telegramChat)</dd>
|
|
<dt>Ultimo messaggio partito</dt><dd>@(_queue?.LastSentAt is { } sent ? Format.ShortDate(sent, Shell.Now, Shell.Zone) : "Nessuno")</dd>
|
|
@if (_queue is { } q && (q.Pending > 0 || q.Retrying > 0 || q.GaveUp > 0))
|
|
{
|
|
<dt>In attesa</dt><dd>@q.Pending in coda@(q.Retrying > 0 ? $", {q.Retrying} da ritentare" : "")@(q.GaveUp > 0 ? $", {q.GaveUp} non partiti" : "")</dd>
|
|
}
|
|
@if (_queue?.LastError is { } lastError)
|
|
{
|
|
<dt>Ultimo errore</dt><dd class="loss">@lastError</dd>
|
|
}
|
|
</dl>
|
|
@if (Shell.IsDemo)
|
|
{
|
|
<p class="hint">Nella modalità dimostrativa Telegram non si usa.</p>
|
|
}
|
|
else if (_telegramToken.FromEnvironment || _telegramChat.FromEnvironment)
|
|
{
|
|
<p class="hint">Token e chat arrivano dalle variabili d'ambiente: si cambiano nella configurazione del container.</p>
|
|
}
|
|
else
|
|
{
|
|
<form method="post" action="/azioni/telegram" class="form" autocomplete="off">
|
|
<AntiforgeryToken />
|
|
<label for="tg-token">Token del bot (da @@BotFather)</label>
|
|
<input id="tg-token" name="token" type="password" autocomplete="off" spellcheck="false" maxlength="200" required />
|
|
<label for="tg-chat">Numero della chat</label>
|
|
<input id="tg-chat" name="chat" inputmode="numeric" autocomplete="off" spellcheck="false" maxlength="40" required />
|
|
<button class="btn" type="submit">Prova e salva</button>
|
|
</form>
|
|
<p class="hint">Prima di salvarli mando un messaggio di prova: se non parte, non salvo nulla. Il token non lo rimostro mai.</p>
|
|
}
|
|
@if (!Shell.IsDemo && _telegramToken.IsSet && _telegramChat.IsSet)
|
|
{
|
|
<form method="post" action="/azioni/telegram/prova" class="form-inline"><AntiforgeryToken /><button class="btn btn-small" type="submit">Manda un messaggio di prova</button></form>
|
|
@if (!_telegramToken.FromEnvironment && !_telegramChat.FromEnvironment)
|
|
{
|
|
<form method="post" action="/azioni/telegram/togli" class="form-inline"><AntiforgeryToken /><button class="btn btn-small" type="submit" data-confirm="Tolgo token e chat? Non ti scrivo più su Telegram finché non li rimetti.">Togli Telegram</button></form>
|
|
}
|
|
}
|
|
|
|
<h3>Stato periodico</h3>
|
|
<form method="post" action="/azioni/impostazioni/@SettingsStore.TelegramStatus.Key" class="form-inline">
|
|
<AntiforgeryToken />
|
|
<input type="hidden" name="ritorno" value="/impostazioni#telegram" />
|
|
<label for="tg-status">@SettingsStore.TelegramStatus.Label</label>
|
|
<select id="tg-status" name="valore" disabled="@(_telegramStatus.ReadOnly || Shell.IsDemo)" data-autosubmit>
|
|
@foreach (var value in SettingsStore.TelegramStatus.Allowed!)
|
|
{
|
|
<option value="@value" selected="@(value == _telegramStatus.Value)">@(value switch { "hourly" => "Ogni ora", "daily" => "Ogni sera alle 20:00", _ => "Mai" })</option>
|
|
}
|
|
</select>
|
|
<button class="btn btn-small" type="submit">Salva</button>
|
|
</form>
|
|
|
|
<h3>Segnale di vita</h3>
|
|
<p class="hint">Facoltativo. Se metti l'indirizzo di un servizio di controllo esterno (per esempio healthchecks.io), lo chiamo ogni minuto. Quando le chiamate si fermano è quel servizio ad avvisarti: è l'unico modo per sapere che il bot è spento quando è spento.</p>
|
|
<dl class="facts">
|
|
<dt>Indirizzo</dt><dd>@(Host.Services!.Telegram?.ConfiguredHeartbeat is not null ? "Dalla configurazione d'avvio (ANUBIS_HEARTBEAT_URL)" : KeyState(_heartbeat))</dd>
|
|
@if (Host.Services.Telegram is { } tg)
|
|
{
|
|
<dt>Ultima chiamata riuscita</dt><dd>@(tg.Heartbeat.LastOk is { } beat ? Format.ShortDate(beat, Shell.Now, Shell.Zone) : "Nessuna da quando il bot è partito")</dd>
|
|
@if (tg.Heartbeat.LastError is { } beatError)
|
|
{
|
|
<dt>Ultimo errore</dt><dd class="loss">@beatError</dd>
|
|
}
|
|
}
|
|
</dl>
|
|
@if (!Shell.IsDemo && Host.Services.Telegram is { ConfiguredHeartbeat: null })
|
|
{
|
|
<form method="post" action="/azioni/segnale-di-vita" class="form-inline" autocomplete="off">
|
|
<AntiforgeryToken />
|
|
<label for="hb-url">Indirizzo</label>
|
|
<input id="hb-url" name="indirizzo" type="url" autocomplete="off" spellcheck="false" maxlength="500" placeholder="https://hc-ping.com/…" required />
|
|
<button class="btn btn-small" type="submit">Prova e salva</button>
|
|
</form>
|
|
@if (_heartbeat.IsSet)
|
|
{
|
|
<form method="post" action="/azioni/segnale-di-vita/togli" class="form-inline"><AntiforgeryToken /><button class="btn btn-small" type="submit">Togli il segnale di vita</button></form>
|
|
}
|
|
}
|
|
</section>
|
|
|
|
<section class="panel" id="dati">
|
|
|
|
<h2>Dati</h2>
|
|
@if (Host.Services!.MarketData is not { } market)
|
|
{
|
|
<p class="note">@(Shell.IsDemo ? "Nella modalità dimostrativa i dati di mercato non si scaricano." : "La raccolta dei dati di mercato è spenta (ANUBIS_MARKET_DATA).")</p>
|
|
}
|
|
else
|
|
{
|
|
<dl class="facts">
|
|
<dt>Prezzi crypto in diretta</dt><dd>@(market.LiveConnected ? "collegati" : "non collegati")</dd>
|
|
<dt>Ultimo giro dello storico</dt><dd>@(market.LastHistoryRun is { } run ? Format.ShortDate(run, Shell.Now, Shell.Zone) : "in corso o non ancora fatto")</dd>
|
|
</dl>
|
|
}
|
|
@if (_sources.Count > 0)
|
|
{
|
|
<h3>Fonti</h3>
|
|
<div class="table-wrap">
|
|
<table class="table">
|
|
<thead><tr><th scope="col">Fonte</th><th scope="col">Stato</th><th scope="col">Ultima risposta</th><th scope="col">Note</th></tr></thead>
|
|
<tbody>
|
|
@foreach (var s in _sources)
|
|
{
|
|
<tr>
|
|
<td>@SourceName(s.Source)</td>
|
|
<td>@(!s.Enabled ? "spenta" : s.LastError is null ? "attiva" : "in errore")</td>
|
|
<td class="nowrap">@(s.LastSuccessAt is { } at ? Format.ShortDate(at, Shell.Now, Shell.Zone) : "—")</td>
|
|
<td>@(s.LastError ?? s.Note)</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
}
|
|
<p class="hint"><a href="/api/data/quality?format=md&days=30">Rapporto sulla qualità dei dati degli ultimi 30 giorni</a></p>
|
|
|
|
</section>
|
|
|
|
<section class="panel" id="notizie">
|
|
<h2>Notizie e calendario</h2>
|
|
<p class="hint">Le notizie e gli eventi in calendario non fanno mai comprare: possono solo fermare o rimandare un acquisto, e ogni volta il diario dice perché.</p>
|
|
|
|
<h3>Regole</h3>
|
|
@foreach (var rule in _newsRules)
|
|
{
|
|
var definition = SettingsStore.Definition(rule.Key);
|
|
<form method="post" action="/azioni/impostazioni/@rule.Key" class="form-inline">
|
|
<AntiforgeryToken />
|
|
<input type="hidden" name="ritorno" value="/impostazioni#notizie" />
|
|
<label for="@rule.Key">@definition.Label</label>
|
|
<select id="@rule.Key" name="valore" disabled="@(rule.ReadOnly || Shell.IsDemo)" data-autosubmit>
|
|
<option value="on" selected="@(rule.Value != "off")">Accesa</option>
|
|
<option value="off" selected="@(rule.Value == "off")">Spenta</option>
|
|
</select>
|
|
@if (rule.ReadOnly)
|
|
{
|
|
<span class="hint">Fissato da @rule.Source: si cambia lì.</span>
|
|
}
|
|
else if (!Shell.IsDemo)
|
|
{
|
|
<noscript><button class="btn btn-small" type="submit">Salva</button></noscript>
|
|
}
|
|
</form>
|
|
}
|
|
|
|
<h3>Fonti delle notizie</h3>
|
|
@if (_newsSources.Count == 0)
|
|
{
|
|
<p class="note">Le fonti compaiono qui dopo il primo giro delle notizie, che parte con i dati di mercato.</p>
|
|
}
|
|
else
|
|
{
|
|
<p class="hint">Una notizia da una sola fonte non affidabile non cambia nulla finché un'altra fonte non la conferma.</p>
|
|
<div class="table-wrap">
|
|
<table class="table">
|
|
<thead><tr><th scope="col">Fonte</th><th scope="col">Leggo</th><th scope="col">Affidabile</th><th scope="col">Ultima lettura</th><th scope="col">Stato</th><th scope="col"><span class="sr-only">Salva</span></th></tr></thead>
|
|
<tbody>
|
|
@foreach (var f in _newsSources)
|
|
{
|
|
var form = "fonte-" + f.Id.ToString("N");
|
|
<tr>
|
|
<td>@f.Name</td>
|
|
<td><input type="checkbox" name="attiva" form="@form" checked="@f.Enabled" disabled="@Shell.IsDemo" aria-label="Leggo @f.Name" /></td>
|
|
<td><input type="checkbox" name="affidabile" form="@form" checked="@f.Trusted" disabled="@Shell.IsDemo" aria-label="@f.Name è affidabile" /></td>
|
|
<td class="nowrap">@(f.LastOkAt is { } at ? Format.ShortDate(at, Shell.Now, Shell.Zone) : "—")</td>
|
|
<td>@(!f.Enabled ? "spenta" : f.LastError is { } problem ? "non risponde: " + problem : "risponde")</td>
|
|
<td>
|
|
@if (!Shell.IsDemo)
|
|
{
|
|
<form id="@form" method="post" action="/azioni/notizie/fonti/@f.Id"><AntiforgeryToken /><button class="btn btn-small" type="submit">Salva</button></form>
|
|
}
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
}
|
|
|
|
<h3>Modello linguistico</h3>
|
|
<p class="hint">Facoltativo. Rilegge le notizie delle ultime 24 ore sulle tue posizioni e sugli strumenti candidati, otto per richiesta: può aggiungere una restrizione, mai toglierla, e non vede né chiavi né conti. Senza chiave tutto funziona lo stesso con il classificatore locale. Con Ollama, sul tuo computer o nella tua rete, la chiave non serve.</p>
|
|
@DataKey(Anubis.News.NewsModelSettings.KeySecret, "Chiave del modello linguistico")
|
|
@ModelSetting(Anubis.News.NewsModelSettings.Provider.Key, "servizio", "Servizio", null)
|
|
@ModelSetting(Anubis.News.NewsModelSettings.Model.Key, "modello", "Modello", null)
|
|
@ModelSetting(Anubis.News.NewsModelSettings.Address.Key, "indirizzo", "Indirizzo (vuoto per quello solito del servizio)", null)
|
|
@ModelSetting(Anubis.News.NewsModelSettings.PriceIn.Key, "prezzo-letti", "Dollari per milione di token letti", 4)
|
|
@ModelSetting(Anubis.News.NewsModelSettings.PriceOut.Key, "prezzo-scritti", "Dollari per milione di token scritti", 4)
|
|
@ModelSetting(Anubis.News.NewsModelSettings.DailyCap.Key, "tetto", "Tetto di spesa al giorno (€)", 2)
|
|
<p class="note">I prezzi in dollari li conto come euro: la spesa calcolata è un po' più alta di quella vera, mai più bassa. Il tetto vale da mezzanotte a mezzanotte; prima di ogni richiesta controllo che anche il caso peggiore ci stia dentro.</p>
|
|
|
|
<h3>Calendario</h3>
|
|
<p class="hint">Senza chiave di Finnhub non conosco le date delle trimestrali e la mean reversion non usa il suo filtro; senza chiave di FRED il calendario usa solo Forex Factory. Le chiavi sono gratuite.</p>
|
|
@DataKey("FINNHUB_API_KEY", "Chiave di Finnhub")
|
|
@DataKey("FRED_API_KEY", "Chiave di FRED")
|
|
<h3>Riunioni di Fed e BCE</h3>
|
|
<form method="post" action="/azioni/impostazioni/@SettingsStore.CentralBankMeetings.Key" class="form">
|
|
<AntiforgeryToken />
|
|
<input type="hidden" name="ritorno" value="/impostazioni#notizie" />
|
|
<label for="riunioni">Un giorno di decisione per riga, per esempio «FED 2027-01-27» o «BCE 2027-02-04». Aggiungi le date del nuovo anno quando le banche le pubblicano.</label>
|
|
<textarea id="riunioni" name="valore" rows="8" spellcheck="false" readonly="@_meetings.ReadOnly">@_meetings.Value</textarea>
|
|
<button class="btn" type="submit">Salva l'elenco</button>
|
|
</form>
|
|
</section>
|
|
|
|
<section class="panel" id="sicurezza">
|
|
<h2>Sicurezza</h2>
|
|
@if (Shell.IsDemo)
|
|
{
|
|
<p class="hint">Nella modalità dimostrativa password e secondo fattore non si cambiano.</p>
|
|
}
|
|
else
|
|
{
|
|
<h3>Password</h3>
|
|
<form method="post" action="/azioni/password" class="form">
|
|
<AntiforgeryToken />
|
|
<label for="attuale">Password attuale</label>
|
|
<input id="attuale" name="attuale" type="password" autocomplete="current-password" required />
|
|
<label for="nuova">Nuova password</label>
|
|
<input id="nuova" name="nuova" type="password" autocomplete="new-password" minlength="@Passwords.MinimumLength" required />
|
|
<label for="conferma">Scrivila di nuovo</label>
|
|
<input id="conferma" name="conferma" type="password" autocomplete="new-password" minlength="@Passwords.MinimumLength" required />
|
|
<button class="btn" type="submit">Cambia password</button>
|
|
</form>
|
|
|
|
<h3>Secondo fattore</h3>
|
|
@if (_hasSecondFactor)
|
|
{
|
|
<p>Attivo: all'accesso chiedo anche il codice dell'app. Servirà anche per attivare i soldi veri.</p>
|
|
<form method="post" action="/azioni/due-fattori/disattiva" class="form">
|
|
<AntiforgeryToken />
|
|
<label for="password-2fa">Per disattivarlo: password</label>
|
|
<input id="password-2fa" name="password" type="password" autocomplete="current-password" required />
|
|
<label for="codice-2fa">Codice dell'app</label>
|
|
<input id="codice-2fa" name="codice" inputmode="numeric" autocomplete="one-time-code" pattern="[0-9]{6}" maxlength="6" required />
|
|
<button class="btn" type="submit">Disattiva il secondo fattore</button>
|
|
</form>
|
|
}
|
|
else
|
|
{
|
|
<p>Facoltativo: un codice di sei cifre da un'app di autenticazione (per esempio quella del tuo gestore di password), oltre alla password.</p>
|
|
<ol class="steps">
|
|
<li>Nell'app scegli "aggiungi con chiave" e scrivi questa chiave: <code class="secret">@_draft</code></li>
|
|
<li>Oppure, se l'app accetta un indirizzo, usa: <code class="secret">@_draftUri</code></li>
|
|
<li>Scrivi qui il codice che l'app mostra.</li>
|
|
</ol>
|
|
<form method="post" action="/azioni/due-fattori/attiva" class="form">
|
|
<AntiforgeryToken />
|
|
<label for="codice">Codice</label>
|
|
<input id="codice" name="codice" inputmode="numeric" autocomplete="one-time-code" pattern="[0-9]{6}" maxlength="6" required />
|
|
<button class="btn" type="submit">Attiva il secondo fattore</button>
|
|
</form>
|
|
}
|
|
<form method="post" action="/azioni/esci" class="form-inline"><AntiforgeryToken /><button class="btn" type="submit"><Icon Name="logout" Size="18" />Esci</button></form>
|
|
}
|
|
</section>
|
|
|
|
<section class="panel" id="sistema">
|
|
<h2>Sistema</h2>
|
|
<dl class="facts">
|
|
<dt>Piattaforma</dt><dd>@(Host.Config.Platform == PlatformKind.Docker ? "Docker" : "Desktop (Windows)")</dd>
|
|
<dt>Database</dt><dd>@Host.Config.Db?.Describe()</dd>
|
|
<dt>Cartella dei dati</dt><dd>@Host.Config.Data.Root</dd>
|
|
<dt>Chiave dei segreti</dt><dd>@Host.Config.SecretKey.Description</dd>
|
|
<dt>Fuso orario</dt><dd>@Host.Config.TimeZone.Id</dd>
|
|
<dt>Versione</dt><dd>@AnubisInfo.Version</dd>
|
|
</dl>
|
|
<p class="hint">
|
|
@if (Host.Config.Platform == PlatformKind.Docker)
|
|
{
|
|
@:Motore e connessione del database si cambiano solo nella configurazione del container.
|
|
}
|
|
else
|
|
{
|
|
@:Motore e connessione del database stanno in config.toml, nella cartella dei dati. Lo spostamento su un altro database arriva con l'applicazione desktop.
|
|
}
|
|
</p>
|
|
|
|
<h3>Salvataggi</h3>
|
|
<p class="hint">Ogni notte alle 03:30 e prima di ogni aggiornamento dello schema. Tengo gli ultimi @Backups.Keep.</p>
|
|
<form method="post" action="/azioni/salvataggio" class="form-inline"><AntiforgeryToken /><button class="btn" type="submit"><Icon Name="database" Size="18" />Salva adesso</button></form>
|
|
@if (_backups.Count > 0)
|
|
{
|
|
<div class="table-wrap">
|
|
<table class="table">
|
|
<thead><tr><th scope="col">Quando</th><th scope="col">Perché</th><th scope="col">Cartella</th></tr></thead>
|
|
<tbody>
|
|
@foreach (var b in _backups)
|
|
{
|
|
<tr><td class="nowrap">@Format.ShortDate(b.TakenAt, Shell.Now, Shell.Zone)</td><td>@b.Reason</td><td><code>@b.Name</code></td></tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
}
|
|
</section>
|
|
|
|
<section class="panel" id="modifiche">
|
|
<h2>Registro delle modifiche</h2>
|
|
@if (_history.Count == 0)
|
|
{
|
|
<p class="note">Nessuna modifica finora.</p>
|
|
}
|
|
else
|
|
{
|
|
<div class="table-wrap">
|
|
<table class="table">
|
|
<thead><tr><th scope="col">Quando</th><th scope="col">Voce</th><th scope="col">Prima</th><th scope="col">Dopo</th><th scope="col">Chi</th></tr></thead>
|
|
<tbody>
|
|
@foreach (var h in _history)
|
|
{
|
|
<tr><td class="nowrap">@Format.ShortDate(h.At, Shell.Now, Shell.Zone)</td><td>@h.Key</td><td>@Label(h.OldValue)</td><td>@Label(h.NewValue)</td><td>@h.ChangedBy</td></tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
}
|
|
</section>
|
|
|
|
@code {
|
|
private readonly List<SettingValue> _appearance = [];
|
|
private readonly List<BrokerSetup> _brokers = [];
|
|
|
|
private sealed record BrokerKey(string Name, string Label, SecretStatus Status);
|
|
|
|
private sealed record BrokerSetup(string Broker, string Title, string Short, IReadOnlyList<BrokerKey> Keys, AccountState? State, EntrustedCapital? Entrusted,
|
|
IReadOnlyList<StrategyCapital> Strategies);
|
|
private sealed record LimitField(string Key, string Label, string Value, bool ReadOnly);
|
|
private readonly List<LimitField> _limits = [];
|
|
private bool _anyLive;
|
|
private string _pdt = "off";
|
|
private string _scenarios = "";
|
|
private IReadOnlyList<Anubis.Data.SourceState> _sources = [];
|
|
|
|
private SettingValue _meetings = new(SettingsStore.CentralBankMeetings.Key, "", false, null);
|
|
private readonly List<SettingValue> _newsRules = [];
|
|
private readonly Dictionary<string, SettingValue> _llm = [];
|
|
private IReadOnlyList<Anubis.News.NewsSource> _newsSources = [];
|
|
private readonly Dictionary<string, SecretStatus> _dataKeys = [];
|
|
private List<SettingChange> _history = [];
|
|
private IReadOnlyList<BackupInfo> _backups = [];
|
|
private bool _hasSecondFactor;
|
|
private SecretStatus _telegramToken = new(Anubis.Notifications.TelegramSettings.TokenSecret, false, false, null);
|
|
private SecretStatus _telegramChat = new(Anubis.Notifications.TelegramSettings.ChatSecret, false, false, null);
|
|
private SecretStatus _heartbeat = new(TelegramServices.HeartbeatSecret, false, false, null);
|
|
private SettingValue _telegramStatus = new(SettingsStore.TelegramStatus.Key, "never", false, null);
|
|
private Anubis.Notifications.NotificationSummary? _queue;
|
|
private string? _draft;
|
|
private string? _draftUri;
|
|
|
|
[CascadingParameter]
|
|
public HttpContext? HttpContext { get; set; }
|
|
|
|
[SupplyParameterFromQuery(Name = "ok")]
|
|
public string? Ok { get; set; }
|
|
|
|
[SupplyParameterFromQuery(Name = "errore")]
|
|
public string? Errore { get; set; }
|
|
|
|
protected override async Task LoadAsync()
|
|
{
|
|
var ct = HttpContext?.RequestAborted ?? CancellationToken.None;
|
|
var services = Host.Services!;
|
|
_appearance.Add(await services.Settings.GetAsync(SettingsStore.Theme.Key, ct));
|
|
_appearance.Add(await services.Settings.GetAsync(SettingsStore.Currency.Key, ct));
|
|
_history = await services.Settings.HistoryAsync(null, 50, ct);
|
|
_meetings = await services.Settings.GetAsync(SettingsStore.CentralBankMeetings.Key, ct);
|
|
_sources = await new Anubis.Data.SourceStateStore(services.Db, Clock).ListAsync(ct);
|
|
foreach (var rule in Anubis.News.NewsRuleSettings.All)
|
|
{
|
|
_newsRules.Add(await services.Settings.GetAsync(rule.Key, ct));
|
|
}
|
|
|
|
foreach (var setting in Anubis.News.NewsModelSettings.All)
|
|
{
|
|
_llm[setting.Key] = await services.Settings.GetAsync(setting.Key, ct);
|
|
}
|
|
_newsSources = await new Anubis.News.NewsStore(services.Db, Clock).ListSourcesAsync(ct);
|
|
foreach (var name in Forms.DataKeys)
|
|
{
|
|
_dataKeys[name] = await services.Secrets.StatusAsync(name, ct);
|
|
}
|
|
foreach (var definition in Anubis.Risk.RiskSettings.Limits)
|
|
{
|
|
var value = await services.Settings.GetAsync(definition.Key, ct);
|
|
_limits.Add(new LimitField(definition.Key, definition.Label, value.Value, value.ReadOnly));
|
|
}
|
|
|
|
_pdt = (await services.Settings.GetAsync(Anubis.Risk.RiskSettings.PdtGuard.Key, ct)).Value;
|
|
_scenarios = (await services.Settings.GetAsync(Anubis.Risk.Scenarios.Setting.Key, ct)).Value;
|
|
_anyLive = await (services.Trading?.Stages ?? new StageBook(services.Db, Clock, TradingConsent.None, (_, _, _) => Task.FromResult(false))).AnyLiveAsync(null, ct);
|
|
|
|
_backups = services.Backups.List();
|
|
_telegramToken = await services.Secrets.StatusAsync(Anubis.Notifications.TelegramSettings.TokenSecret, ct);
|
|
_telegramChat = await services.Secrets.StatusAsync(Anubis.Notifications.TelegramSettings.ChatSecret, ct);
|
|
_heartbeat = await services.Secrets.StatusAsync(TelegramServices.HeartbeatSecret, ct);
|
|
_telegramStatus = await services.Settings.GetAsync(SettingsStore.TelegramStatus.Key, ct);
|
|
_queue = services.Telegram is { } telegram ? await telegram.Sender.SummaryAsync(ct) : null;
|
|
var ledger = new Ledger(services.Db, Clock);
|
|
var capital = new Capital(services.Db, Clock, ledger, new FxStore(services.Db, Clock));
|
|
var reconciler = new Reconciler(services.Db, Clock, ledger);
|
|
foreach (var (broker, title, name) in new[] { (Venues.Okx, "OKX Europe · conto demo", "OKX"), (Venues.Alpaca, "Alpaca · conto di prova (paper)", "Alpaca") })
|
|
{
|
|
var keys = new List<BrokerKey>();
|
|
foreach (var (secret, label) in TradingService.KeyFields(broker))
|
|
{
|
|
keys.Add(new BrokerKey(secret, label, await services.Secrets.StatusAsync(secret, ct)));
|
|
}
|
|
|
|
var demoAccount = await services.Db.ReadAsync(s => s.FirstOrDefaultAsync("SELECT id FROM accounts WHERE broker = @b AND environment = 'demo'", r => (Guid?)r.Id("id"), ("b", broker)), ct);
|
|
var state = demoAccount is { } id ? await reconciler.StateAsync(id, ct) : null;
|
|
_brokers.Add(new BrokerSetup(broker, title, name, keys, state, await capital.EntrustedAsync(broker, ct), await capital.StrategiesAsync(broker, ct)));
|
|
}
|
|
var user = HttpContext!.User;
|
|
_hasSecondFactor = CurrentUser.HasSecondFactor(user);
|
|
if (!_hasSecondFactor && !Shell.IsDemo)
|
|
{
|
|
var secret = Drafts.For(CurrentUser.Session(user));
|
|
_draft = Base32.Encode(secret);
|
|
_draftUri = Totp.Uri("Anubis", AccessStore.AdminName, secret);
|
|
}
|
|
}
|
|
|
|
private string? ErrorText => Errore switch
|
|
{
|
|
"codice" => "Il codice non è giusto. Controlla l'ora del telefono e riprova con il codice che vedi adesso.",
|
|
"segreto" => "La chiave è scaduta: ricarica la pagina e aggiungi di nuovo Anubis nell'app.",
|
|
"salvataggio" => "Il salvataggio non è riuscito. Controlla lo spazio libero nella cartella dei dati.",
|
|
"impostazione" => "Questa impostazione non si può cambiare così.",
|
|
"riunioni" => "L'elenco delle riunioni non è valido: una riga per riunione, con FED o BCE e la data, per esempio «FED 2027-01-27».",
|
|
"bot" => "Comando non ammesso nello stato attuale del bot.",
|
|
"motore" => "Il motore di trading non è attivo (modalità dimostrativa o ANUBIS_TRADING spento): qui non si cambia nulla.",
|
|
"conto" => "Conto sconosciuto.",
|
|
"ambiente" => "Le chiavi di questo conto arrivano dalle variabili d'ambiente: si cambiano nella configurazione del container.",
|
|
"chiavi-vuote" => "Servono tutti i campi della chiave.",
|
|
"chiavi-rifiutate" => "Il broker non ha accettato la chiave, o non ha risposto. Controlla di aver copiato la chiave del conto di prova e riprova. Non ho salvato nulla.",
|
|
"prelievo" => "Questa chiave permette i prelievi: non la salvo. Creane una senza il permesso di prelievo.",
|
|
"sola-lettura" => "Questa chiave può solo leggere: per lavorare sul conto di prova serve anche il permesso di fare ordini. Non l'ho salvata.",
|
|
"importo" => "Scrivi un importo in euro, per esempio 4000 o 1.500,50.",
|
|
"cambio" => "Manca ancora il cambio euro/dollaro della BCE: lo scarico ogni giorno, riprova più tardi.",
|
|
"capitale" => "Una strategia ha investito più di quanto le resterebbe: potrò ridurre il capitale quando avrà venduto.",
|
|
"limite" => "Un limite non è valido: controlla che ogni valore sia un numero dentro il suo intervallo.",
|
|
"ordine-limiti" => "Il dimezzamento sul calo dal massimo deve venire prima dell'interruttore, e la perdita di un giorno non può superare quella di una settimana.",
|
|
"frase-rischio" => $"Una strategia usa soldi veri: per aggiungere rischio scrivi la frase «{StageBook.RaisePhrase}». Non ho cambiato nulla.",
|
|
"password-rischio" => "Password o codice non corretti. Dopo cinque tentativi sbagliati devi aspettare 15 minuti. Non ho cambiato nulla.",
|
|
"retrocessione-rischio" => "Una strategia con soldi veri ha una condizione di retrocessione in corso: finché dura non si aggiunge rischio. Non ho cambiato nulla.",
|
|
"telegram-rifiutato" => "Telegram non ha accettato token o chat, o non ha risposto: il messaggio di prova non è partito e non ho salvato nulla. Controlla il token di @BotFather e il numero della chat.",
|
|
"telegram-prova" => "Il messaggio di prova non è partito: controlla token e chat, o riprova tra poco.",
|
|
"telegram-vuoto" => "Servono il token del bot e il numero della chat.",
|
|
"telegram-ambiente" => "Token e chat arrivano dalle variabili d'ambiente: si cambiano nella configurazione del container.",
|
|
"segnale" => "L'indirizzo non va bene: serve https:// (http solo nella rete di casa).",
|
|
"segnale-fallito" => "Il servizio di controllo non ha risposto bene alla prova: non ho salvato l'indirizzo.",
|
|
"scenari" => "Gli scenari non sono validi: una riga ciascuno, con descrizione e tre percentuali separate da punto e virgola.",
|
|
"fonte" => "Fonte sconosciuta: ricarica la pagina e riprova.",
|
|
"chiave" => "La chiave è vuota o contiene spazi: copiala di nuovo così come la dà il servizio.",
|
|
"chiave-ambiente" => "Questa chiave arriva dalle variabili d'ambiente: si cambia nella configurazione del container.",
|
|
"tetto" => $"Il tetto di spesa va scritto in euro, da 0 a {Anubis.News.NewsModelSettings.MaxCap:0}, per esempio 0,50.",
|
|
"modello" => "Valore non valido per il modello linguistico: il nome come lo dà il servizio, un indirizzo https:// (http:// solo nella tua rete), prezzi da 0 a 200.",
|
|
|
|
_ => PasswordMessages.For(Errore),
|
|
};
|
|
|
|
// A key of SPEC 13.5 that is not a broker's: its state, a field to replace it, a button to take it away. Never the value.
|
|
// One setting of the language model: a choice for the service, a field for the others; amounts shown in Italian.
|
|
private RenderFragment ModelSetting(string key, string id, string label, int? decimals)
|
|
{
|
|
var definition = SettingsStore.Definition(key);
|
|
var value = _llm.GetValueOrDefault(key) ?? new SettingValue(key, definition.Default, false, null);
|
|
var locked = value.ReadOnly || Shell.IsDemo;
|
|
var shown = decimals is { } d ? Format.Number(decimal.Parse(value.Value, CultureInfo.InvariantCulture), d) : value.Value;
|
|
var provider = _llm.GetValueOrDefault(Anubis.News.NewsModelSettings.Provider.Key)?.Value ?? Anubis.News.NewsModelProviders.Anthropic;
|
|
return @<form method="post" action="/azioni/impostazioni/@key" class="form-inline">
|
|
<AntiforgeryToken />
|
|
<input type="hidden" name="ritorno" value="/impostazioni#notizie" />
|
|
<label for="@id">@label</label>
|
|
@if (definition.Allowed is { } choices)
|
|
{
|
|
<select id="@id" name="valore" disabled="@locked" data-autosubmit>
|
|
@foreach (var choice in choices)
|
|
{
|
|
<option value="@choice" selected="@(choice == value.Value)">@ProviderName(choice)</option>
|
|
}
|
|
</select>
|
|
@if (!locked)
|
|
{
|
|
<noscript><button class="btn btn-small" type="submit">Salva</button></noscript>
|
|
}
|
|
}
|
|
else
|
|
{
|
|
<input id="@id" name="valore" inputmode="@(decimals is null ? "text" : "decimal")" autocomplete="off" spellcheck="false" value="@shown"
|
|
placeholder="@(key == Anubis.News.NewsModelSettings.Address.Key ? Anubis.News.NewsModelProviders.DefaultAddress(provider).ToString() : null)"
|
|
readonly="@locked" required="@(key != Anubis.News.NewsModelSettings.Address.Key)" />
|
|
@if (!locked)
|
|
{
|
|
<button class="btn btn-small" type="submit">Salva</button>
|
|
}
|
|
}
|
|
@if (value.ReadOnly)
|
|
{
|
|
<span class="hint">Fissato da @value.Source: si cambia lì.</span>
|
|
}
|
|
</form>;
|
|
}
|
|
|
|
private static string ProviderName(string provider) => provider switch
|
|
{
|
|
Anubis.News.NewsModelProviders.Anthropic => "Anthropic (Claude)",
|
|
Anubis.News.NewsModelProviders.OpenAi => "Compatibile con OpenAI",
|
|
Anubis.News.NewsModelProviders.Ollama => "Ollama, sul tuo computer o in rete",
|
|
_ => provider,
|
|
};
|
|
|
|
private RenderFragment DataKey(string name, string label)
|
|
{
|
|
var status = _dataKeys.GetValueOrDefault(name) ?? new SecretStatus(name, false, false, null);
|
|
var id = "k-" + name.ToLowerInvariant();
|
|
return @<div class="data-key">
|
|
<p><strong>@label</strong>: @KeyState(status).</p>
|
|
@if (status.FromEnvironment)
|
|
{
|
|
<p class="hint">Si cambia nella configurazione del container (@name).</p>
|
|
}
|
|
else if (!Shell.IsDemo)
|
|
{
|
|
<form method="post" action="/azioni/chiavi-dati/@name" class="form-inline">
|
|
<AntiforgeryToken />
|
|
<label for="@id">@(status.IsSet ? "Nuova chiave" : "Chiave")</label>
|
|
<input id="@id" name="chiave" type="password" autocomplete="off" spellcheck="false" maxlength="512" required />
|
|
<button class="btn btn-small" type="submit">Salva</button>
|
|
</form>
|
|
@if (status.IsSet)
|
|
{
|
|
<form method="post" action="/azioni/chiavi-dati/@name/togli" class="form-inline">
|
|
<AntiforgeryToken />
|
|
<button class="btn btn-small btn-danger" type="submit" data-confirm="Tolgo la chiave: quello che la usa smette di funzionare finché non ne metti un'altra. Confermi?">Togli la chiave</button>
|
|
</form>
|
|
}
|
|
}
|
|
</div>;
|
|
}
|
|
|
|
private string KeyState(SecretStatus status) => status switch
|
|
{
|
|
{ FromEnvironment: true } => "Dalle variabili d'ambiente",
|
|
{ IsSet: true, UpdatedAt: { } at } => "Impostata " + Inline(Format.ShortDate(at, Shell.Now, Shell.Zone)),
|
|
{ IsSet: true } => "Impostata",
|
|
_ => "Non impostata",
|
|
};
|
|
|
|
// "Oggi 08:20" inside a sentence reads "oggi 08:20".
|
|
private static string Inline(string text) => text.Length == 0 ? text : char.ToLowerInvariant(text[0]) + text[1..];
|
|
|
|
private static string SourceName(string source) => source switch
|
|
{
|
|
"okx" => "OKX Europe (crypto)",
|
|
"alpaca" => "Alpaca (azioni, conto di prova)",
|
|
"storico" => "Storico giornaliero delle crypto",
|
|
"storico_azioni" => "Storico giornaliero delle azioni",
|
|
"binance" => "Archivi Binance (ricerca)",
|
|
"ecb" => "Cambi della BCE",
|
|
"forexfactory" => "Calendario economico (Forex Factory)",
|
|
"fred" => "Date dei dati USA (FRED)",
|
|
"finnhub" => "Date delle trimestrali (Finnhub)",
|
|
"central_banks" => "Riunioni di Fed e BCE",
|
|
"alternative.me" => "Indice di paura e avidità",
|
|
"cboe" => "VIX (Cboe)",
|
|
"okx_derivatives" => "Funding e interesse aperto di BTC (OKX)",
|
|
_ => source,
|
|
};
|
|
|
|
private static string Label(string? value) => value switch
|
|
{
|
|
null => "—",
|
|
"auto" => "Come il sistema",
|
|
"light" => "Chiaro",
|
|
"dark" => "Scuro",
|
|
"EUR" => "Euro (EUR)",
|
|
"USD" => "Dollaro (USD)",
|
|
"active" => "Attivo",
|
|
"paused" => "In pausa",
|
|
"stopped" => "Fermo",
|
|
_ => value.Trim('"'),
|
|
};
|
|
}
|