@openfinclaw/openfinclaw-strategy 2026.4.2 → 2026.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfinclaw/openfinclaw-strategy",
3
- "version": "2026.4.2",
3
+ "version": "2026.4.10",
4
4
  "description": "OpenFinClaw - Unified financial tools: market data (price/K-line/crypto/compare/search), strategy publishing, fork, and validation. Single API key for Hub and DataHub.",
5
5
  "keywords": [
6
6
  "backtest",
@@ -23,6 +23,9 @@ import type { AggregatedNewsProvider } from "./news-provider.js";
23
23
  import { formatPeriodicReportMarkdown } from "./periodic-report-builder.js";
24
24
  import { buildScanReport, formatScanReportMarkdown } from "./scan-report-builder.js";
25
25
 
26
+ const NO_API_KEY =
27
+ "API key not configured. Set apiKey in plugin config or OPENFINCLAW_API_KEY env var.";
28
+
26
29
  /** JSON tool result helper. */
27
30
  function json(payload: unknown) {
28
31
  return {
@@ -421,6 +424,7 @@ export function registerSchedulerTools(
421
424
  "strategy_scan_history",
422
425
  "scheduler",
423
426
  async (_toolCallId, params) => {
427
+ if (!config.apiKey) return json({ success: false, error: NO_API_KEY });
424
428
  try {
425
429
  const db = getDb();
426
430
  const entries = queryScanHistory(db, {
@@ -489,6 +493,7 @@ export function registerSchedulerTools(
489
493
  "strategy_periodic_report",
490
494
  "scheduler",
491
495
  async (_toolCallId, params) => {
496
+ if (!config.apiKey) return json({ success: false, error: NO_API_KEY });
492
497
  const period = params.period === "monthly" ? "monthly" : "weekly";
493
498
  const scanId = randomUUID();
494
499
  const now = new Date();
@@ -21,7 +21,9 @@ export async function hubApiRequest(
21
21
  }
22
22
 
23
23
  const headers: Record<string, string> = { "Content-Type": "application/json" };
24
- if (config.apiKey) headers["Authorization"] = `Bearer ${config.apiKey}`;
24
+ if (config.apiKey) {
25
+ headers["Authorization"] = `Bearer ${config.apiKey}`;
26
+ }
25
27
 
26
28
  const response = await fetch(url.toString(), {
27
29
  method,
@@ -346,6 +346,7 @@ export function registerStrategyTools(
346
346
  }),
347
347
  }),
348
348
  execute: withLogging(getDb, "skill_validate", "strategy", async (_toolCallId, params) => {
349
+ if (!config.apiKey) return json({ success: false, error: NO_API_KEY });
349
350
  try {
350
351
  const dirPath = String(params.dirPath ?? "").trim();
351
352
  if (!dirPath)
@@ -375,7 +376,7 @@ export function registerStrategyTools(
375
376
  {
376
377
  name: "skill_leaderboard",
377
378
  label: "Get Hub leaderboard",
378
- description: "Query strategy leaderboard from hub.openfinclaw.ai. No API key required.",
379
+ description: "Query strategy leaderboard from hub.openfinclaw.ai.",
379
380
  parameters: Type.Object({
380
381
  boardType: Type.Optional(
381
382
  Type.Unsafe<BoardType>({
@@ -390,6 +391,7 @@ export function registerStrategyTools(
390
391
  offset: Type.Optional(Type.Number({ description: "Offset for pagination" })),
391
392
  }),
392
393
  execute: withLogging(getDb, "skill_leaderboard", "strategy", async (_toolCallId, params) => {
394
+ if (!config.apiKey) return json({ success: false, error: NO_API_KEY });
393
395
  try {
394
396
  const boardType = (params.boardType as BoardType) || "composite";
395
397
  const limit = Math.min(Math.max(Number(params.limit) || 20, 1), 100);
@@ -401,7 +403,7 @@ export function registerStrategyTools(
401
403
 
402
404
  const response = await fetch(url.toString(), {
403
405
  method: "GET",
404
- headers: { Accept: "application/json" },
406
+ headers: { Accept: "application/json", Authorization: `Bearer ${config.apiKey}` },
405
407
  signal: AbortSignal.timeout(config.requestTimeoutMs),
406
408
  });
407
409
 
@@ -573,6 +575,7 @@ export function registerStrategyTools(
573
575
  description: "List all strategies downloaded or created locally, organized by date.",
574
576
  parameters: Type.Object({}),
575
577
  execute: withLogging(getDb, "skill_list_local", "strategy", async () => {
578
+ if (!config.apiKey) return json({ success: false, error: NO_API_KEY });
576
579
  try {
577
580
  const strategies = await listLocalStrategies();
578
581
 
@@ -622,7 +625,7 @@ export function registerStrategyTools(
622
625
  name: "skill_get_info",
623
626
  label: "Get strategy info from Hub",
624
627
  description:
625
- "Fetch detailed information about a strategy from hub.openfinclaw.ai. No API key required.",
628
+ "Fetch detailed information about a strategy from hub.openfinclaw.ai.",
626
629
  parameters: Type.Object({
627
630
  strategyId: Type.String({ description: "Strategy ID from Hub (UUID or Hub URL)" }),
628
631
  }),
@@ -631,6 +634,7 @@ export function registerStrategyTools(
631
634
  "skill_get_info",
632
635
  "strategy",
633
636
  async (_toolCallId, params) => {
637
+ if (!config.apiKey) return json({ success: false, error: NO_API_KEY });
634
638
  try {
635
639
  const strategyId = String(params.strategyId ?? "").trim();
636
640
  if (!strategyId) return json({ success: false, error: "strategyId is required" });