@thoshpathi/utils-smartapi-order
Version:
Utility functions for placing live and dummy orders using Angel One's SmartAPI, with helper methods for streamlined trading workflows.
21 lines (19 loc) • 532 B
JavaScript
// src/utils.ts
import { generateUniqueString } from "@thoshpathi/utils-core";
function generateOrderId(length = 20, prefix = "O_") {
const id = generateUniqueString(length);
return `${prefix}_${id}`.substring(0, length);
}
function toggleTrend(trend) {
if (trend !== "BUY" && trend !== "SELL")
throw new Error("Invalid trend value");
return trend === "BUY" ? "SELL" : "BUY";
}
function delay(ms = 0) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
export {
generateOrderId,
toggleTrend,
delay
};