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
@@ -111,9 +111,16 @@ public sealed class OrderManagerTests
|
||||
await s.Rig.TurnsAsync(s.Manager, 2, _minute).ConfigureAwait(false);
|
||||
var held = (await s.Rig.Ledger.PositionAsync(s.Account.AccountId, s.Instrument.Id, Strategies.CryptoTrend, _none).ConfigureAwait(false))!.Quantity;
|
||||
|
||||
// No price at all: the sale waits, and the stops stay on the broker until it can really leave.
|
||||
s.Rig.QuotesDown = true;
|
||||
var (execution, _) = await s.Manager.SubmitAsync(Sell(s, held), _none).ConfigureAwait(false);
|
||||
await s.Rig.TurnsAsync(s.Manager, 3, _minute).ConfigureAwait(false);
|
||||
Assert.AreEqual("working/", await ExecutionStatusAsync(s.Rig, execution!.Value).ConfigureAwait(false));
|
||||
Assert.IsTrue((await OrdersAsync(s.Rig).ConfigureAwait(false)).Any(o => o.Purpose == "stop" && o.Status == "submitted"), "Without a price the stops stay.");
|
||||
s.Rig.QuotesDown = false;
|
||||
|
||||
// Nobody buys near the price: the sale keeps going with a fresh reference and double tolerance.
|
||||
s.Rig.Quote("BTC-EUR", 50000m, 60000m);
|
||||
var (execution, _) = await s.Manager.SubmitAsync(Sell(s, held), _none).ConfigureAwait(false);
|
||||
await s.Rig.TurnsAsync(s.Manager, 12, _minute).ConfigureAwait(false);
|
||||
Assert.AreEqual("working/", await ExecutionStatusAsync(s.Rig, execution!.Value).ConfigureAwait(false));
|
||||
var tolerance = (await s.Rig.QueryAsync("SELECT tolerance FROM executions WHERE id = @id", r => r.Money("tolerance"), ("id", execution)).ConfigureAwait(false)).Single();
|
||||
@@ -239,11 +246,11 @@ public sealed class OrderManagerTests
|
||||
{
|
||||
var first = !applied;
|
||||
applied = true;
|
||||
return Task.FromResult(first ? new CorporateAction(instrument.Symbol, CorporateActionKinds.Split, new DateOnly(2026, 11, 10), "test", "split-msft") { Ratio = 4m } : null);
|
||||
return Task.FromResult(first ? new CorporateAction(instrument.Symbol, CorporateActionKinds.Split, new DateOnly(2026, 11, 11), "test", "split-msft") { Ratio = 4m } : null);
|
||||
}).ConfigureAwait(false);
|
||||
await a.Manager.SubmitAsync(Buy(a, 10m, aggressive: true, strategy: Strategies.EquityMomentum), _none).ConfigureAwait(false);
|
||||
await a.Rig.TurnsAsync(a.Manager, 2, _minute).ConfigureAwait(false);
|
||||
await a.Paper.ApplySplitAsync("MSFT", 4m, _none).ConfigureAwait(false);
|
||||
a.Rig.Clock.Advance(TimeSpan.FromDays(1));
|
||||
a.Rig.Quote("MSFT", 100m, 100.05m);
|
||||
await a.Rig.Ledger.SetStopAsync(a.Account.AccountId, a.Instrument.Id, Strategies.EquityMomentum, 380m, _none).ConfigureAwait(false);
|
||||
await a.Rig.TurnsAsync(a.Manager, 2, _minute).ConfigureAwait(false);
|
||||
@@ -254,6 +261,7 @@ public sealed class OrderManagerTests
|
||||
Assert.IsFalse((await OrdersAsync(a.Rig).ConfigureAwait(false)).Any(o => o.Purpose == "protective"));
|
||||
var stop = (await OrdersAsync(a.Rig).ConfigureAwait(false)).Single(o => o.Purpose == "stop" && o.Status == "submitted");
|
||||
Assert.AreEqual((40m, 95m), (stop.Quantity, stop.Stop));
|
||||
Assert.AreEqual(40m, (await a.Paper.GetPositionsAsync(_none).ConfigureAwait(false)).Single().Quantity, "The simulator's book follows the same split.");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
Reference in new issue
Block a user