feat(settings): add settings route and API updates\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
||||
import { enrichExecutionPlan } from "../execution";
|
||||
|
||||
describe("enrichExecutionPlan with Alpaca account data", () => {
|
||||
beforeEach(() => {
|
||||
process.env.DEFAULT_ACCOUNT_EQUITY = "10000";
|
||||
});
|
||||
afterEach(() => {
|
||||
delete process.env.DEFAULT_ACCOUNT_EQUITY;
|
||||
});
|
||||
|
||||
it("uses input.account.cash for sizing when provided", () => {
|
||||
const decision: any = { action: "buy" };
|
||||
const input = { technicalData: { prices: [50, 52, 51] }, account: { cash: 5000 } };
|
||||
|
||||
const out = enrichExecutionPlan(decision, input);
|
||||
|
||||
// entryPrice = 51, ATR ~ 1.5 -> stopDistance = 1.5*1.5 = 2.25
|
||||
// riskAmount = 5000 * 0.01 = 50 -> amount = floor(50 / 2.25) = 22
|
||||
expect(out.executionPlan.amount).toBe(22);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user