Skip to content

Commit

Permalink
refactor(strategies): rename gridBotLite to grid
Browse files Browse the repository at this point in the history
  • Loading branch information
bludnic committed May 24, 2024
1 parent 1f74f31 commit 3cef5da
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 5 additions & 1 deletion packages/bot-templates/src/templates/grid-bot.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from "zod";
import type { IExchange } from "@opentrader/exchanges";
import {
import type {
IBotConfiguration,
SmartTradeService,
TBotContext,
Expand All @@ -14,6 +14,10 @@ import { computeGridLevelsFromCurrentAssetPrice } from "@opentrader/tools";
import type { IGetMarketPriceResponse } from "@opentrader/types";
import { logger } from "@opentrader/logger";

/**
* Advanced grid bot template.
* The template allows specifying grid lines with custom prices and quantities.
*/
export function* gridBot(ctx: TBotContext<GridBotConfig>) {
const { config: bot, onStart, onStop } = ctx;
const symbol = `${bot.baseCurrency}/${bot.quoteCurrency}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { gridBot } from "./grid-bot";
* Wrapper for the `gridBot` template with a simplified configuration.
* @param ctx - Bot context
*/
export function* gridBotLite(ctx: TBotContext<GridBotLiteConfig>) {
export function* grid(ctx: TBotContext<GridBotLiteConfig>) {
const { config } = ctx;

const gridLines = calcGridLines(
Expand All @@ -32,8 +32,8 @@ export function* gridBotLite(ctx: TBotContext<GridBotLiteConfig>) {
yield* gridBot(gridBotCtx);
}

gridBotLite.displayName = "Grid Bot Lite";
gridBotLite.schema = z.object({
grid.displayName = "Grid Bot Lite";
grid.schema = z.object({
highPrice: z.number().positive().describe("Highest price of the grid"),
lowPrice: z.number().positive().describe("Lowest price of the grid"),
gridLevels: z.number().positive().describe("Number of grid lines"),
Expand All @@ -43,6 +43,4 @@ gridBotLite.schema = z.object({
.describe("Quantity of base currency per each grid"),
});

export type GridBotLiteConfig = IBotConfiguration<
z.infer<typeof gridBotLite.schema>
>;
export type GridBotLiteConfig = IBotConfiguration<z.infer<typeof grid.schema>>;
2 changes: 1 addition & 1 deletion packages/bot-templates/src/templates/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from "./grid-bot";
export * from "./grid-bot-lite";
export * from "./grid";
export * from "./rsi";
export * from "./test";

0 comments on commit 3cef5da

Please sign in to comment.