-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
110 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type BotState = Record<string, any>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { TBotContext } from "@opentrader/bot-processor"; | ||
import { logger } from "@opentrader/logger"; | ||
|
||
export function* testState(ctx: TBotContext<any>) { | ||
const { config: bot, onStart, onStop } = ctx; | ||
|
||
if (onStart) { | ||
logger.info(ctx.state, `[TestState] Bot started`); | ||
|
||
return; | ||
} | ||
if (onStop) { | ||
logger.info(ctx.state, `[TestState] Bot stopped`); | ||
return; | ||
} | ||
|
||
if (ctx.state.counter === undefined) { | ||
ctx.state.counter = 0; | ||
} | ||
|
||
ctx.state.counter += 1; | ||
|
||
logger.info(ctx.state, `[TestState] State is`); | ||
} | ||
|
||
testState.displayName = "Test State"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { z } from "zod"; | ||
|
||
export const ZBotState = z.record(z.any()); | ||
|
||
export type TBotState = z.infer<typeof ZBotState>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { zt } from "@opentrader/prisma"; | ||
import type { z } from "zod"; | ||
import { ZBotSettings } from "./bot-settings.schema"; | ||
import { ZBotState } from "./bot-state.schema"; | ||
|
||
export const ZBot = zt.BotSchema.extend({ | ||
settings: ZBotSettings, | ||
state: ZBotState, | ||
}); | ||
|
||
export type TBot = z.infer<typeof ZBot>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./bot-settings.schema"; | ||
export * from "./bot.schema"; | ||
export * from "./bot-state.schema"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { zt } from "@opentrader/prisma"; | ||
import type { z } from "zod"; | ||
import { ZGridBotSettings } from "./grid-bot-settings.schema"; | ||
import { ZBotState } from "../bot/bot-state.schema"; | ||
|
||
export const ZGridBot = zt.BotSchema.extend({ | ||
settings: ZGridBotSettings, | ||
state: ZBotState, | ||
}); | ||
|
||
export type TGridBot = z.infer<typeof ZGridBot>; |
Oops, something went wrong.