@coinrithm/mcp-trading 0.7.7 → 0.7.8
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/CHANGELOG.md +83 -0
- package/dist/agent/act.js +19 -6
- package/dist/agent/capitalSizing.d.ts +32 -0
- package/dist/agent/capitalSizing.js +257 -0
- package/dist/agent/decision.d.ts +392 -0
- package/dist/agent/decision.js +177 -0
- package/dist/agent/decisionReceipt.d.ts +45 -0
- package/dist/agent/decisionReceipt.js +595 -0
- package/dist/agent/decisionValidator.d.ts +19 -2
- package/dist/agent/decisionValidator.js +74 -3
- package/dist/agent/engine.d.ts +1 -0
- package/dist/agent/engine.js +1 -0
- package/dist/agent/observe.js +175 -34
- package/dist/agent/pmContext.d.ts +13 -0
- package/dist/agent/pmContext.js +136 -0
- package/dist/agent/prompt.d.ts +11 -1
- package/dist/agent/prompt.js +135 -7
- package/dist/agent/providerCapabilities.d.ts +3 -0
- package/dist/agent/providerCapabilities.js +41 -3
- package/dist/agent/providers.js +119 -73
- package/dist/agent/resolve.js +1 -0
- package/dist/agent/runner.d.ts +4 -1
- package/dist/agent/runner.js +360 -34
- package/dist/agent/scorecard.js +7 -1
- package/dist/agent/skill.js +17 -0
- package/dist/agent/skillValidator.d.ts +1 -0
- package/dist/agent/skillValidator.js +56 -0
- package/dist/agent/state.js +6 -0
- package/dist/agent/strictLint.js +19 -0
- package/dist/agent/thesis.d.ts +40 -0
- package/dist/agent/thesis.js +319 -0
- package/dist/agent/types.d.ts +127 -0
- package/package.json +1 -1
package/dist/agent/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IndicatorSet } from "./indicators.js";
|
|
2
|
+
import type { DecisionInputRecord } from "./decisionReceipt.js";
|
|
2
3
|
export declare const SPEC_VERSION = "coinrithm.agent.v1";
|
|
3
4
|
export type Venue = "spot" | "futures" | "pm";
|
|
4
5
|
export declare const VENUES: readonly Venue[];
|
|
@@ -39,6 +40,38 @@ export interface LimitsConfig {
|
|
|
39
40
|
maxDailyLossMusd: number;
|
|
40
41
|
maxOpenMarginMusd: number;
|
|
41
42
|
}
|
|
43
|
+
/** Opt-in paper experiment. Percent fields are percentage POINTS, not fractions. */
|
|
44
|
+
export interface CapitalSizingPolicy {
|
|
45
|
+
version: "equity_fraction_v1";
|
|
46
|
+
futuresRiskPct: number;
|
|
47
|
+
pmMaxLossPct: number;
|
|
48
|
+
perTicketCapitalPct: number;
|
|
49
|
+
totalCapitalPct: number;
|
|
50
|
+
cashReservePct: number;
|
|
51
|
+
minRewardRisk: number;
|
|
52
|
+
}
|
|
53
|
+
export type CapitalBook = {
|
|
54
|
+
status: "unavailable";
|
|
55
|
+
reason: string;
|
|
56
|
+
} | {
|
|
57
|
+
status: "ready";
|
|
58
|
+
walletId: number;
|
|
59
|
+
/** Marked spot + collateral, reduced by known negative position marks.
|
|
60
|
+
* Positive open-position gains are excluded; this is NOT complete MTM. */
|
|
61
|
+
conservativeEquityMusd: number;
|
|
62
|
+
cashAvailableMusd: number;
|
|
63
|
+
committedCapitalMusd: number;
|
|
64
|
+
};
|
|
65
|
+
export interface CapitalSizingAdjustment {
|
|
66
|
+
version: "equity_fraction_v1";
|
|
67
|
+
basis: "owned_collateral_spot_marked_negative_position_marks_only";
|
|
68
|
+
proposedAmountMusd?: number;
|
|
69
|
+
sizedAmountMusd?: number;
|
|
70
|
+
conservativeEquityMusd?: number;
|
|
71
|
+
riskBudgetMusd?: number;
|
|
72
|
+
/** Runner safety estimate, not a claim that the venue charges this fee. */
|
|
73
|
+
feeBufferBps?: number;
|
|
74
|
+
}
|
|
42
75
|
export interface AbstentionConfig {
|
|
43
76
|
onStaleData: boolean;
|
|
44
77
|
onWeakSignal: boolean;
|
|
@@ -72,6 +105,7 @@ export interface AgentSpec {
|
|
|
72
105
|
model?: ModelConfig;
|
|
73
106
|
venues: Venue[];
|
|
74
107
|
risk: RiskConfig;
|
|
108
|
+
capitalSizing?: CapitalSizingPolicy;
|
|
75
109
|
limits: LimitsConfig;
|
|
76
110
|
abstention: AbstentionConfig;
|
|
77
111
|
sync: SyncConfig;
|
|
@@ -95,6 +129,8 @@ export declare const fail: (code: string, reason: string) => ValidationResult;
|
|
|
95
129
|
export interface Freshness {
|
|
96
130
|
status: string;
|
|
97
131
|
ageSeconds?: number;
|
|
132
|
+
asOf?: string;
|
|
133
|
+
basis?: string;
|
|
98
134
|
}
|
|
99
135
|
export interface WatchEntry {
|
|
100
136
|
symbol: string;
|
|
@@ -108,10 +144,25 @@ export interface WatchEntry {
|
|
|
108
144
|
freshness?: Freshness;
|
|
109
145
|
indicators?: IndicatorSet;
|
|
110
146
|
discovered?: boolean;
|
|
147
|
+
slug?: string;
|
|
148
|
+
fundamentals?: CoinFundamentals;
|
|
149
|
+
}
|
|
150
|
+
export interface CoinFundamentals {
|
|
151
|
+
categories?: string[];
|
|
152
|
+
marketCapRank?: number;
|
|
153
|
+
marketCapUsd?: number;
|
|
154
|
+
volume24hUsd?: number;
|
|
155
|
+
headlines?: Array<{
|
|
156
|
+
title: string;
|
|
157
|
+
at?: string;
|
|
158
|
+
importance?: number;
|
|
159
|
+
sentiment?: string;
|
|
160
|
+
}>;
|
|
111
161
|
}
|
|
112
162
|
export interface OpenPosition {
|
|
113
163
|
venue: Venue;
|
|
114
164
|
id: number;
|
|
165
|
+
walletId?: number;
|
|
115
166
|
coinId?: string;
|
|
116
167
|
symbol?: string;
|
|
117
168
|
side?: string;
|
|
@@ -124,6 +175,8 @@ export interface OpenPosition {
|
|
|
124
175
|
liquidationPrice?: number;
|
|
125
176
|
stopLossPrice?: number;
|
|
126
177
|
takeProfitPrice?: number;
|
|
178
|
+
openedAt?: string;
|
|
179
|
+
thesis?: ThesisView;
|
|
127
180
|
}
|
|
128
181
|
export interface SpotOrder {
|
|
129
182
|
id: number;
|
|
@@ -136,12 +189,19 @@ export interface SpotOrder {
|
|
|
136
189
|
}
|
|
137
190
|
export interface PmPosition {
|
|
138
191
|
id: number;
|
|
192
|
+
walletId?: number;
|
|
139
193
|
source?: string;
|
|
140
194
|
slug?: string;
|
|
141
195
|
outcomeExternalMarketId?: string;
|
|
142
196
|
stakeMusd?: number;
|
|
143
197
|
unrealizedPnlMusd?: number;
|
|
144
198
|
status?: string;
|
|
199
|
+
title?: string;
|
|
200
|
+
side?: string;
|
|
201
|
+
entryProbability?: number;
|
|
202
|
+
currentProbability?: number;
|
|
203
|
+
openedAt?: string;
|
|
204
|
+
thesis?: ThesisView;
|
|
145
205
|
}
|
|
146
206
|
export interface PmResolution {
|
|
147
207
|
id: number;
|
|
@@ -162,6 +222,27 @@ export interface PmMarket {
|
|
|
162
222
|
title?: string;
|
|
163
223
|
freshness?: Freshness;
|
|
164
224
|
volumeUsd?: number;
|
|
225
|
+
endDate?: string;
|
|
226
|
+
liquidityUsd?: number;
|
|
227
|
+
quality?: PmQuality;
|
|
228
|
+
decisionSupport?: PmDecisionSupport;
|
|
229
|
+
}
|
|
230
|
+
export interface PmQuality {
|
|
231
|
+
decisionEligible?: boolean;
|
|
232
|
+
warningReasons: string[];
|
|
233
|
+
blockReasons: string[];
|
|
234
|
+
policyVersion?: string;
|
|
235
|
+
assessedAt?: string;
|
|
236
|
+
reasonsOmitted?: boolean;
|
|
237
|
+
}
|
|
238
|
+
export interface PmDecisionSupport {
|
|
239
|
+
qualityScore?: number;
|
|
240
|
+
qualityTier?: string;
|
|
241
|
+
qualityCapReason?: string | null;
|
|
242
|
+
spreadTier?: string;
|
|
243
|
+
liquidityTier?: string;
|
|
244
|
+
volumeTier?: string;
|
|
245
|
+
flags?: Partial<Record<"thinMarket" | "inactiveMarket" | "highAmbiguity" | "nearResolution" | "staleData", boolean>>;
|
|
165
246
|
}
|
|
166
247
|
export interface SetupSignal {
|
|
167
248
|
symbol: string;
|
|
@@ -177,6 +258,7 @@ export interface NewsItem {
|
|
|
177
258
|
sentiment?: string;
|
|
178
259
|
importance?: number;
|
|
179
260
|
ageHours?: number;
|
|
261
|
+
publishedAt?: string;
|
|
180
262
|
coins?: string[];
|
|
181
263
|
}
|
|
182
264
|
export interface Observation {
|
|
@@ -184,6 +266,7 @@ export interface Observation {
|
|
|
184
266
|
scopes: string[];
|
|
185
267
|
cashAvailableMusd: number | null;
|
|
186
268
|
equityMusd: number | null;
|
|
269
|
+
capitalBook?: CapitalBook;
|
|
187
270
|
openPositions: OpenPosition[];
|
|
188
271
|
openOrders: SpotOrder[];
|
|
189
272
|
pmPositions: PmPosition[];
|
|
@@ -206,6 +289,35 @@ export interface Observation {
|
|
|
206
289
|
priceUsd?: number;
|
|
207
290
|
}>;
|
|
208
291
|
}
|
|
292
|
+
export interface ThesisInvalidation {
|
|
293
|
+
priceBelow?: number;
|
|
294
|
+
priceAbove?: number;
|
|
295
|
+
probabilityBelow?: number;
|
|
296
|
+
probabilityAbove?: number;
|
|
297
|
+
maxHoldMinutes?: number;
|
|
298
|
+
catalyst?: string;
|
|
299
|
+
}
|
|
300
|
+
export interface Thesis {
|
|
301
|
+
summary: string;
|
|
302
|
+
invalidation: ThesisInvalidation;
|
|
303
|
+
}
|
|
304
|
+
export interface PositionThesis extends Thesis {
|
|
305
|
+
venue: Venue;
|
|
306
|
+
positionId: number;
|
|
307
|
+
symbol?: string;
|
|
308
|
+
side?: string;
|
|
309
|
+
source?: string;
|
|
310
|
+
slug?: string;
|
|
311
|
+
outcomeExternalMarketId?: string;
|
|
312
|
+
openedAt: string;
|
|
313
|
+
entryPrice?: number;
|
|
314
|
+
entryProbability?: number;
|
|
315
|
+
}
|
|
316
|
+
export interface ThesisView extends Thesis {
|
|
317
|
+
holdMinutes: number;
|
|
318
|
+
status: "intact" | "invalidated";
|
|
319
|
+
invalidatedBy?: string;
|
|
320
|
+
}
|
|
209
321
|
export type ProposedAction = {
|
|
210
322
|
type: "futures_open";
|
|
211
323
|
symbol: string;
|
|
@@ -216,6 +328,7 @@ export type ProposedAction = {
|
|
|
216
328
|
takeProfitPrice?: number | null;
|
|
217
329
|
confidence?: number;
|
|
218
330
|
rationaleSummary?: string;
|
|
331
|
+
thesis?: Thesis;
|
|
219
332
|
} | {
|
|
220
333
|
type: "futures_close";
|
|
221
334
|
positionId: number;
|
|
@@ -237,6 +350,7 @@ export type ProposedAction = {
|
|
|
237
350
|
stopPrice?: number;
|
|
238
351
|
confidence?: number;
|
|
239
352
|
rationaleSummary?: string;
|
|
353
|
+
thesis?: Thesis;
|
|
240
354
|
} | {
|
|
241
355
|
type: "spot_cancel";
|
|
242
356
|
orderId: number;
|
|
@@ -250,6 +364,7 @@ export type ProposedAction = {
|
|
|
250
364
|
confidence?: number;
|
|
251
365
|
rationaleSummary?: string;
|
|
252
366
|
forecastProbability?: number;
|
|
367
|
+
thesis?: Thesis;
|
|
253
368
|
};
|
|
254
369
|
export type ActionVenue = Venue;
|
|
255
370
|
export declare function actionVenue(a: ProposedAction): ActionVenue;
|
|
@@ -273,7 +388,14 @@ export interface QuoteEvidence {
|
|
|
273
388
|
entryPrice?: number;
|
|
274
389
|
liquidationPrice?: number;
|
|
275
390
|
executionPrice?: number;
|
|
391
|
+
entryProbability?: number;
|
|
392
|
+
stakeMusd?: number;
|
|
393
|
+
sharesEstimate?: number;
|
|
276
394
|
estimatedCostMusd?: number;
|
|
395
|
+
estimatedFeeMusd?: number;
|
|
396
|
+
futuresFeeBps?: number;
|
|
397
|
+
estimatedEntryFeeMusd?: number;
|
|
398
|
+
cashRequiredMusd?: number;
|
|
277
399
|
freshness?: Freshness;
|
|
278
400
|
openBlocked?: boolean;
|
|
279
401
|
openBlockReasons?: unknown;
|
|
@@ -282,6 +404,7 @@ export interface RunState {
|
|
|
282
404
|
runId: string;
|
|
283
405
|
cyclesRun: number;
|
|
284
406
|
writesToday: number;
|
|
407
|
+
riskIncreasesToday: number;
|
|
285
408
|
realizedPnlMusd: number;
|
|
286
409
|
peakRealizedMusd: number;
|
|
287
410
|
consecutiveRejectCycles: number;
|
|
@@ -304,6 +427,7 @@ export interface RunState {
|
|
|
304
427
|
at: string;
|
|
305
428
|
did: string;
|
|
306
429
|
}>;
|
|
430
|
+
theses?: Record<string, PositionThesis>;
|
|
307
431
|
}
|
|
308
432
|
export interface AgentTrace {
|
|
309
433
|
runId?: string;
|
|
@@ -330,8 +454,11 @@ export interface PlannedAction {
|
|
|
330
454
|
quote?: QuoteEvidence;
|
|
331
455
|
executed?: boolean;
|
|
332
456
|
result?: unknown;
|
|
457
|
+
capitalSizing?: CapitalSizingAdjustment;
|
|
333
458
|
}
|
|
334
459
|
export interface CycleResult {
|
|
460
|
+
/** Private non-enumerable evidence. Never forward through AgentTrace/public APIs. */
|
|
461
|
+
decisionInputRecord?: DecisionInputRecord;
|
|
335
462
|
decision: "skip" | "act";
|
|
336
463
|
skipReason?: string;
|
|
337
464
|
rationale?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinrithm/mcp-trading",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.8",
|
|
4
4
|
"mcpName": "io.github.CoinRithm/mcp-trading",
|
|
5
5
|
"description": "CoinRithm paper-trading toolkit: an MCP server (coinrithm-mcp) AND a self-host agent runner (coinrithm-agent) for spot, futures, and prediction markets with a user-minted API key.",
|
|
6
6
|
"type": "module",
|