mirror of
https://github.com/db9979/wibosim.git
synced 2026-12-06 13:34:09 +01:00
- Ereigniskalender und „Deine Termine“: Kalenderblatt je Tag (Wochentag farbig, große Tageszahl, Monat), Heute/Morgen hervorgehoben, Turbo-Modus mit Handelstag-Blättern; je Art farbiges Abzeichen bzw. Firmenlogo mit kleinem Abzeichen und getöntem Art-Chip; Morgenbriefing „Heute wichtig“ im selben Stil; Kartenköpfe der Seite mit Abzeichen - Neues Modul badges.js: badge(kind), logoBadge, itemBadge, kindChip – einheitlich in Posteingang (Liste und Lesebereich), Vorschau auf der Community-Seite und in Toasts (Dividende, Margin, Aufsicht, Nachricht, Kursalarm) - Neues Modul fills.js: „10 × NVLT gekauft zu 144,97 €“ (verkauft/eingedeckt/leer verkauft) mit Logo, grün/rot getönt, Funken (Münzen bei Gewinn); Teilausführungen werden gebündelt - Orderticket: Haken-Animation auf dem Kaufen/Verkaufen-Knopf nach dem Absenden - Server: Ausführungsmeldung enthält den Bestand davor (before), mit Test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUhQVoPUusUzxgxLWkK
47 lines
2.0 KiB
JavaScript
47 lines
2.0 KiB
JavaScript
// Ausführungsmeldung (fill): enthält den Bestand vor der Ausführung, damit der Client
|
|
// „gekauft“, „verkauft“, „leer verkauft“ und „eingedeckt“ unterscheiden kann.
|
|
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import os from 'node:os';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
process.env.NODE_ENV = 'test';
|
|
process.env.TIME_MODE = 'turbo';
|
|
process.env.DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), 'wibosim-fill-'));
|
|
const { settings } = await import('./settings.js');
|
|
const { Store } = await import('./store.js');
|
|
const { Game } = await import('./game.js');
|
|
|
|
Object.assign(settings.game, { dayMs: 60_000, tickMs: 1000, staticCorridor: 0.5, dynamicCorridor: 0.3, marketHaltPct: 0.5, recallsEnabled: false });
|
|
settings.news.enabled = false;
|
|
|
|
test('Ausführungsmeldung nennt den Bestand vor der Ausführung', async () => {
|
|
const clock = { t: Date.now() };
|
|
const g = new Game({ store: new Store(fs.mkdtempSync(path.join(os.tmpdir(), 'wibosim-fl-'))), now: () => clock.t });
|
|
const a = (await g.register({ name: 'Fuellerin', password: 'geheim123' })).player;
|
|
for (let i = 0; i < 400 && g.market.phase !== 'continuous'; i++) { clock.t += 1000; g.tick(); }
|
|
assert.equal(g.market.phase, 'continuous');
|
|
const fills = [];
|
|
g.sendTo = (id, m) => { if (m.type === 'fill' && id === a.id) fills.push(m); };
|
|
const sym = 'RHBK';
|
|
|
|
g.placeOrder(a, { symbol: sym, side: 'buy', type: 'market', qty: 10 });
|
|
assert.ok(fills.length >= 1);
|
|
assert.equal(fills[0].before, 0);
|
|
assert.equal(fills[0].side, 'buy');
|
|
|
|
fills.length = 0;
|
|
g.placeOrder(a, { symbol: sym, side: 'sell', type: 'market', qty: 10 });
|
|
assert.equal(fills[0].before, 10); // gewöhnlicher Verkauf
|
|
|
|
fills.length = 0;
|
|
g.placeOrder(a, { symbol: sym, side: 'sell', type: 'market', qty: 5 });
|
|
assert.equal(fills[0].before, 0); // Leerverkauf
|
|
assert.equal(a.positions[sym].qty, -5);
|
|
|
|
fills.length = 0;
|
|
g.placeOrder(a, { symbol: sym, side: 'buy', type: 'market', qty: 5 });
|
|
assert.equal(fills[0].before, -5); // Eindecken
|
|
});
|