(
action: string,
options: Record<string, string | boolean>,
common: CommandCommonOptions & { help?: boolean }
)
| 205 | } |
| 206 | |
| 207 | function 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 | |
| 253 | function parseStrategyCommand( |
| 254 | action: string, |
no test coverage detected