repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; |
| #2 | import { dirname, join } from "node:path"; |
| #3 | import { fileURLToPath } from "node:url"; |
| #4 | import type { Candle } from "./state.js"; |
| #5 | import type { Decision } from "./validate.js"; |
| #6 | |
| #7 | const __dirname = dirname(fileURLToPath(import.meta.url)); |
| #8 | const JOURNAL_PATH = join(__dirname, "journal", "ticks.jsonl"); |
| #9 | |
| #10 | export interface TickEntry { |
| #11 | tick: number; |
| #12 | now: string; |
| #13 | candles_last3: Candle[]; |
| #14 | whale_activity?: unknown; |
| #15 | book_snapshot: unknown; |
| #16 | decision: Decision; |
| #17 | outcome: "applied" | "rejected" | "killswitch"; |
| #18 | violation?: string; |
| #19 | pnl_lamports?: number; |
| #20 | total_pnl_lamports?: number; |
| #21 | consecutive_losses?: number; |
| #22 | event?: string; |
| #23 | molt_note?: string; |
| #24 | } |
| #25 | |
| #26 | export function appendTick(entry: TickEntry): void { |
| #27 | mkdirSync(dirname(JOURNAL_PATH), { recursive: true }); |
| #28 | appendFileSync(JOURNAL_PATH, `${JSON.stringify(entry)}\n`, "utf8"); |
| #29 | } |
| #30 | |
| #31 | export function readLastEntries(n = 3): TickEntry[] { |
| #32 | if (!existsSync(JOURNAL_PATH)) return []; |
| #33 | return readFileSync(JOURNAL_PATH, "utf8") |
| #34 | .split("\n") |
| #35 | .filter(Boolean) |
| #36 | .slice(-n) |
| #37 | .map((line) => JSON.parse(line) as TickEntry); |
| #38 | } |
| #39 | |
| #40 | export function clearJournal(): void { |
| #41 | mkdirSync(dirname(JOURNAL_PATH), { recursive: true }); |
| #42 | writeFileSync(JOURNAL_PATH, "", "utf8"); |
| #43 | } |
| #44 | |
| #45 | export function journalPath(): string { |
| #46 | return JOURNAL_PATH; |
| #47 | } |
| #48 | |
| #49 |