@farazirfan/costar-server-executor 1.7.25 → 1.7.27
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/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -3
- package/dist/server.js.map +1 -1
- package/dist/services/saxo-auth.d.ts +71 -0
- package/dist/services/saxo-auth.d.ts.map +1 -0
- package/dist/services/saxo-auth.js +201 -0
- package/dist/services/saxo-auth.js.map +1 -0
- package/dist/skills/sync.d.ts +13 -11
- package/dist/skills/sync.d.ts.map +1 -1
- package/dist/skills/sync.js +130 -27
- package/dist/skills/sync.js.map +1 -1
- package/dist/web-server.d.ts.map +1 -1
- package/dist/web-server.js +71 -0
- package/dist/web-server.js.map +1 -1
- package/package.json +1 -1
- package/public/index.html +165 -0
- package/skills/coinbase/LEARNING.md +9 -85
- package/skills/coinbase/SKILL.md +53 -76
- package/skills/saxo/LEARNING.md +42 -0
- package/skills/saxo/SKILL.md +235 -0
- package/skills/saxo/references/api-reference.md +332 -0
- package/skills/saxo/references/asset-classes.md +249 -0
- package/skills/saxo/references/auth.md +209 -0
- package/skills/saxo/references/order-types.md +260 -0
- package/skills/saxo/scripts/saxo-trade.py +314 -0
- package/skills/trading/LEARNING.md +15 -127
- package/skills/trading/SKILL.md +140 -178
- package/skills/trading/references/crypto.md +13 -62
- package/skills/trading/references/forex.md +13 -63
- package/skills/trading/references/metals.md +13 -42
- package/skills/trading/references/risk-management.md +23 -51
- package/skills/trading/references/stocks.md +13 -62
- package/skills/trading/references/strategies.md +20 -85
package/public/index.html
CHANGED
|
@@ -1009,6 +1009,9 @@
|
|
|
1009
1009
|
<span class="icon">⚡</span> Skills
|
|
1010
1010
|
<span class="badge" id="skills-badge">0</span>
|
|
1011
1011
|
</button>
|
|
1012
|
+
<button class="nav-item" data-page="integrations" onclick="navigate('integrations')">
|
|
1013
|
+
<span class="icon">🔗</span> Integrations
|
|
1014
|
+
</button>
|
|
1012
1015
|
<button class="nav-item" data-page="workspace" onclick="navigate('workspace')">
|
|
1013
1016
|
<span class="icon">📄</span> Workspace
|
|
1014
1017
|
</button>
|
|
@@ -1199,6 +1202,82 @@
|
|
|
1199
1202
|
</div>
|
|
1200
1203
|
</div>
|
|
1201
1204
|
|
|
1205
|
+
<!-- ═══ Integrations Page ═══ -->
|
|
1206
|
+
<div class="page" id="page-integrations">
|
|
1207
|
+
<div class="card">
|
|
1208
|
+
<div class="card-header">
|
|
1209
|
+
<h3>🔌 Trading Platforms</h3>
|
|
1210
|
+
<p style="font-size:13px;color:var(--text-secondary);margin-top:8px;">Connect your trading accounts for autonomous execution across crypto, forex, stocks, and metals.</p>
|
|
1211
|
+
</div>
|
|
1212
|
+
|
|
1213
|
+
<!-- Saxo Bank Integration -->
|
|
1214
|
+
<div class="integration-item" style="padding:20px;border-bottom:1px solid var(--border);">
|
|
1215
|
+
<div style="display:flex;align-items:start;justify-content:space-between;">
|
|
1216
|
+
<div style="flex:1;">
|
|
1217
|
+
<div style="display:flex;align-items:center;gap:12px;margin-bottom:8px;">
|
|
1218
|
+
<div style="width:48px;height:48px;background:linear-gradient(135deg,#002855,#0047AB);border-radius:8px;display:flex;align-items:center;justify-content:center;color:white;font-weight:700;font-size:18px;">S</div>
|
|
1219
|
+
<div>
|
|
1220
|
+
<h4 style="font-size:16px;font-weight:600;margin-bottom:4px;">Saxo Bank OpenAPI</h4>
|
|
1221
|
+
<div style="font-size:12px;color:var(--text-secondary);">
|
|
1222
|
+
<span id="saxo-status-text">Not connected</span>
|
|
1223
|
+
<span id="saxo-env-badge" style="display:none;margin-left:8px;padding:2px 8px;background:var(--blue-dim);color:var(--blue);border-radius:4px;font-size:11px;"></span>
|
|
1224
|
+
</div>
|
|
1225
|
+
</div>
|
|
1226
|
+
</div>
|
|
1227
|
+
<p style="font-size:13px;color:var(--text-secondary);margin-bottom:12px;">Trade forex, stocks, gold, silver, and 71,000+ instruments globally.</p>
|
|
1228
|
+
|
|
1229
|
+
<!-- Demo Token Section -->
|
|
1230
|
+
<div id="saxo-demo-section" style="margin-top:12px;">
|
|
1231
|
+
<div style="font-size:12px;font-weight:600;color:var(--text-primary);margin-bottom:8px;">Quick Start: Demo Token (24-hour validity)</div>
|
|
1232
|
+
<div style="display:flex;gap:8px;">
|
|
1233
|
+
<input type="text" id="saxo-demo-token" placeholder="Paste 24-hour demo token from developer.saxo" style="flex:1;padding:8px 12px;background:var(--bg-secondary);border:1px solid var(--border);border-radius:var(--radius);color:var(--text-primary);font-size:13px;" />
|
|
1234
|
+
<button class="btn btn-sm btn-primary" onclick="connectSaxoDemo()">Connect</button>
|
|
1235
|
+
</div>
|
|
1236
|
+
<div style="font-size:11px;color:var(--text-muted);margin-top:6px;">Get token: <a href="https://www.developer.saxo/openapi/appmanagement" target="_blank" style="color:var(--accent);">developer.saxo/openapi/appmanagement</a></div>
|
|
1237
|
+
</div>
|
|
1238
|
+
|
|
1239
|
+
<!-- OAuth Section (TODO) -->
|
|
1240
|
+
<div id="saxo-oauth-section" style="display:none;margin-top:16px;padding-top:16px;border-top:1px solid var(--border);">
|
|
1241
|
+
<div style="font-size:12px;font-weight:600;color:var(--text-primary);margin-bottom:8px;">Live Trading: Full OAuth</div>
|
|
1242
|
+
<button class="btn btn-sm" onclick="connectSaxoOAuth()">Connect via OAuth</button>
|
|
1243
|
+
<div style="font-size:11px;color:var(--text-muted);margin-top:6px;">Auto-refreshing tokens, 20-minute validity</div>
|
|
1244
|
+
</div>
|
|
1245
|
+
</div>
|
|
1246
|
+
|
|
1247
|
+
<div style="display:flex;gap:8px;" id="saxo-actions">
|
|
1248
|
+
<button class="btn btn-sm" onclick="checkSaxoStatus()" style="display:none;" id="saxo-refresh-btn">Refresh</button>
|
|
1249
|
+
<button class="btn btn-sm" onclick="disconnectSaxo()" style="display:none;" id="saxo-disconnect-btn">Disconnect</button>
|
|
1250
|
+
</div>
|
|
1251
|
+
</div>
|
|
1252
|
+
</div>
|
|
1253
|
+
|
|
1254
|
+
<!-- Coinbase Integration (Already configured via ENV) -->
|
|
1255
|
+
<div class="integration-item" style="padding:20px;border-bottom:1px solid var(--border);">
|
|
1256
|
+
<div style="display:flex;align-items:start;justify-content:space-between;">
|
|
1257
|
+
<div style="flex:1;">
|
|
1258
|
+
<div style="display:flex;align-items:center;gap:12px;margin-bottom:8px;">
|
|
1259
|
+
<div style="width:48px;height:48px;background:linear-gradient(135deg,#0052FF,#2C72FF);border-radius:8px;display:flex;align-items:center;justify-content:center;color:white;font-weight:700;font-size:18px;">₿</div>
|
|
1260
|
+
<div>
|
|
1261
|
+
<h4 style="font-size:16px;font-weight:600;margin-bottom:4px;">Coinbase Advanced Trade</h4>
|
|
1262
|
+
<div style="font-size:12px;color:var(--text-secondary);">Configure via Environment Variables</div>
|
|
1263
|
+
</div>
|
|
1264
|
+
</div>
|
|
1265
|
+
<p style="font-size:13px;color:var(--text-secondary);margin-bottom:12px;">Trade crypto (BTC, ETH, SOL, etc.) with API keys.</p>
|
|
1266
|
+
<div style="font-size:11px;color:var(--text-muted);">
|
|
1267
|
+
Required: <code style="background:var(--bg-secondary);padding:2px 6px;border-radius:4px;font-family:var(--mono);">COINBASE_API_KEY</code> and <code style="background:var(--bg-secondary);padding:2px 6px;border-radius:4px;font-family:var(--mono);">COINBASE_API_SECRET</code><br>
|
|
1268
|
+
<a href="#" onclick="navigate('settings');return false;" style="color:var(--accent);margin-top:4px;display:inline-block;">→ Add in Settings</a>
|
|
1269
|
+
</div>
|
|
1270
|
+
</div>
|
|
1271
|
+
</div>
|
|
1272
|
+
</div>
|
|
1273
|
+
|
|
1274
|
+
<!-- Future Integrations Placeholder -->
|
|
1275
|
+
<div style="padding:20px;text-align:center;color:var(--text-muted);font-size:13px;">
|
|
1276
|
+
More integrations coming soon: IBKR, Alpaca, OANDA, etc.
|
|
1277
|
+
</div>
|
|
1278
|
+
</div>
|
|
1279
|
+
</div>
|
|
1280
|
+
|
|
1202
1281
|
<!-- ═══ Settings Page ═══ -->
|
|
1203
1282
|
<div class="page" id="page-settings">
|
|
1204
1283
|
<div class="card">
|
|
@@ -1344,6 +1423,7 @@
|
|
|
1344
1423
|
chat: 'Chat',
|
|
1345
1424
|
cron: 'Cron Jobs',
|
|
1346
1425
|
skills: 'Skills',
|
|
1426
|
+
integrations: 'Integrations',
|
|
1347
1427
|
workspace: 'Workspace',
|
|
1348
1428
|
logs: 'Logs',
|
|
1349
1429
|
settings: 'Settings',
|
|
@@ -1356,6 +1436,7 @@
|
|
|
1356
1436
|
case 'chat': initChat(); break;
|
|
1357
1437
|
case 'cron': loadCronJobs(); loadCronStatus(); break;
|
|
1358
1438
|
case 'skills': loadSkills(); break;
|
|
1439
|
+
case 'integrations': checkSaxoStatus(); break;
|
|
1359
1440
|
case 'workspace': loadWorkspaceFiles(); break;
|
|
1360
1441
|
case 'logs': loadLogs(); startLogStream(); break;
|
|
1361
1442
|
case 'settings': loadSettings(); break;
|
|
@@ -2506,6 +2587,90 @@
|
|
|
2506
2587
|
document.querySelectorAll('.modal-overlay.open').forEach(m => m.classList.remove('open'));
|
|
2507
2588
|
}
|
|
2508
2589
|
});
|
|
2590
|
+
|
|
2591
|
+
// ─── Saxo Integration Functions ────────────────────────
|
|
2592
|
+
|
|
2593
|
+
async function checkSaxoStatus() {
|
|
2594
|
+
try {
|
|
2595
|
+
const data = await api('/api/integrations/saxo/status');
|
|
2596
|
+
updateSaxoUI(data);
|
|
2597
|
+
} catch (err) {
|
|
2598
|
+
console.error('Failed to check Saxo status:', err);
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
|
|
2602
|
+
function updateSaxoUI(status) {
|
|
2603
|
+
const statusText = document.getElementById('saxo-status-text');
|
|
2604
|
+
const envBadge = document.getElementById('saxo-env-badge');
|
|
2605
|
+
const refreshBtn = document.getElementById('saxo-refresh-btn');
|
|
2606
|
+
const disconnectBtn = document.getElementById('saxo-disconnect-btn');
|
|
2607
|
+
const demoSection = document.getElementById('saxo-demo-section');
|
|
2608
|
+
|
|
2609
|
+
if (status.connected) {
|
|
2610
|
+
statusText.textContent = '✓ Connected';
|
|
2611
|
+
statusText.style.color = 'var(--green)';
|
|
2612
|
+
envBadge.textContent = status.environment || 'simulation';
|
|
2613
|
+
envBadge.style.display = 'inline-block';
|
|
2614
|
+
refreshBtn.style.display = 'inline-block';
|
|
2615
|
+
disconnectBtn.style.display = 'inline-block';
|
|
2616
|
+
demoSection.style.display = 'none';
|
|
2617
|
+
|
|
2618
|
+
if (status.expiresAt) {
|
|
2619
|
+
const expiresIn = Math.floor((status.expiresAt - Date.now()) / 1000 / 60);
|
|
2620
|
+
if (expiresIn < 60) {
|
|
2621
|
+
statusText.textContent = `✓ Connected (expires in ${expiresIn}m)`;
|
|
2622
|
+
}
|
|
2623
|
+
}
|
|
2624
|
+
} else {
|
|
2625
|
+
statusText.textContent = 'Not connected';
|
|
2626
|
+
statusText.style.color = 'var(--text-secondary)';
|
|
2627
|
+
envBadge.style.display = 'none';
|
|
2628
|
+
refreshBtn.style.display = 'none';
|
|
2629
|
+
disconnectBtn.style.display = 'none';
|
|
2630
|
+
demoSection.style.display = 'block';
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
|
|
2634
|
+
async function connectSaxoDemo() {
|
|
2635
|
+
const token = document.getElementById('saxo-demo-token').value.trim();
|
|
2636
|
+
if (!token) {
|
|
2637
|
+
alert('Please paste your 24-hour demo token');
|
|
2638
|
+
return;
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
try {
|
|
2642
|
+
await api('/api/integrations/saxo/connect/demo', {
|
|
2643
|
+
method: 'POST',
|
|
2644
|
+
body: JSON.stringify({ token }),
|
|
2645
|
+
});
|
|
2646
|
+
alert('✓ Saxo demo token saved! Valid for 24 hours.');
|
|
2647
|
+
document.getElementById('saxo-demo-token').value = '';
|
|
2648
|
+
checkSaxoStatus();
|
|
2649
|
+
} catch (err) {
|
|
2650
|
+
alert('Failed to save token: ' + err.message);
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
|
|
2654
|
+
async function connectSaxoOAuth() {
|
|
2655
|
+
try {
|
|
2656
|
+
const data = await api('/api/integrations/saxo/auth-url');
|
|
2657
|
+
window.location.href = data.authUrl;
|
|
2658
|
+
} catch (err) {
|
|
2659
|
+
alert('Failed to start OAuth flow: ' + err.message);
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
|
|
2663
|
+
async function disconnectSaxo() {
|
|
2664
|
+
if (!confirm('Disconnect Saxo account? You\'ll need to reconnect to trade.')) return;
|
|
2665
|
+
|
|
2666
|
+
try {
|
|
2667
|
+
await api('/api/integrations/saxo/disconnect', { method: 'POST' });
|
|
2668
|
+
alert('✓ Saxo disconnected');
|
|
2669
|
+
checkSaxoStatus();
|
|
2670
|
+
} catch (err) {
|
|
2671
|
+
alert('Failed to disconnect: ' + err.message);
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2509
2674
|
</script>
|
|
2510
2675
|
</body>
|
|
2511
2676
|
</html>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
# Coinbase Trading
|
|
1
|
+
# Coinbase Trading Log
|
|
2
2
|
|
|
3
|
-
> **Read this before every Coinbase operation.**
|
|
3
|
+
> **Read this before every Coinbase operation.** Write freely after every trade.
|
|
4
|
+
> This is YOUR space — write whatever you think will make the next trade better.
|
|
4
5
|
> Never delete entries — mark outdated ones as `[OUTDATED]` with date and reason.
|
|
5
6
|
|
|
6
7
|
---
|
|
@@ -13,80 +14,13 @@
|
|
|
13
14
|
|
|
14
15
|
---
|
|
15
16
|
|
|
16
|
-
##
|
|
17
|
+
## Learnings
|
|
17
18
|
|
|
18
|
-
>
|
|
19
|
+
> Write freely here. Patterns you noticed, strategies that worked, execution insights,
|
|
20
|
+
> things to do differently, market observations, risk lessons, anything that will make
|
|
21
|
+
> the next trade better. No rigid format — just honest reflection.
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
2. HTTP 200 doesn't mean success — always check `order.success`
|
|
22
|
-
3. Duplicate `client_order_id` returns existing order, not error
|
|
23
|
-
|
|
24
|
-
*(Add more as you discover them)*
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## Fee Insights
|
|
29
|
-
|
|
30
|
-
> Track fee rates and patterns to optimize execution.
|
|
31
|
-
|
|
32
|
-
- **Current fee tier:** *Unknown — check with `getTransactionSummary()`*
|
|
33
|
-
- **Maker rate:** *TBD*
|
|
34
|
-
- **Taker rate:** *TBD*
|
|
35
|
-
|
|
36
|
-
<!--
|
|
37
|
-
- [DATE] Fee observation. Example: post_only limit orders save 0.2% in fees vs market orders
|
|
38
|
-
-->
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Order Patterns That Work
|
|
43
|
-
|
|
44
|
-
> Reusable patterns you've validated with real trades.
|
|
45
|
-
|
|
46
|
-
<!--
|
|
47
|
-
- [DATE] PATTERN: description. PAIR: which pair. RESULT: outcome.
|
|
48
|
-
Example:
|
|
49
|
-
- [2026-02-14] PATTERN: Limit buy 0.5% below current price with GTD 1-hour expiry. PAIR: BTC-USD. RESULT: Filled 70% of the time, saved avg $15 in slippage vs market orders.
|
|
50
|
-
-->
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
## Order Patterns That Failed
|
|
55
|
-
|
|
56
|
-
> Equally important — what NOT to do.
|
|
57
|
-
|
|
58
|
-
<!--
|
|
59
|
-
- [DATE] PATTERN: description. PAIR: which pair. PROBLEM: what went wrong.
|
|
60
|
-
Example:
|
|
61
|
-
- [2026-02-14] PATTERN: Market sell large SOL position ($5000). PAIR: SOL-USD. PROBLEM: 1.2% slippage due to thin order book. Should have used limit or split into smaller orders.
|
|
62
|
-
-->
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
## Product-Specific Notes
|
|
67
|
-
|
|
68
|
-
> Observations about specific trading pairs.
|
|
69
|
-
|
|
70
|
-
<!--
|
|
71
|
-
- [DATE] PRODUCT: observation
|
|
72
|
-
Example:
|
|
73
|
-
- [2026-02-14] BTC-USD: min order $1, base_increment 0.00000001, quote_increment 0.01
|
|
74
|
-
- [2026-02-14] SOL-USD: wider spreads after hours, better to trade during US market hours
|
|
75
|
-
-->
|
|
76
|
-
|
|
77
|
-
---
|
|
78
|
-
|
|
79
|
-
## Scripts I've Created
|
|
80
|
-
|
|
81
|
-
| Script | Purpose | Works Well? | Last Modified |
|
|
82
|
-
|--------|---------|-------------|---------------|
|
|
83
|
-
| *(None yet)* | | | |
|
|
84
|
-
|
|
85
|
-
---
|
|
86
|
-
|
|
87
|
-
## Mistakes to Never Repeat
|
|
88
|
-
|
|
89
|
-
1. *(Will accumulate from real trading)*
|
|
23
|
+
*(Will grow with every trade. Write what matters most to future you.)*
|
|
90
24
|
|
|
91
25
|
---
|
|
92
26
|
|
|
@@ -96,7 +30,6 @@ Example:
|
|
|
96
30
|
- **Total Trades:** 0
|
|
97
31
|
- **Total Fees Paid:** $0
|
|
98
32
|
- **Net P&L:** $0
|
|
99
|
-
- **Avg Slippage:** N/A
|
|
100
33
|
|
|
101
34
|
### Current Week
|
|
102
35
|
- **Trades:** 0
|
|
@@ -105,13 +38,4 @@ Example:
|
|
|
105
38
|
|
|
106
39
|
---
|
|
107
40
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
1. What are the actual minimum order sizes for each product?
|
|
111
|
-
2. How much slippage to expect on market orders for different pair sizes?
|
|
112
|
-
3. What's the optimal order type for different trade sizes?
|
|
113
|
-
4. When does `post_only` get rejected vs filled?
|
|
114
|
-
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
> Every entry makes your next trade better. Record everything.
|
|
41
|
+
> Every entry makes your next trade better. Record everything that matters.
|
package/skills/coinbase/SKILL.md
CHANGED
|
@@ -9,31 +9,20 @@ metadata:
|
|
|
9
9
|
|
|
10
10
|
# Coinbase Trading Executor
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Execute real trades on Coinbase via the Advanced Trade API. This is real money — be precise and never skip risk checks.
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
## Authentication
|
|
19
|
-
|
|
20
|
-
The user's Coinbase API credentials are available as environment variables:
|
|
21
|
-
- `COINBASE_API_KEY` — format: `organizations/{org_id}/apiKeys/{key_id}`
|
|
22
|
-
- `COINBASE_API_SECRET` — EC private key in PEM format
|
|
23
|
-
|
|
24
|
-
These use **CDP (Coinbase Developer Platform) keys** with **ES256 JWT** authentication. The `coinbase-api` npm package handles JWT generation internally.
|
|
14
|
+
Coinbase is the execution layer. The Trading skill is the brain. Before ANY action, read all three:
|
|
15
|
+
1. [../trading/SKILL.md](../trading/SKILL.md) — risk rules, position sizing, market regime
|
|
16
|
+
2. [../trading/LEARNING.md](../trading/LEARNING.md) — what's working now, past lessons
|
|
17
|
+
3. [LEARNING.md](LEARNING.md) — Coinbase-specific execution learnings
|
|
25
18
|
|
|
26
19
|
## Setup
|
|
27
20
|
|
|
28
|
-
Before first use, ensure the SDK is installed in the workspace:
|
|
29
|
-
|
|
30
21
|
```bash
|
|
31
22
|
npm list coinbase-api 2>/dev/null || npm install coinbase-api
|
|
32
23
|
```
|
|
33
24
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
All Coinbase operations use TypeScript/JavaScript scripts via `execute_code` or shell commands. Use the `coinbase-api` package:
|
|
25
|
+
Auth uses CDP keys with ES256 JWT via env vars `COINBASE_API_KEY` and `COINBASE_API_SECRET`. The `coinbase-api` package handles JWT internally.
|
|
37
26
|
|
|
38
27
|
```typescript
|
|
39
28
|
import { CBAdvancedTradeClient } from 'coinbase-api';
|
|
@@ -44,19 +33,20 @@ const client = new CBAdvancedTradeClient({
|
|
|
44
33
|
});
|
|
45
34
|
```
|
|
46
35
|
|
|
47
|
-
##
|
|
36
|
+
## Workflow
|
|
48
37
|
|
|
49
38
|
```
|
|
50
|
-
- [ ]
|
|
51
|
-
- [ ]
|
|
52
|
-
- [ ]
|
|
53
|
-
- [ ]
|
|
54
|
-
- [ ]
|
|
55
|
-
- [ ]
|
|
56
|
-
- [ ]
|
|
39
|
+
- [ ] 1. Read Trading SKILL.md + both LEARNING.md files
|
|
40
|
+
- [ ] 2. Validate against risk rules
|
|
41
|
+
- [ ] 3. Check balances
|
|
42
|
+
- [ ] 4. Get price and market data
|
|
43
|
+
- [ ] 5. Preview order
|
|
44
|
+
- [ ] 6. Execute order
|
|
45
|
+
- [ ] 7. Verify fill
|
|
46
|
+
- [ ] 8. Evolve
|
|
57
47
|
```
|
|
58
48
|
|
|
59
|
-
###
|
|
49
|
+
### Check Balances
|
|
60
50
|
|
|
61
51
|
```typescript
|
|
62
52
|
const accounts = await client.getAccounts();
|
|
@@ -67,17 +57,14 @@ for (const acct of accounts.accounts) {
|
|
|
67
57
|
}
|
|
68
58
|
```
|
|
69
59
|
|
|
70
|
-
###
|
|
60
|
+
### Get Price Data
|
|
71
61
|
|
|
72
62
|
```typescript
|
|
73
|
-
// Current price
|
|
74
63
|
const product = await client.getProduct({ product_id: 'BTC-USD' });
|
|
75
64
|
console.log(`Price: $${product.price}, 24h change: ${product.price_percentage_change_24h}%`);
|
|
76
65
|
|
|
77
|
-
// Best bid/ask spread
|
|
78
66
|
const spread = await client.getBestBidAsk({ product_ids: ['BTC-USD'] });
|
|
79
67
|
|
|
80
|
-
// OHLCV candles (last 24h, 1-hour granularity)
|
|
81
68
|
const candles = await client.getProductCandles({
|
|
82
69
|
product_id: 'BTC-USD',
|
|
83
70
|
start: String(Math.floor(Date.now() / 1000) - 86400),
|
|
@@ -86,9 +73,9 @@ const candles = await client.getProductCandles({
|
|
|
86
73
|
});
|
|
87
74
|
```
|
|
88
75
|
|
|
89
|
-
###
|
|
76
|
+
### Preview Order
|
|
90
77
|
|
|
91
|
-
|
|
78
|
+
Always preview before executing:
|
|
92
79
|
|
|
93
80
|
```typescript
|
|
94
81
|
const preview = await client.previewOrder({
|
|
@@ -98,38 +85,37 @@ const preview = await client.previewOrder({
|
|
|
98
85
|
market_market_ioc: { quote_size: '100.00' },
|
|
99
86
|
},
|
|
100
87
|
});
|
|
101
|
-
// Shows: quote_size, base_size, best_bid, best_ask, total_fees, slippage
|
|
102
88
|
```
|
|
103
89
|
|
|
104
|
-
###
|
|
90
|
+
### Place Orders
|
|
105
91
|
|
|
106
|
-
See [references/order-types.md](references/order-types.md) for all
|
|
92
|
+
See [references/order-types.md](references/order-types.md) for all types.
|
|
107
93
|
|
|
108
|
-
|
|
94
|
+
Market buy (spend $100):
|
|
109
95
|
```typescript
|
|
110
96
|
const order = await client.submitOrder({
|
|
111
97
|
client_order_id: crypto.randomUUID(),
|
|
112
98
|
product_id: 'BTC-USD',
|
|
113
99
|
side: 'BUY',
|
|
114
100
|
order_configuration: {
|
|
115
|
-
market_market_ioc: { quote_size: '100.00' },
|
|
101
|
+
market_market_ioc: { quote_size: '100.00' },
|
|
116
102
|
},
|
|
117
103
|
});
|
|
118
104
|
```
|
|
119
105
|
|
|
120
|
-
|
|
106
|
+
Market sell (sell 0.001 BTC):
|
|
121
107
|
```typescript
|
|
122
108
|
const order = await client.submitOrder({
|
|
123
109
|
client_order_id: crypto.randomUUID(),
|
|
124
110
|
product_id: 'BTC-USD',
|
|
125
111
|
side: 'SELL',
|
|
126
112
|
order_configuration: {
|
|
127
|
-
market_market_ioc: { base_size: '0.001' },
|
|
113
|
+
market_market_ioc: { base_size: '0.001' },
|
|
128
114
|
},
|
|
129
115
|
});
|
|
130
116
|
```
|
|
131
117
|
|
|
132
|
-
|
|
118
|
+
Limit buy (GTC):
|
|
133
119
|
```typescript
|
|
134
120
|
const order = await client.submitOrder({
|
|
135
121
|
client_order_id: crypto.randomUUID(),
|
|
@@ -145,73 +131,64 @@ const order = await client.submitOrder({
|
|
|
145
131
|
});
|
|
146
132
|
```
|
|
147
133
|
|
|
148
|
-
###
|
|
134
|
+
### Verify Order
|
|
135
|
+
|
|
136
|
+
Coinbase returns HTTP 200 even on failure. Always check `order.success`:
|
|
149
137
|
|
|
150
138
|
```typescript
|
|
151
|
-
// Check response immediately
|
|
152
139
|
if (order.success) {
|
|
153
|
-
const
|
|
154
|
-
// Get fill details
|
|
155
|
-
const status = await client.getOrder({ order_id: orderId });
|
|
140
|
+
const status = await client.getOrder({ order_id: order.success_response.order_id });
|
|
156
141
|
console.log(`Status: ${status.status}, Filled: ${status.filled_size} @ ${status.average_filled_price}`);
|
|
157
142
|
} else {
|
|
158
143
|
console.error(`Order failed: ${order.error_response.message}`);
|
|
159
144
|
}
|
|
160
145
|
```
|
|
161
146
|
|
|
162
|
-
|
|
147
|
+
### Post-Execution Evolution
|
|
148
|
+
|
|
149
|
+
After every trade, ask: "What would make the next execution better?" Then do it.
|
|
163
150
|
|
|
164
|
-
|
|
151
|
+
- Update both [LEARNING.md](LEARNING.md) and [../trading/LEARNING.md](../trading/LEARNING.md)
|
|
152
|
+
- If you had slippage, research better order types or timing. Update references
|
|
153
|
+
- If a script could do it better, build one in `scripts/`
|
|
154
|
+
- Feed execution insights back to Trading skill references
|
|
155
|
+
- Use `web_search` and `browser` to research better execution strategies, GitHub tools, market microstructure
|
|
156
|
+
- Use `cron` to schedule portfolio snapshots, price alerts, or execution quality tracking
|
|
165
157
|
|
|
166
|
-
|
|
158
|
+
No limits. If something makes execution better, do it.
|
|
167
159
|
|
|
168
160
|
## Order Management
|
|
169
161
|
|
|
170
162
|
```typescript
|
|
171
|
-
// List open orders
|
|
172
163
|
const orders = await client.getOrders({ order_status: ['OPEN', 'PENDING'] });
|
|
173
|
-
|
|
174
|
-
// Cancel specific orders
|
|
175
164
|
const cancel = await client.cancelOrders({ order_ids: ['order-id-here'] });
|
|
176
|
-
|
|
177
|
-
// Get fills (trade executions)
|
|
178
165
|
const fills = await client.getFills({ order_id: 'order-id-here' });
|
|
179
166
|
```
|
|
180
167
|
|
|
181
|
-
## Portfolio
|
|
168
|
+
## Portfolio and Fees
|
|
182
169
|
|
|
183
170
|
```typescript
|
|
184
|
-
// Portfolio breakdown
|
|
185
171
|
const portfolios = await client.getPortfolios({});
|
|
186
172
|
const breakdown = await client.getPortfolioBreakdown({ portfolio_id: portfolios.portfolios[0].uuid });
|
|
187
|
-
|
|
188
|
-
// Fee tier info
|
|
189
173
|
const fees = await client.getTransactionSummary({});
|
|
190
|
-
// Shows: fee_tier, total_volume, maker_fee_rate, taker_fee_rate
|
|
191
174
|
```
|
|
192
175
|
|
|
193
176
|
## Critical Rules
|
|
194
177
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
8. **Never place orders in a loop without delays** — respect rate limits
|
|
203
|
-
9. **Log everything in LEARNING.md** — every trade, every error, every quirk
|
|
178
|
+
- Always preview orders before executing
|
|
179
|
+
- All values are strings — `"100.00"` not `100`
|
|
180
|
+
- `client_order_id` must be unique — use `crypto.randomUUID()`
|
|
181
|
+
- Check `order.success` — HTTP 200 doesn't mean success
|
|
182
|
+
- Product IDs are `BASE-QUOTE` format (BTC-USD, ETH-USD, SOL-USD)
|
|
183
|
+
- Minimum order sizes vary — check product details first
|
|
184
|
+
- Rate limits ~10 req/sec — never loop orders without delays
|
|
204
185
|
|
|
205
|
-
##
|
|
186
|
+
## References
|
|
206
187
|
|
|
207
|
-
- [references/order-types.md](references/order-types.md) —
|
|
208
|
-
- [references/api-reference.md](references/api-reference.md) —
|
|
209
|
-
- [references/products.md](references/products.md) —
|
|
188
|
+
- [references/order-types.md](references/order-types.md) — all order configurations
|
|
189
|
+
- [references/api-reference.md](references/api-reference.md) — complete API endpoints
|
|
190
|
+
- [references/products.md](references/products.md) — trading pairs and details
|
|
210
191
|
|
|
211
192
|
## Self-Evolution
|
|
212
193
|
|
|
213
|
-
You
|
|
214
|
-
- Found an API quirk? Update LEARNING.md and references
|
|
215
|
-
- Built a reusable script? Save it in `scripts/`
|
|
216
|
-
- Discovered a better workflow? Update this SKILL.md
|
|
217
|
-
- New order type pattern? Add to `references/order-types.md`
|
|
194
|
+
You own every file in this skill. Improve anything — scripts, references, this SKILL.md itself. Use the internet to research Coinbase execution strategies, find tools, stay current on platform changes. Your `scripts/` directory should grow into a comprehensive execution toolkit.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Saxo Trading Log
|
|
2
|
+
|
|
3
|
+
> **Read this before every Saxo operation.** Write freely after every trade.
|
|
4
|
+
> This is YOUR space — write whatever you think will make the next trade better.
|
|
5
|
+
> Never delete entries — mark outdated ones as `[OUTDATED]` with date and reason.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Trade Log
|
|
10
|
+
|
|
11
|
+
| Date | Asset | Type | Side | Size | Entry | Exit | Fees | P&L | Notes |
|
|
12
|
+
|------|-------|------|------|------|-------|------|------|-----|-------|
|
|
13
|
+
| *(No trades yet)* | | | | | | | | | |
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Learnings
|
|
18
|
+
|
|
19
|
+
> Write freely here. Patterns you noticed, strategies that worked, execution insights,
|
|
20
|
+
> things to do differently, market observations, risk lessons, session timing discoveries,
|
|
21
|
+
> asset-specific quirks, margin behavior, correlation findings, anything that will make
|
|
22
|
+
> the next trade better. No rigid format — just honest reflection.
|
|
23
|
+
|
|
24
|
+
*(Will grow with every trade. Write what matters most to future you.)*
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Performance Summary
|
|
29
|
+
|
|
30
|
+
### All Time
|
|
31
|
+
- **Total Trades:** 0
|
|
32
|
+
- **Total Fees Paid:** $0
|
|
33
|
+
- **Net P&L:** $0
|
|
34
|
+
|
|
35
|
+
### Current Week
|
|
36
|
+
- **Trades:** 0
|
|
37
|
+
- **Fees:** $0
|
|
38
|
+
- **P&L:** $0
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
> Every entry makes your next trade better. Record everything that matters.
|