tinkclaw 0.2.0__tar.gz
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.
- tinkclaw-0.2.0/LICENSE +21 -0
- tinkclaw-0.2.0/PKG-INFO +333 -0
- tinkclaw-0.2.0/README.md +297 -0
- tinkclaw-0.2.0/pyproject.toml +42 -0
- tinkclaw-0.2.0/setup.cfg +4 -0
- tinkclaw-0.2.0/setup.py +51 -0
- tinkclaw-0.2.0/tinkclaw/__init__.py +13 -0
- tinkclaw-0.2.0/tinkclaw/backtest.py +70 -0
- tinkclaw-0.2.0/tinkclaw/brokers/__init__.py +9 -0
- tinkclaw-0.2.0/tinkclaw/brokers/alpaca.py +140 -0
- tinkclaw-0.2.0/tinkclaw/client.py +220 -0
- tinkclaw-0.2.0/tinkclaw/strategy.py +108 -0
- tinkclaw-0.2.0/tinkclaw.egg-info/PKG-INFO +333 -0
- tinkclaw-0.2.0/tinkclaw.egg-info/SOURCES.txt +15 -0
- tinkclaw-0.2.0/tinkclaw.egg-info/dependency_links.txt +1 -0
- tinkclaw-0.2.0/tinkclaw.egg-info/requires.txt +8 -0
- tinkclaw-0.2.0/tinkclaw.egg-info/top_level.txt +3 -0
tinkclaw-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Meshcue
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
tinkclaw-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tinkclaw
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Official Python SDK for TinkClaw quant intelligence API
|
|
5
|
+
Home-page: https://github.com/tinkclaw/tinkclaw-python
|
|
6
|
+
Author: TinkClaw
|
|
7
|
+
Author-email: TinkClaw <dev@tinkclaw.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
Project-URL: Documentation, https://tinkclaw.com/docs
|
|
10
|
+
Project-URL: Source, https://github.com/tinkclaw/tinkclaw-python
|
|
11
|
+
Project-URL: Issues, https://github.com/tinkclaw/tinkclaw-python/issues
|
|
12
|
+
Keywords: trading,bot,api,quant,finance,tinkclaw,confluence,signals,crypto
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
16
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: requests>=2.28.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
30
|
+
Provides-Extra: brokers
|
|
31
|
+
Requires-Dist: alpaca-py>=0.10.0; extra == "brokers"
|
|
32
|
+
Dynamic: author
|
|
33
|
+
Dynamic: home-page
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
Dynamic: requires-python
|
|
36
|
+
|
|
37
|
+
# TinkClaw Python SDK
|
|
38
|
+
|
|
39
|
+
Official Python SDK for [TinkClaw](https://tinkclaw.com) quant intelligence API.
|
|
40
|
+
|
|
41
|
+
Build trading bots in minutes using confluence signals powered by Hurst exponent, autocorrelation, and regime detection.
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
- Simple API wrapper for TinkClaw endpoints
|
|
46
|
+
- Strategy base class for custom bot logic
|
|
47
|
+
- Alpaca paper trading integration
|
|
48
|
+
- Local backtesting harness
|
|
49
|
+
- Full typing support
|
|
50
|
+
- Zero heavy dependencies (just `requests`)
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install -e .
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Or from PyPI (coming soon):
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install tinkclaw
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Quick Start (5 Minutes)
|
|
65
|
+
|
|
66
|
+
### 1. Get Your API Key
|
|
67
|
+
|
|
68
|
+
1. Visit [https://tinkclaw.com](https://tinkclaw.com)
|
|
69
|
+
2. Sign up for free Developer tier (50 calls/day)
|
|
70
|
+
3. Copy your API key
|
|
71
|
+
|
|
72
|
+
### 2. Basic Usage
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from tinkclaw import TinkClawClient
|
|
76
|
+
|
|
77
|
+
# Initialize client
|
|
78
|
+
client = TinkClawClient(api_key="your_key_here")
|
|
79
|
+
|
|
80
|
+
# Get confluence score
|
|
81
|
+
confluence = client.get_confluence("BTC")
|
|
82
|
+
|
|
83
|
+
print(f"Symbol: {confluence['symbol']}")
|
|
84
|
+
print(f"Score: {confluence['score']}") # 0-100
|
|
85
|
+
print(f"Signal: {confluence['signal']}") # strong_buy, buy, hold, sell, strong_sell
|
|
86
|
+
print(f"Setup: {confluence['setup_type']}") # trending, mean_reverting, uncertain
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 3. Build a Trading Bot
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from tinkclaw import TinkClawClient, Strategy
|
|
93
|
+
|
|
94
|
+
class MomentumBot(Strategy):
|
|
95
|
+
def on_signal(self, symbol, confluence):
|
|
96
|
+
score = confluence['score']
|
|
97
|
+
setup = confluence['setup_type']
|
|
98
|
+
|
|
99
|
+
# Buy on strong confluence + trending regime
|
|
100
|
+
if score > 75 and setup == 'trending':
|
|
101
|
+
self.buy(symbol, size=100)
|
|
102
|
+
|
|
103
|
+
# Sell on weak confluence
|
|
104
|
+
elif score < 40:
|
|
105
|
+
self.sell(symbol, size=100)
|
|
106
|
+
|
|
107
|
+
# Run bot
|
|
108
|
+
client = TinkClawClient(api_key="your_key_here")
|
|
109
|
+
bot = MomentumBot(symbols=['BTC', 'ETH', 'SOL'], client=client)
|
|
110
|
+
bot.run(interval_hours=4) # Check every 4 hours
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Output:
|
|
114
|
+
```
|
|
115
|
+
[TINKCLAW] Starting strategy for 3 symbols
|
|
116
|
+
[TINKCLAW] Check interval: 4 hours
|
|
117
|
+
|
|
118
|
+
[TINKCLAW] Iteration 1 - 2026-02-21T10:00:00
|
|
119
|
+
[SIGNAL] BTC: score=78, signal=strong_buy, setup=trending
|
|
120
|
+
[SIGNAL] Buy 100 BTC (Strong trending signal (score=78))
|
|
121
|
+
[SIGNAL] ETH: score=65, signal=buy, setup=trending
|
|
122
|
+
[HOLD] ETH: position=0, score=65, setup=trending
|
|
123
|
+
[SIGNAL] SOL: score=42, signal=hold, setup=uncertain
|
|
124
|
+
[HOLD] SOL: position=0, score=42, setup=uncertain
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 4. Integrate with Alpaca Paper Trading
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from tinkclaw import TinkClawClient, Strategy
|
|
131
|
+
from tinkclaw.brokers import AlpacaBroker
|
|
132
|
+
|
|
133
|
+
# Initialize broker
|
|
134
|
+
broker = AlpacaBroker(
|
|
135
|
+
api_key="your_alpaca_key",
|
|
136
|
+
secret_key="your_alpaca_secret",
|
|
137
|
+
paper=True # Paper trading
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
# Initialize strategy with broker
|
|
141
|
+
bot = MomentumBot(
|
|
142
|
+
symbols=['AAPL', 'TSLA', 'NVDA'],
|
|
143
|
+
client=client,
|
|
144
|
+
broker=broker # Trades will execute on Alpaca
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
bot.run(interval_hours=4)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Output:
|
|
151
|
+
```
|
|
152
|
+
[EXECUTE] Buy 100 AAPL via AlpacaBroker
|
|
153
|
+
[EXECUTE] Sell 50 TSLA via AlpacaBroker
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## API Reference
|
|
157
|
+
|
|
158
|
+
### TinkClawClient
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
client = TinkClawClient(api_key="your_key")
|
|
162
|
+
|
|
163
|
+
# Get confluence score
|
|
164
|
+
confluence = client.get_confluence("BTC")
|
|
165
|
+
|
|
166
|
+
# Multi-timeframe analysis
|
|
167
|
+
confluence = client.get_confluence("BTC", timeframes=[7, 30, 90, 365])
|
|
168
|
+
|
|
169
|
+
# Get technical indicators
|
|
170
|
+
indicators = client.get_indicators("ETH", range_days=30)
|
|
171
|
+
|
|
172
|
+
# Get historical signals
|
|
173
|
+
history = client.get_history("SOL", limit=100)
|
|
174
|
+
|
|
175
|
+
# Get top signals across all assets
|
|
176
|
+
top = client.get_top_signals(min_score=70, limit=10)
|
|
177
|
+
|
|
178
|
+
# Health check
|
|
179
|
+
health = client.health()
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Strategy Base Class
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
class MyBot(Strategy):
|
|
186
|
+
def on_signal(self, symbol, confluence):
|
|
187
|
+
# Your strategy logic here
|
|
188
|
+
pass
|
|
189
|
+
|
|
190
|
+
bot = MyBot(symbols=['BTC'], client=client, broker=None)
|
|
191
|
+
bot.run(interval_hours=4)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Methods:
|
|
195
|
+
- `on_signal(symbol, confluence)` - Override with your logic
|
|
196
|
+
- `buy(symbol, size, reason)` - Place buy order
|
|
197
|
+
- `sell(symbol, size, reason)` - Place sell order
|
|
198
|
+
- `get_position(symbol)` - Get current position
|
|
199
|
+
- `run(interval_hours, max_iterations)` - Run strategy loop
|
|
200
|
+
|
|
201
|
+
### AlpacaBroker
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
from tinkclaw.brokers import AlpacaBroker
|
|
205
|
+
|
|
206
|
+
broker = AlpacaBroker(
|
|
207
|
+
api_key="your_key",
|
|
208
|
+
secret_key="your_secret",
|
|
209
|
+
paper=True # Use paper trading
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
# Place orders
|
|
213
|
+
broker.buy("AAPL", size=10)
|
|
214
|
+
broker.sell("AAPL", size=10)
|
|
215
|
+
|
|
216
|
+
# Get position
|
|
217
|
+
position = broker.get_position("AAPL")
|
|
218
|
+
|
|
219
|
+
# Get account info
|
|
220
|
+
account = broker.get_account()
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Examples
|
|
224
|
+
|
|
225
|
+
See `examples/` directory:
|
|
226
|
+
|
|
227
|
+
- **momentum_bot.py** - Complete working bot using confluence signals
|
|
228
|
+
- **quickstart.md** - 5-minute integration guide
|
|
229
|
+
|
|
230
|
+
Run the example:
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
python examples/momentum_bot.py
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Rate Limits
|
|
237
|
+
|
|
238
|
+
| Tier | Calls/Day | Price | Use Case |
|
|
239
|
+
|------|-----------|-------|----------|
|
|
240
|
+
| Developer | 50 | Free | Testing (3 assets x 6 checks/day) |
|
|
241
|
+
| Builder | 5,000 | $29/mo | Prod bots (10 assets x 24 checks/day) |
|
|
242
|
+
| Pro | 50,000 | $99/mo | Multi-strategy systems |
|
|
243
|
+
| Enterprise | Custom | Custom | Institutional use |
|
|
244
|
+
|
|
245
|
+
**Developer Tier Optimization:**
|
|
246
|
+
- Check every 4-6 hours (not hourly)
|
|
247
|
+
- Monitor 3-5 assets max
|
|
248
|
+
- 50 calls/day = 3 assets x 6 checks/day (every 4 hours)
|
|
249
|
+
|
|
250
|
+
## Advanced Features
|
|
251
|
+
|
|
252
|
+
### Multi-Timeframe Analysis
|
|
253
|
+
|
|
254
|
+
```python
|
|
255
|
+
confluence = client.get_confluence(
|
|
256
|
+
symbol="BTC",
|
|
257
|
+
timeframes=[7, 30, 90, 365] # 1w, 1m, 3m, 1y
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
# Returns confluence across all timeframes
|
|
261
|
+
print(confluence['multi_timeframe'])
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Backtesting (Coming Soon)
|
|
265
|
+
|
|
266
|
+
```python
|
|
267
|
+
from tinkclaw import BacktestEngine
|
|
268
|
+
|
|
269
|
+
engine = BacktestEngine(
|
|
270
|
+
strategy=bot,
|
|
271
|
+
start_date="2025-01-01",
|
|
272
|
+
end_date="2026-01-01",
|
|
273
|
+
initial_capital=10000
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
results = engine.run()
|
|
277
|
+
print(f"Total return: {results['total_return']}%")
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## Architecture
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
Your Bot
|
|
284
|
+
|
|
|
285
|
+
TinkClaw SDK
|
|
286
|
+
|
|
|
287
|
+
TinkClaw API (meshcue-api.dieubuhendwa.workers.dev)
|
|
288
|
+
|
|
|
289
|
+
TinkClaw Backend (Cloudflare Workers + KV)
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Development
|
|
293
|
+
|
|
294
|
+
Install dev dependencies:
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
pip install -e ".[dev]"
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Run tests:
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
pytest
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Format code:
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
black tinkclaw/
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## License
|
|
313
|
+
|
|
314
|
+
MIT License - see LICENSE file
|
|
315
|
+
|
|
316
|
+
## Support
|
|
317
|
+
|
|
318
|
+
- **Documentation**: [https://tinkclaw.com/docs](https://tinkclaw.com/docs)
|
|
319
|
+
- **API Status**: [https://meshcue-api.dieubuhendwa.workers.dev/api/signals/health](https://meshcue-api.dieubuhendwa.workers.dev/api/signals/health)
|
|
320
|
+
- **Issues**: [GitHub Issues](https://github.com/tinkclaw/tinkclaw-python/issues)
|
|
321
|
+
|
|
322
|
+
## Roadmap
|
|
323
|
+
|
|
324
|
+
- [ ] Publish to PyPI
|
|
325
|
+
- [ ] Add more broker integrations (Interactive Brokers, Coinbase)
|
|
326
|
+
- [ ] Complete backtesting engine with performance metrics
|
|
327
|
+
- [ ] Add WebSocket streaming for real-time signals
|
|
328
|
+
- [ ] CLI tool for quick testing
|
|
329
|
+
- [ ] Jupyter notebook examples
|
|
330
|
+
|
|
331
|
+
## Credits
|
|
332
|
+
|
|
333
|
+
Built by [Meshcue](https://meshcue.com) - Global platform for quant intelligence.
|
tinkclaw-0.2.0/README.md
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# TinkClaw Python SDK
|
|
2
|
+
|
|
3
|
+
Official Python SDK for [TinkClaw](https://tinkclaw.com) quant intelligence API.
|
|
4
|
+
|
|
5
|
+
Build trading bots in minutes using confluence signals powered by Hurst exponent, autocorrelation, and regime detection.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Simple API wrapper for TinkClaw endpoints
|
|
10
|
+
- Strategy base class for custom bot logic
|
|
11
|
+
- Alpaca paper trading integration
|
|
12
|
+
- Local backtesting harness
|
|
13
|
+
- Full typing support
|
|
14
|
+
- Zero heavy dependencies (just `requests`)
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install -e .
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or from PyPI (coming soon):
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install tinkclaw
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick Start (5 Minutes)
|
|
29
|
+
|
|
30
|
+
### 1. Get Your API Key
|
|
31
|
+
|
|
32
|
+
1. Visit [https://tinkclaw.com](https://tinkclaw.com)
|
|
33
|
+
2. Sign up for free Developer tier (50 calls/day)
|
|
34
|
+
3. Copy your API key
|
|
35
|
+
|
|
36
|
+
### 2. Basic Usage
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from tinkclaw import TinkClawClient
|
|
40
|
+
|
|
41
|
+
# Initialize client
|
|
42
|
+
client = TinkClawClient(api_key="your_key_here")
|
|
43
|
+
|
|
44
|
+
# Get confluence score
|
|
45
|
+
confluence = client.get_confluence("BTC")
|
|
46
|
+
|
|
47
|
+
print(f"Symbol: {confluence['symbol']}")
|
|
48
|
+
print(f"Score: {confluence['score']}") # 0-100
|
|
49
|
+
print(f"Signal: {confluence['signal']}") # strong_buy, buy, hold, sell, strong_sell
|
|
50
|
+
print(f"Setup: {confluence['setup_type']}") # trending, mean_reverting, uncertain
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 3. Build a Trading Bot
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from tinkclaw import TinkClawClient, Strategy
|
|
57
|
+
|
|
58
|
+
class MomentumBot(Strategy):
|
|
59
|
+
def on_signal(self, symbol, confluence):
|
|
60
|
+
score = confluence['score']
|
|
61
|
+
setup = confluence['setup_type']
|
|
62
|
+
|
|
63
|
+
# Buy on strong confluence + trending regime
|
|
64
|
+
if score > 75 and setup == 'trending':
|
|
65
|
+
self.buy(symbol, size=100)
|
|
66
|
+
|
|
67
|
+
# Sell on weak confluence
|
|
68
|
+
elif score < 40:
|
|
69
|
+
self.sell(symbol, size=100)
|
|
70
|
+
|
|
71
|
+
# Run bot
|
|
72
|
+
client = TinkClawClient(api_key="your_key_here")
|
|
73
|
+
bot = MomentumBot(symbols=['BTC', 'ETH', 'SOL'], client=client)
|
|
74
|
+
bot.run(interval_hours=4) # Check every 4 hours
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Output:
|
|
78
|
+
```
|
|
79
|
+
[TINKCLAW] Starting strategy for 3 symbols
|
|
80
|
+
[TINKCLAW] Check interval: 4 hours
|
|
81
|
+
|
|
82
|
+
[TINKCLAW] Iteration 1 - 2026-02-21T10:00:00
|
|
83
|
+
[SIGNAL] BTC: score=78, signal=strong_buy, setup=trending
|
|
84
|
+
[SIGNAL] Buy 100 BTC (Strong trending signal (score=78))
|
|
85
|
+
[SIGNAL] ETH: score=65, signal=buy, setup=trending
|
|
86
|
+
[HOLD] ETH: position=0, score=65, setup=trending
|
|
87
|
+
[SIGNAL] SOL: score=42, signal=hold, setup=uncertain
|
|
88
|
+
[HOLD] SOL: position=0, score=42, setup=uncertain
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 4. Integrate with Alpaca Paper Trading
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from tinkclaw import TinkClawClient, Strategy
|
|
95
|
+
from tinkclaw.brokers import AlpacaBroker
|
|
96
|
+
|
|
97
|
+
# Initialize broker
|
|
98
|
+
broker = AlpacaBroker(
|
|
99
|
+
api_key="your_alpaca_key",
|
|
100
|
+
secret_key="your_alpaca_secret",
|
|
101
|
+
paper=True # Paper trading
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
# Initialize strategy with broker
|
|
105
|
+
bot = MomentumBot(
|
|
106
|
+
symbols=['AAPL', 'TSLA', 'NVDA'],
|
|
107
|
+
client=client,
|
|
108
|
+
broker=broker # Trades will execute on Alpaca
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
bot.run(interval_hours=4)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Output:
|
|
115
|
+
```
|
|
116
|
+
[EXECUTE] Buy 100 AAPL via AlpacaBroker
|
|
117
|
+
[EXECUTE] Sell 50 TSLA via AlpacaBroker
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## API Reference
|
|
121
|
+
|
|
122
|
+
### TinkClawClient
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
client = TinkClawClient(api_key="your_key")
|
|
126
|
+
|
|
127
|
+
# Get confluence score
|
|
128
|
+
confluence = client.get_confluence("BTC")
|
|
129
|
+
|
|
130
|
+
# Multi-timeframe analysis
|
|
131
|
+
confluence = client.get_confluence("BTC", timeframes=[7, 30, 90, 365])
|
|
132
|
+
|
|
133
|
+
# Get technical indicators
|
|
134
|
+
indicators = client.get_indicators("ETH", range_days=30)
|
|
135
|
+
|
|
136
|
+
# Get historical signals
|
|
137
|
+
history = client.get_history("SOL", limit=100)
|
|
138
|
+
|
|
139
|
+
# Get top signals across all assets
|
|
140
|
+
top = client.get_top_signals(min_score=70, limit=10)
|
|
141
|
+
|
|
142
|
+
# Health check
|
|
143
|
+
health = client.health()
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Strategy Base Class
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
class MyBot(Strategy):
|
|
150
|
+
def on_signal(self, symbol, confluence):
|
|
151
|
+
# Your strategy logic here
|
|
152
|
+
pass
|
|
153
|
+
|
|
154
|
+
bot = MyBot(symbols=['BTC'], client=client, broker=None)
|
|
155
|
+
bot.run(interval_hours=4)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Methods:
|
|
159
|
+
- `on_signal(symbol, confluence)` - Override with your logic
|
|
160
|
+
- `buy(symbol, size, reason)` - Place buy order
|
|
161
|
+
- `sell(symbol, size, reason)` - Place sell order
|
|
162
|
+
- `get_position(symbol)` - Get current position
|
|
163
|
+
- `run(interval_hours, max_iterations)` - Run strategy loop
|
|
164
|
+
|
|
165
|
+
### AlpacaBroker
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
from tinkclaw.brokers import AlpacaBroker
|
|
169
|
+
|
|
170
|
+
broker = AlpacaBroker(
|
|
171
|
+
api_key="your_key",
|
|
172
|
+
secret_key="your_secret",
|
|
173
|
+
paper=True # Use paper trading
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
# Place orders
|
|
177
|
+
broker.buy("AAPL", size=10)
|
|
178
|
+
broker.sell("AAPL", size=10)
|
|
179
|
+
|
|
180
|
+
# Get position
|
|
181
|
+
position = broker.get_position("AAPL")
|
|
182
|
+
|
|
183
|
+
# Get account info
|
|
184
|
+
account = broker.get_account()
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Examples
|
|
188
|
+
|
|
189
|
+
See `examples/` directory:
|
|
190
|
+
|
|
191
|
+
- **momentum_bot.py** - Complete working bot using confluence signals
|
|
192
|
+
- **quickstart.md** - 5-minute integration guide
|
|
193
|
+
|
|
194
|
+
Run the example:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
python examples/momentum_bot.py
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Rate Limits
|
|
201
|
+
|
|
202
|
+
| Tier | Calls/Day | Price | Use Case |
|
|
203
|
+
|------|-----------|-------|----------|
|
|
204
|
+
| Developer | 50 | Free | Testing (3 assets x 6 checks/day) |
|
|
205
|
+
| Builder | 5,000 | $29/mo | Prod bots (10 assets x 24 checks/day) |
|
|
206
|
+
| Pro | 50,000 | $99/mo | Multi-strategy systems |
|
|
207
|
+
| Enterprise | Custom | Custom | Institutional use |
|
|
208
|
+
|
|
209
|
+
**Developer Tier Optimization:**
|
|
210
|
+
- Check every 4-6 hours (not hourly)
|
|
211
|
+
- Monitor 3-5 assets max
|
|
212
|
+
- 50 calls/day = 3 assets x 6 checks/day (every 4 hours)
|
|
213
|
+
|
|
214
|
+
## Advanced Features
|
|
215
|
+
|
|
216
|
+
### Multi-Timeframe Analysis
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
confluence = client.get_confluence(
|
|
220
|
+
symbol="BTC",
|
|
221
|
+
timeframes=[7, 30, 90, 365] # 1w, 1m, 3m, 1y
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
# Returns confluence across all timeframes
|
|
225
|
+
print(confluence['multi_timeframe'])
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Backtesting (Coming Soon)
|
|
229
|
+
|
|
230
|
+
```python
|
|
231
|
+
from tinkclaw import BacktestEngine
|
|
232
|
+
|
|
233
|
+
engine = BacktestEngine(
|
|
234
|
+
strategy=bot,
|
|
235
|
+
start_date="2025-01-01",
|
|
236
|
+
end_date="2026-01-01",
|
|
237
|
+
initial_capital=10000
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
results = engine.run()
|
|
241
|
+
print(f"Total return: {results['total_return']}%")
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Architecture
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
Your Bot
|
|
248
|
+
|
|
|
249
|
+
TinkClaw SDK
|
|
250
|
+
|
|
|
251
|
+
TinkClaw API (meshcue-api.dieubuhendwa.workers.dev)
|
|
252
|
+
|
|
|
253
|
+
TinkClaw Backend (Cloudflare Workers + KV)
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Development
|
|
257
|
+
|
|
258
|
+
Install dev dependencies:
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
pip install -e ".[dev]"
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Run tests:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
pytest
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Format code:
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
black tinkclaw/
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## License
|
|
277
|
+
|
|
278
|
+
MIT License - see LICENSE file
|
|
279
|
+
|
|
280
|
+
## Support
|
|
281
|
+
|
|
282
|
+
- **Documentation**: [https://tinkclaw.com/docs](https://tinkclaw.com/docs)
|
|
283
|
+
- **API Status**: [https://meshcue-api.dieubuhendwa.workers.dev/api/signals/health](https://meshcue-api.dieubuhendwa.workers.dev/api/signals/health)
|
|
284
|
+
- **Issues**: [GitHub Issues](https://github.com/tinkclaw/tinkclaw-python/issues)
|
|
285
|
+
|
|
286
|
+
## Roadmap
|
|
287
|
+
|
|
288
|
+
- [ ] Publish to PyPI
|
|
289
|
+
- [ ] Add more broker integrations (Interactive Brokers, Coinbase)
|
|
290
|
+
- [ ] Complete backtesting engine with performance metrics
|
|
291
|
+
- [ ] Add WebSocket streaming for real-time signals
|
|
292
|
+
- [ ] CLI tool for quick testing
|
|
293
|
+
- [ ] Jupyter notebook examples
|
|
294
|
+
|
|
295
|
+
## Credits
|
|
296
|
+
|
|
297
|
+
Built by [Meshcue](https://meshcue.com) - Global platform for quant intelligence.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tinkclaw"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Official Python SDK for TinkClaw quant intelligence API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "TinkClaw", email = "dev@tinkclaw.com" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["trading", "bot", "api", "quant", "finance", "tinkclaw", "confluence", "signals", "crypto"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Intended Audience :: Financial and Insurance Industry",
|
|
20
|
+
"Topic :: Office/Business :: Financial :: Investment",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.9",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"requests>=2.28.0",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
dev = ["pytest>=7.0.0", "pytest-cov>=4.0.0"]
|
|
34
|
+
brokers = ["alpaca-py>=0.10.0"]
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Documentation = "https://tinkclaw.com/docs"
|
|
38
|
+
Source = "https://github.com/tinkclaw/tinkclaw-python"
|
|
39
|
+
Issues = "https://github.com/tinkclaw/tinkclaw-python/issues"
|
|
40
|
+
|
|
41
|
+
[tool.setuptools.packages.find]
|
|
42
|
+
exclude = ["tests", "examples", "venv"]
|
tinkclaw-0.2.0/setup.cfg
ADDED