MCPcopy Create free account
hub / github.com/discountry/ritmex-bot / parseOrderCommand

Function parseOrderCommand

src/cli/command-parser.ts:207–251  ·  view source on GitHub ↗
(
  action: string,
  options: Record<string, string | boolean>,
  common: CommandCommonOptions & { help?: boolean }
)

Source from the content-addressed store, hash-verified

205}
206
207function parseOrderCommand(
208 action: string,
209 options: Record<string, string | boolean>,
210 common: CommandCommonOptions & { help?: boolean }
211): ParsedCliCommand {
212 if (action === "open") {
213 assertAllowedOptions(options, GLOBAL_OPTION_NAMES);
214 return { kind: "order-open", ...common };
215 }
216 if (action === "cancel") {
217 assertAllowedOptions(options, new Set([...GLOBAL_OPTION_NAMES, "order-id"]));
218 const orderId = requireStringOption(options, ["order-id"], "Missing required option --order-id");
219 return { kind: "order-cancel", orderId, ...common };
220 }
221 if (action === "cancel-all") {
222 assertAllowedOptions(options, GLOBAL_OPTION_NAMES);
223 return { kind: "order-cancel-all", ...common };
224 }
225 if (action === "create") {
226 assertAllowedOptions(
227 options,
228 new Set([
229 ...GLOBAL_OPTION_NAMES,
230 "side",
231 "type",
232 "quantity",
233 "qty",
234 "price",
235 "stop-price",
236 "activation-price",
237 "callback-rate",
238 "time-in-force",
239 "reduce-only",
240 "close-position",
241 "trigger-type",
242 "sl-price",
243 "tp-price",
244 ])
245 );
246
247 const payload = parseOrderCreatePayload(options);
248 return { kind: "order-create", payload, ...common };
249 }
250 throw new CommandParseError(`Unsupported order action '${action}'`);
251}
252
253function parseStrategyCommand(
254 action: string,

Callers 1

parseCommandArgvFunction · 0.85

Calls 3

assertAllowedOptionsFunction · 0.85
requireStringOptionFunction · 0.85
parseOrderCreatePayloadFunction · 0.85

Tested by

no test coverage detected