Dmitry Beresnev commited on
Commit
6e99af6
·
1 Parent(s): abff89f

add openclaw configs, skills, etc

Browse files
README.md CHANGED
@@ -9,4 +9,23 @@ license: apache-2.0
9
  short_description: AGI Assistant
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  short_description: AGI Assistant
10
  ---
11
 
12
+ This Space hosts the OpenClaw trading bot (paper-only). The LLM runs in a separate Space that you already have; this repo only contains the bot-side architecture and configs.
13
+
14
+ **Architecture**
15
+ - OpenClaw bot Space (this repo) calls an external LLM Space for analysis and signal generation.
16
+ - Paper trading via Alpaca API.
17
+ - Trade logs stored to HF Hub storage (dataset repo).
18
+
19
+ **LLM Space (external)**
20
+ - Expected to expose a simple HTTP inference endpoint.
21
+ - The bot calls `${LLM_SPACE_URL}` (see `config/openclaw.env.example`) and expects a JSON response with an output string.
22
+ - Update `LLM_SPACE_URL` and response path in `openclaw.json` to match your existing LLM Space.
23
+
24
+ **Key Files**
25
+ - `openclaw.json` defines providers, routing, tools, memory, and safety.
26
+ - `config/openclaw.env.example` lists all required env vars.
27
+ - `skills/` contains architecture-only SKILL specs.
28
+ - `tools/README.md` defines the tool surface to implement later.
29
+ - `schedules/cron.yml` documents the intended schedule.
30
+
31
+ If you want me to add minimal tool stubs or a working runner later, say the word and I will wire it up.
config/openclaw.env.example ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LLM Space (external)
2
+ LLM_SPACE_URL=https://your-llm-space.hf.space/api/predict
3
+
4
+ # Alpaca paper trading
5
+ ALPACA_API_KEY=your_key
6
+ ALPACA_API_SECRET=your_secret
7
+ ALPACA_BASE_URL=https://paper-api.alpaca.markets
8
+
9
+ # HF Storage for trade logs
10
+ HF_TOKEN=hf_xxx
11
+ HF_TRADES_REPO=username/trading-logs
12
+
13
+ # Market data (optional extra source)
14
+ MARKET_DATA_SOURCE=alpaca
openclaw.json ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "agent": {
3
+ "name": "openclaw-trading-bot",
4
+ "description": "OpenClaw bot for paper trading with Alpaca and external LLM Space",
5
+ "timezone": "UTC"
6
+ },
7
+ "providers": [
8
+ {
9
+ "name": "hf_space_llm",
10
+ "type": "custom_http",
11
+ "base_url": "${LLM_SPACE_URL}",
12
+ "method": "POST",
13
+ "timeout_ms": 20000,
14
+ "request_schema": {
15
+ "inputs": "${prompt}"
16
+ },
17
+ "response_path": "data.output_text"
18
+ }
19
+ ],
20
+ "routing": {
21
+ "market_analysis": "hf_space_llm",
22
+ "signal_generation": "hf_space_llm",
23
+ "reporting": "hf_space_llm"
24
+ },
25
+ "tools": {
26
+ "alpaca_paper": {
27
+ "type": "python",
28
+ "module": "tools.alpaca_paper",
29
+ "env": [
30
+ "ALPACA_API_KEY",
31
+ "ALPACA_API_SECRET",
32
+ "ALPACA_BASE_URL"
33
+ ]
34
+ },
35
+ "hf_storage": {
36
+ "type": "python",
37
+ "module": "tools.hf_storage",
38
+ "env": [
39
+ "HF_TOKEN",
40
+ "HF_TRADES_REPO"
41
+ ]
42
+ },
43
+ "market_data": {
44
+ "type": "python",
45
+ "module": "tools.market_data",
46
+ "env": [
47
+ "MARKET_DATA_SOURCE"
48
+ ]
49
+ }
50
+ },
51
+ "memory": {
52
+ "type": "sqlite",
53
+ "path": "/data/openclaw_memory.sqlite",
54
+ "max_tokens": 1200
55
+ },
56
+ "safety": {
57
+ "paper_only": true,
58
+ "max_order_qty": 5,
59
+ "max_position_usd": 5000,
60
+ "require_signal": true
61
+ }
62
+ }
schedules/cron.yml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ schedules:
2
+ market_data:
3
+ cron: "*/5 * * * *"
4
+ signal_trading:
5
+ cron: "*/5 * * * *"
6
+ reporting:
7
+ cron: "0 0 * * *"
skills/execution/SKILL.md ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: execution
2
+ version: 0.1
3
+ kind: skill
4
+ summary: Executes paper orders with safety checks and logs trades
5
+ triggers:
6
+ - event: "signal_ready"
7
+ inputs:
8
+ - signal
9
+ outputs:
10
+ - order_id
11
+ - status
12
+ tools:
13
+ - alpaca_paper
14
+ - hf_storage
15
+ steps:
16
+ - id: preflight
17
+ run: "risk_checks"
18
+ - id: place_order
19
+ tool: alpaca_paper
20
+ with:
21
+ action: submit_order
22
+ signal: "${signal}"
23
+ - id: log_trade
24
+ tool: hf_storage
25
+ with:
26
+ record: "${order}"
27
+ notes:
28
+ - "Keep this paper-only; hard-block live trading in tool implementation"
skills/market_data/SKILL.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: market_data
2
+ version: 0.1
3
+ kind: skill
4
+ summary: Fetches market data snapshots for analysis
5
+ triggers:
6
+ - cron: "*/5 * * * *"
7
+ inputs:
8
+ - symbols
9
+ outputs:
10
+ - snapshot
11
+ tools:
12
+ - market_data
13
+ steps:
14
+ - id: fetch_snapshot
15
+ tool: market_data
16
+ with:
17
+ symbols: "${symbols}"
18
+ notes:
19
+ - "This skill is intentionally minimal; implement tool wiring in tools/market_data.py"
skills/reporting/SKILL.md ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: reporting
2
+ version: 0.1
3
+ kind: skill
4
+ summary: Creates daily summaries of signals and trades
5
+ triggers:
6
+ - cron: "0 0 * * *"
7
+ inputs:
8
+ - trades
9
+ outputs:
10
+ - report
11
+ providers:
12
+ - hf_space_llm
13
+ tools:
14
+ - hf_storage
15
+ steps:
16
+ - id: summarize
17
+ provider: hf_space_llm
18
+ with:
19
+ prompt: "Summarize the trading day from this JSON: ${trades}"
20
+ - id: store_report
21
+ tool: hf_storage
22
+ with:
23
+ record: "${report}"
24
+ notes:
25
+ - "Replace with PDF/CSV generator when ready"
skills/signal_trading/SKILL.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: signal_trading
2
+ version: 0.1
3
+ kind: skill
4
+ summary: Generates trade signals via external LLM and queues orders
5
+ triggers:
6
+ - cron: "*/5 * * * *"
7
+ inputs:
8
+ - snapshot
9
+ outputs:
10
+ - signal
11
+ providers:
12
+ - hf_space_llm
13
+ steps:
14
+ - id: build_prompt
15
+ run: "render_prompt"
16
+ with:
17
+ template: "${PROMPT_TEMPLATE}"
18
+ snapshot: "${snapshot}"
19
+ - id: generate_signal
20
+ provider: hf_space_llm
21
+ with:
22
+ prompt: "${prompt}"
23
+ - id: normalize_signal
24
+ run: "normalize_signal"
25
+ notes:
26
+ - "Add a schema validator to keep outputs strict: buy/sell/hold + qty"
tools/README.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Tools (Architecture Only)
2
+
3
+ This directory defines the tool surface expected by `openclaw.json`.
4
+ Implementations are intentionally left as stubs for now.
5
+
6
+ Expected modules:
7
+ - `tools/alpaca_paper.py`
8
+ - `submit_order(signal)`
9
+ - `list_positions()`
10
+ - Safety: refuse non-paper base URL
11
+ - `tools/hf_storage.py`
12
+ - `append_trade(record)`
13
+ - `append_report(record)`
14
+ - Storage target: HF dataset repo
15
+ - `tools/market_data.py`
16
+ - `get_snapshot(symbols)`
17
+ - Optional: Alpaca data or external provider
18
+
19
+ All tools should accept config via environment variables listed in `openclaw.json`.