opentool 0.8.28 → 0.8.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -109,8 +109,14 @@ function resolveConfig(options) {
109
109
  }
110
110
  async function store(input, options) {
111
111
  const normalizedInput = normalizeStoreInput(input);
112
+ const mode = normalizedInput.mode ?? "live";
112
113
  const eventLevel = normalizedInput.eventLevel;
113
114
  const normalizedAction = normalizeAction(normalizedInput.action);
115
+ if (mode === "backtest" && !normalizedInput.backtestRunId) {
116
+ throw new StoreError(
117
+ `backtestRunId is required when mode is "backtest"`
118
+ );
119
+ }
114
120
  if (eventLevel === "execution" || eventLevel === "lifecycle") {
115
121
  if (!normalizedAction || !EXECUTION_ACTIONS_SET.has(normalizedAction)) {
116
122
  throw new StoreError(
@@ -130,7 +136,8 @@ async function store(input, options) {
130
136
  );
131
137
  }
132
138
  const { baseUrl, apiKey, fetchFn } = resolveConfig(options);
133
- const url = `${baseUrl}/apps/positions/tx`;
139
+ const path = mode === "backtest" ? "/apps/backtests/tx" : "/apps/positions/tx";
140
+ const url = `${baseUrl}${path}`;
134
141
  let response;
135
142
  try {
136
143
  response = await fetchFn(url, {