Fix the defects found by the Phase 3 review (refs #33 #26 #27 #28 #29 #30 #31 #32)
ci / test (postgres) (push) Successful in 3m9s
ci / test (sqlite) (push) Successful in 2m28s
ci / test (postgres) (pull_request) Successful in 4m1s
ci / test (sqlite) (pull_request) Failing after 2m31s
ci / image (pull_request) Skipped
ci / image (push) Successful in 1m34s
ci / test (postgres) (push) Successful in 3m9s
ci / test (sqlite) (push) Successful in 2m28s
ci / test (postgres) (pull_request) Successful in 4m1s
ci / test (sqlite) (pull_request) Failing after 2m31s
ci / image (pull_request) Skipped
ci / image (push) Successful in 1m34s
- Splits multiply only the shares held before the ex-date. Old splits in the table no longer inflate positions bought later; the simulator's book follows the same split once, together with the ledger. - Dividends pay the simulator once on the ex-date holdings, and each payment is marked in the same write, so a failure never pays twice. - Positions are marked to market before every equity photograph; until now equity, drawdown and the Conti screen stayed at the last fill. - A sale with no price keeps its broker stops until it can really leave; a purchase with no price is dropped. - A refused sale is retried with pauses of 1, 2, 4, 8 and 15 minutes instead of every tick, and one failing execution no longer stops the stop alignment of the whole account. - On Alpaca a purchase clears the sell stops of every strategy on the symbol and holds them until it ends. - OKX order lookups treat only 51603 as unknown; any other failure is an error, so a lost order is never sent twice. - The reconcile choice and key removal forms now require the antiforgery token; the choice re-runs the comparison and is only offered after the 15 minutes; stale differences are dropped. - A replaced key that cannot withdraw releases the prudent mode. - Re-entering the same euro capital for Alpaca changes nothing; a new amount converts only the euro difference at today's rate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
60d5ebbc05
commit
1a0912e436
17 files changed
+358
-89
No files matched your search
@@ -125,8 +125,11 @@ public sealed class LedgerTests
|
||||
// A 4-for-1 split: four times the shares at a quarter of the price, the value unchanged; applied once.
|
||||
await rig.Ledger.SetStopAsync(alpaca.AccountId, aapl.Id, Strategies.EquityMomentum, 180m, _none).ConfigureAwait(false);
|
||||
var before = (await rig.Ledger.EquitiesAsync(_none).ConfigureAwait(false)).Single(e => e.AccountId == alpaca.AccountId);
|
||||
Assert.IsTrue(await rig.Ledger.ApplySplitAsync(alpaca.AccountId, aapl.Id, "split-aapl-1", 4m, _none).ConfigureAwait(false));
|
||||
Assert.IsFalse(await rig.Ledger.ApplySplitAsync(alpaca.AccountId, aapl.Id, "split-aapl-1", 4m, _none).ConfigureAwait(false), "Never twice.");
|
||||
// A split whose ex-date came before the purchase changes nothing: those shares were new shares already.
|
||||
Assert.AreEqual(0m, await rig.Ledger.ApplySplitAsync(alpaca.AccountId, aapl.Id, "split-aapl-old", 2m, TradingRig.Start.AddDays(-30), _none).ConfigureAwait(false));
|
||||
Assert.AreEqual(10m, (await rig.Ledger.PositionAsync(alpaca.AccountId, aapl.Id, Strategies.EquityMomentum, _none).ConfigureAwait(false))!.Quantity);
|
||||
Assert.AreEqual(10m, await rig.Ledger.ApplySplitAsync(alpaca.AccountId, aapl.Id, "split-aapl-1", 4m, rig.Clock.UtcNow, _none).ConfigureAwait(false));
|
||||
Assert.IsNull(await rig.Ledger.ApplySplitAsync(alpaca.AccountId, aapl.Id, "split-aapl-1", 4m, rig.Clock.UtcNow, _none).ConfigureAwait(false), "Never twice.");
|
||||
var split = (await rig.Ledger.PositionAsync(alpaca.AccountId, aapl.Id, Strategies.EquityMomentum, _none).ConfigureAwait(false))!;
|
||||
Assert.AreEqual((40m, 50m, 45m), (split.Quantity, split.AveragePrice, split.StopPrice));
|
||||
Assert.AreEqual(40m, (await rig.Ledger.OpenLotsAsync(alpaca.AccountId, aapl.Id, Strategies.EquityMomentum, _none).ConfigureAwait(false)).Sum(l => l.Remaining));
|
||||
|
||||
Reference in new issue
Block a user