Skip to content

Commit

Permalink
Merge pull request #97 from Open-Trader/feat/strategies-meta
Browse files Browse the repository at this point in the history
Add `description` property to the strategy template
  • Loading branch information
bludnic authored Jan 12, 2025
2 parents 8ab088f + 4914229 commit 0070c37
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/bot-processor/src/types/bot/bot-template.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export interface BotTemplate<T extends IBotConfiguration> {
* Display name of the bot. Used in the UI.
*/
displayName?: string;
/**
* Strategy description. What does the strategy do?
*/
description?: string;
/**
* Number of candles the strategy requires for warm-up.
* When the bot starts, it will download the required number of candles.
Expand Down
2 changes: 2 additions & 0 deletions packages/bot-templates/src/templates/dca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export function* dca(ctx: TBotContext<DCABotConfig>) {
}

dca.displayName = "DCA Bot";
dca.description =
"Dollar-Cost Averaging (DCA) is a trading strategy that involves entering a position through multiple smaller orders, known as Safety Orders. These orders are placed at predetermined levels, below the initial entry price. This method helps reduce the impact of adverse price movements by lowering the overall cost of the position. Once the market reverses and the price reaches a favorable level, the position is closed at the Take Profit level. This strategy is especially effective in volatile markets, allowing traders to capitalize on price fluctuations while minimizing the risks of poor timing with a single large entry.";
dca.hidden = true;
dca.schema = z.object({
entry: z.object({
Expand Down
2 changes: 1 addition & 1 deletion packages/bot-templates/src/templates/grid-bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function* gridBot(ctx: TBotContext<GridBotConfig>) {
}
}

gridBot.displayName = "Grid Bot";
gridBot.displayName = "Grid Bot Advanced";
gridBot.hidden = true;
gridBot.schema = z.object({
gridLines: z.array(
Expand Down
4 changes: 3 additions & 1 deletion packages/bot-templates/src/templates/grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export function* grid(ctx: TBotContext<GridBotLiteConfig>) {
yield* gridBot(gridBotCtx);
}

grid.displayName = "Grid Bot Lite";
grid.displayName = "Grid Bot";
grid.description =
"A grid trading strategy is a market-neutral approach that works by placing a series of buy and sell orders at predetermined intervals above and below the current price. It capitalizes on market volatility, aiming to profit from price fluctuations rather than predicting market direction.";
grid.hidden = true;
grid.schema = z.object({
highPrice: z.number().positive().describe("Highest price of the grid"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ type Options = {
};

type StrategyName = keyof typeof templates | string;
type StrategyInfo = { schema: JsonSchema7Type; isCustom: boolean } & Pick<
type StrategyInfo = { name: string; schema: JsonSchema7Type; isCustom: boolean } & Pick<
BotTemplate<any>,
"displayName" | "hidden" | "runPolicy" | "watchers" | "requiredHistory"
"displayName" | "description" | "hidden" | "runPolicy" | "watchers" | "requiredHistory"
>;

// Helper function to check if the schema is a ZodObject
Expand All @@ -37,9 +37,11 @@ export async function getStrategies({ ctx }: Options) {
const zodSchema = isZodObject(strategy.schema) ? strategy.schema : z.object({});

result[strategyName] = {
name: strategyName,
schema: zodToJsonSchema(zodSchema),
isCustom: strategyName in customStrategies,
displayName: strategy.displayName,
description: strategy.description,
hidden: !!strategy.hidden,
runPolicy: strategy.runPolicy,
watchers: strategy.watchers,
Expand Down

0 comments on commit 0070c37

Please sign in to comment.