clodds 1.2.9 → 1.3.0
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/skills/bundled/acp/SKILL.md +188 -0
- package/dist/skills/bundled/acp/index.d.ts +0 -3
- package/dist/skills/bundled/acp/index.js +1 -1
- package/dist/skills/bundled/acp/index.js.map +1 -1
- package/dist/skills/bundled/agentbets/SKILL.md +19 -0
- package/dist/skills/bundled/ai-strategy/SKILL.md +111 -0
- package/dist/skills/bundled/ai-strategy/index.js +1 -1
- package/dist/skills/bundled/ai-strategy/index.js.map +1 -1
- package/dist/skills/bundled/alerts/SKILL.md +87 -0
- package/dist/skills/bundled/analytics/SKILL.md +252 -0
- package/dist/skills/bundled/analytics/index.js +2 -2
- package/dist/skills/bundled/analytics/index.js.map +1 -1
- package/dist/skills/bundled/arbitrage/SKILL.md +287 -0
- package/dist/skills/bundled/auto-reply/SKILL.md +285 -0
- package/dist/skills/bundled/auto-reply/index.js +2 -2
- package/dist/skills/bundled/auto-reply/index.js.map +1 -1
- package/dist/skills/bundled/automation/SKILL.md +242 -0
- package/dist/skills/bundled/automation/index.js +2 -2
- package/dist/skills/bundled/automation/index.js.map +1 -1
- package/dist/skills/bundled/backtest/SKILL.md +225 -0
- package/dist/skills/bundled/bags/SKILL.md +131 -0
- package/dist/skills/bundled/bankr/SKILL.md +114 -0
- package/dist/skills/bundled/betfair/SKILL.md +113 -0
- package/dist/skills/bundled/binance-futures/SKILL.md +84 -0
- package/dist/skills/bundled/binance-futures/index.d.ts +0 -3
- package/dist/skills/bundled/binance-futures/index.js +1 -2
- package/dist/skills/bundled/binance-futures/index.js.map +1 -1
- package/dist/skills/bundled/botchan/SKILL.md +66 -0
- package/dist/skills/bundled/botchan/index.d.ts +0 -3
- package/dist/skills/bundled/botchan/index.js +0 -1
- package/dist/skills/bundled/botchan/index.js.map +1 -1
- package/dist/skills/bundled/bridge/SKILL.md +215 -0
- package/dist/skills/bundled/bybit-futures/SKILL.md +84 -0
- package/dist/skills/bundled/bybit-futures/index.d.ts +0 -3
- package/dist/skills/bundled/bybit-futures/index.js +0 -1
- package/dist/skills/bundled/bybit-futures/index.js.map +1 -1
- package/dist/skills/bundled/clanker/SKILL.md +125 -0
- package/dist/skills/bundled/clanker/index.d.ts +0 -3
- package/dist/skills/bundled/clanker/index.js +0 -1
- package/dist/skills/bundled/clanker/index.js.map +1 -1
- package/dist/skills/bundled/copy-trading/SKILL.md +285 -0
- package/dist/skills/bundled/copy-trading/index.js +2 -2
- package/dist/skills/bundled/copy-trading/index.js.map +1 -1
- package/dist/skills/bundled/copy-trading-solana/SKILL.md +66 -0
- package/dist/skills/bundled/credentials/SKILL.md +261 -0
- package/dist/skills/bundled/crypto-hft/SKILL.md +121 -0
- package/dist/skills/bundled/dca/SKILL.md +27 -0
- package/dist/skills/bundled/dex/SKILL.md +87 -0
- package/dist/skills/bundled/divergence/SKILL.md +83 -0
- package/dist/skills/bundled/doctor/SKILL.md +267 -0
- package/dist/skills/bundled/doctor/index.js +2 -8
- package/dist/skills/bundled/doctor/index.js.map +1 -1
- package/dist/skills/bundled/drift/SKILL.md +53 -0
- package/dist/skills/bundled/drift-sdk/SKILL.md +103 -0
- package/dist/skills/bundled/drift-sdk/index.d.ts +0 -3
- package/dist/skills/bundled/drift-sdk/index.js +0 -1
- package/dist/skills/bundled/drift-sdk/index.js.map +1 -1
- package/dist/skills/bundled/edge/SKILL.md +84 -0
- package/dist/skills/bundled/embeddings/SKILL.md +244 -0
- package/dist/skills/bundled/endaoment/SKILL.md +65 -0
- package/dist/skills/bundled/endaoment/index.d.ts +0 -3
- package/dist/skills/bundled/endaoment/index.js +0 -1
- package/dist/skills/bundled/endaoment/index.js.map +1 -1
- package/dist/skills/bundled/ens/SKILL.md +63 -0
- package/dist/skills/bundled/ens/index.d.ts +0 -3
- package/dist/skills/bundled/ens/index.js +0 -1
- package/dist/skills/bundled/ens/index.js.map +1 -1
- package/dist/skills/bundled/erc8004/SKILL.md +79 -0
- package/dist/skills/bundled/erc8004/index.d.ts +0 -3
- package/dist/skills/bundled/erc8004/index.js +0 -1
- package/dist/skills/bundled/erc8004/index.js.map +1 -1
- package/dist/skills/bundled/execution/SKILL.md +278 -0
- package/dist/skills/bundled/farcaster/SKILL.md +80 -0
- package/dist/skills/bundled/features/SKILL.md +20 -0
- package/dist/skills/bundled/feeds/SKILL.md +288 -0
- package/dist/skills/bundled/harden/SKILL.md +74 -0
- package/dist/skills/bundled/history/SKILL.md +257 -0
- package/dist/skills/bundled/hyperliquid/SKILL.md +200 -0
- package/dist/skills/bundled/hyperliquid/index.d.ts +0 -3
- package/dist/skills/bundled/hyperliquid/index.js +0 -1
- package/dist/skills/bundled/hyperliquid/index.js.map +1 -1
- package/dist/skills/bundled/identity/SKILL.md +228 -0
- package/dist/skills/bundled/identity/index.js +2 -2
- package/dist/skills/bundled/identity/index.js.map +1 -1
- package/dist/skills/bundled/integrations/SKILL.md +321 -0
- package/dist/skills/bundled/integrations/index.js +2 -2
- package/dist/skills/bundled/integrations/index.js.map +1 -1
- package/dist/skills/bundled/jupiter/SKILL.md +163 -0
- package/dist/skills/bundled/kamino/SKILL.md +69 -0
- package/dist/skills/bundled/ledger/SKILL.md +20 -0
- package/dist/skills/bundled/lighter/SKILL.md +83 -0
- package/dist/skills/bundled/lighter/index.d.ts +0 -3
- package/dist/skills/bundled/lighter/index.js +0 -1
- package/dist/skills/bundled/lighter/index.js.map +1 -1
- package/dist/skills/bundled/marginfi/SKILL.md +62 -0
- package/dist/skills/bundled/market-index/SKILL.md +242 -0
- package/dist/skills/bundled/market-index/index.js +1 -3
- package/dist/skills/bundled/market-index/index.js.map +1 -1
- package/dist/skills/bundled/markets/SKILL.md +49 -0
- package/dist/skills/bundled/mcp/SKILL.md +235 -0
- package/dist/skills/bundled/mcp/index.js +1 -3
- package/dist/skills/bundled/mcp/index.js.map +1 -1
- package/dist/skills/bundled/memory/SKILL.md +209 -0
- package/dist/skills/bundled/metaculus/SKILL.md +62 -0
- package/dist/skills/bundled/meteora/SKILL.md +28 -0
- package/dist/skills/bundled/meteora-dbc/SKILL.md +25 -0
- package/dist/skills/bundled/metrics/SKILL.md +338 -0
- package/dist/skills/bundled/mev/SKILL.md +239 -0
- package/dist/skills/bundled/mev/index.js +2 -2
- package/dist/skills/bundled/mev/index.js.map +1 -1
- package/dist/skills/bundled/mexc-futures/SKILL.md +86 -0
- package/dist/skills/bundled/mexc-futures/index.d.ts +0 -3
- package/dist/skills/bundled/mexc-futures/index.js +0 -1
- package/dist/skills/bundled/mexc-futures/index.js.map +1 -1
- package/dist/skills/bundled/mm/SKILL.md +142 -0
- package/dist/skills/bundled/monitoring/SKILL.md +249 -0
- package/dist/skills/bundled/news/SKILL.md +95 -0
- package/dist/skills/bundled/onchainkit/SKILL.md +83 -0
- package/dist/skills/bundled/opinion/SKILL.md +87 -0
- package/dist/skills/bundled/opportunity/SKILL.md +308 -0
- package/dist/skills/bundled/orca/SKILL.md +28 -0
- package/dist/skills/bundled/pairing/SKILL.md +275 -0
- package/dist/skills/bundled/pancakeswap/SKILL.md +93 -0
- package/dist/skills/bundled/pancakeswap/index.d.ts +0 -3
- package/dist/skills/bundled/pancakeswap/index.js +0 -1
- package/dist/skills/bundled/pancakeswap/index.js.map +1 -1
- package/dist/skills/bundled/percolator/SKILL.md +22 -0
- package/dist/skills/bundled/permissions/SKILL.md +269 -0
- package/dist/skills/bundled/permissions/index.js +2 -2
- package/dist/skills/bundled/permissions/index.js.map +1 -1
- package/dist/skills/bundled/plugins/SKILL.md +263 -0
- package/dist/skills/bundled/plugins/index.js +2 -2
- package/dist/skills/bundled/plugins/index.js.map +1 -1
- package/dist/skills/bundled/portfolio/SKILL.md +161 -0
- package/dist/skills/bundled/portfolio/index.js +1 -1
- package/dist/skills/bundled/portfolio/index.js.map +1 -1
- package/dist/skills/bundled/portfolio-sync/SKILL.md +466 -0
- package/dist/skills/bundled/positions/SKILL.md +262 -0
- package/dist/skills/bundled/predictfun/SKILL.md +109 -0
- package/dist/skills/bundled/predictfun/index.js +1 -1
- package/dist/skills/bundled/predictfun/index.js.map +1 -1
- package/dist/skills/bundled/predictit/SKILL.md +66 -0
- package/dist/skills/bundled/presence/SKILL.md +217 -0
- package/dist/skills/bundled/presence/index.js +2 -2
- package/dist/skills/bundled/presence/index.js.map +1 -1
- package/dist/skills/bundled/processes/SKILL.md +254 -0
- package/dist/skills/bundled/pump-swarm/SKILL.md +309 -0
- package/dist/skills/bundled/pumpfun/SKILL.md +145 -0
- package/dist/skills/bundled/qmd/SKILL.md +129 -0
- package/dist/skills/bundled/qrcoin/SKILL.md +60 -0
- package/dist/skills/bundled/qrcoin/index.d.ts +0 -3
- package/dist/skills/bundled/qrcoin/index.js +0 -1
- package/dist/skills/bundled/qrcoin/index.js.map +1 -1
- package/dist/skills/bundled/raydium/SKILL.md +198 -0
- package/dist/skills/bundled/remote/SKILL.md +201 -0
- package/dist/skills/bundled/research/SKILL.md +83 -0
- package/dist/skills/bundled/research/index.js +2 -2
- package/dist/skills/bundled/research/index.js.map +1 -1
- package/dist/skills/bundled/risk/SKILL.md +323 -0
- package/dist/skills/bundled/router/SKILL.md +233 -0
- package/dist/skills/bundled/routing/SKILL.md +258 -0
- package/dist/skills/bundled/sandbox/SKILL.md +257 -0
- package/dist/skills/bundled/search-config/SKILL.md +257 -0
- package/dist/skills/bundled/search-config/index.js +2 -2
- package/dist/skills/bundled/search-config/index.js.map +1 -1
- package/dist/skills/bundled/sessions/SKILL.md +251 -0
- package/dist/skills/bundled/sessions/index.js +1 -1
- package/dist/skills/bundled/sessions/index.js.map +1 -1
- package/dist/skills/bundled/setup/SKILL.md +53 -0
- package/dist/skills/bundled/shield/SKILL.md +21 -0
- package/dist/skills/bundled/signals/SKILL.md +106 -0
- package/dist/skills/bundled/signals/index.d.ts +0 -3
- package/dist/skills/bundled/signals/index.js +3 -4
- package/dist/skills/bundled/signals/index.js.map +1 -1
- package/dist/skills/bundled/sizing/SKILL.md +238 -0
- package/dist/skills/bundled/slippage/SKILL.md +306 -0
- package/dist/skills/bundled/smarkets/SKILL.md +107 -0
- package/dist/skills/bundled/solend/SKILL.md +63 -0
- package/dist/skills/bundled/strategy/SKILL.md +266 -0
- package/dist/skills/bundled/streaming/SKILL.md +150 -0
- package/dist/skills/bundled/streaming/index.js +2 -2
- package/dist/skills/bundled/streaming/index.js.map +1 -1
- package/dist/skills/bundled/tailscale/SKILL.md +249 -0
- package/dist/skills/bundled/tailscale/index.js +2 -2
- package/dist/skills/bundled/tailscale/index.js.map +1 -1
- package/dist/skills/bundled/ticks/SKILL.md +61 -0
- package/dist/skills/bundled/token-security/SKILL.md +18 -0
- package/dist/skills/bundled/trading-evm/SKILL.md +329 -0
- package/dist/skills/bundled/trading-futures/SKILL.md +865 -0
- package/dist/skills/bundled/trading-kalshi/SKILL.md +629 -0
- package/dist/skills/bundled/trading-manifold/SKILL.md +387 -0
- package/dist/skills/bundled/trading-polymarket/SKILL.md +1080 -0
- package/dist/skills/bundled/trading-solana/SKILL.md +418 -0
- package/dist/skills/bundled/trading-system/SKILL.md +290 -0
- package/dist/skills/bundled/triggers/SKILL.md +433 -0
- package/dist/skills/bundled/tts/SKILL.md +220 -0
- package/dist/skills/bundled/tweet-ideas/SKILL.md +77 -0
- package/dist/skills/bundled/usage/SKILL.md +239 -0
- package/dist/skills/bundled/usage/index.js +2 -2
- package/dist/skills/bundled/usage/index.js.map +1 -1
- package/dist/skills/bundled/veil/SKILL.md +76 -0
- package/dist/skills/bundled/veil/index.d.ts +0 -3
- package/dist/skills/bundled/veil/index.js +0 -1
- package/dist/skills/bundled/veil/index.js.map +1 -1
- package/dist/skills/bundled/verify/SKILL.md +199 -0
- package/dist/skills/bundled/verify/index.d.ts +0 -3
- package/dist/skills/bundled/verify/index.js +0 -1
- package/dist/skills/bundled/verify/index.js.map +1 -1
- package/dist/skills/bundled/virtuals/SKILL.md +82 -0
- package/dist/skills/bundled/voice/SKILL.md +217 -0
- package/dist/skills/bundled/voice/index.js +2 -2
- package/dist/skills/bundled/voice/index.js.map +1 -1
- package/dist/skills/bundled/weather/SKILL.md +80 -0
- package/dist/skills/bundled/webhooks/SKILL.md +297 -0
- package/dist/skills/bundled/webhooks/index.js +2 -2
- package/dist/skills/bundled/webhooks/index.js.map +1 -1
- package/dist/skills/bundled/whale-tracking/SKILL.md +287 -0
- package/dist/skills/bundled/whale-tracking/index.js +2 -2
- package/dist/skills/bundled/whale-tracking/index.js.map +1 -1
- package/dist/skills/bundled/yoink/SKILL.md +54 -0
- package/dist/skills/bundled/yoink/index.d.ts +0 -3
- package/dist/skills/bundled/yoink/index.js +0 -1
- package/dist/skills/bundled/yoink/index.js.map +1 -1
- package/dist/skills/executor.js +5 -3
- package/dist/skills/executor.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: trading-manifold
|
|
3
|
+
description: "Place bets on Manifold Markets using their REST API"
|
|
4
|
+
emoji: "🎲"
|
|
5
|
+
gates:
|
|
6
|
+
envs:
|
|
7
|
+
- MANIFOLD_API_KEY
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Manifold Markets Trading Skill
|
|
11
|
+
|
|
12
|
+
Real, working methods to bet on Manifold Markets using Mana (play money that can be donated to charity).
|
|
13
|
+
|
|
14
|
+
## Setup
|
|
15
|
+
|
|
16
|
+
Get your API key from: https://manifold.markets/profile (API key section)
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
import os
|
|
20
|
+
import requests
|
|
21
|
+
|
|
22
|
+
API_URL = "https://api.manifold.markets/v0"
|
|
23
|
+
API_KEY = os.getenv("MANIFOLD_API_KEY")
|
|
24
|
+
|
|
25
|
+
def headers():
|
|
26
|
+
return {
|
|
27
|
+
"Authorization": f"Key {API_KEY}",
|
|
28
|
+
"Content-Type": "application/json"
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Search Markets
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
def search_markets(query: str, limit: int = 10):
|
|
36
|
+
"""Search for markets"""
|
|
37
|
+
r = requests.get(f"{API_URL}/search-markets", params={
|
|
38
|
+
"term": query,
|
|
39
|
+
"limit": limit,
|
|
40
|
+
"filter": "open",
|
|
41
|
+
"sort": "liquidity"
|
|
42
|
+
})
|
|
43
|
+
r.raise_for_status()
|
|
44
|
+
markets = r.json()
|
|
45
|
+
|
|
46
|
+
for m in markets[:5]:
|
|
47
|
+
prob = m.get("probability", 0.5)
|
|
48
|
+
print(f"\nMarket: {m['question']}")
|
|
49
|
+
print(f"ID: {m['id']}")
|
|
50
|
+
print(f"Probability: {prob*100:.1f}%")
|
|
51
|
+
print(f"URL: {m.get('url', '')}")
|
|
52
|
+
|
|
53
|
+
return markets
|
|
54
|
+
|
|
55
|
+
markets = search_markets("AI")
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Get Market by ID or Slug
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
def get_market(id_or_slug: str):
|
|
62
|
+
"""Get market details"""
|
|
63
|
+
# Try by ID first
|
|
64
|
+
r = requests.get(f"{API_URL}/market/{id_or_slug}")
|
|
65
|
+
if r.status_code == 404:
|
|
66
|
+
# Try by slug
|
|
67
|
+
r = requests.get(f"{API_URL}/slug/{id_or_slug}")
|
|
68
|
+
|
|
69
|
+
r.raise_for_status()
|
|
70
|
+
return r.json()
|
|
71
|
+
|
|
72
|
+
market = get_market("will-gpt5-be-released-before-2025")
|
|
73
|
+
print(f"Question: {market['question']}")
|
|
74
|
+
print(f"Probability: {market.get('probability', 0.5)*100:.1f}%")
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Place a Bet
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
def place_bet(
|
|
81
|
+
market_id: str,
|
|
82
|
+
amount: int, # Mana amount to bet
|
|
83
|
+
outcome: str = "YES", # "YES" or "NO"
|
|
84
|
+
limit_prob: float = None # Optional limit order probability
|
|
85
|
+
):
|
|
86
|
+
"""
|
|
87
|
+
Place a bet on Manifold
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
market_id: The market ID (not slug!)
|
|
91
|
+
amount: Amount of Mana to bet
|
|
92
|
+
outcome: "YES" or "NO"
|
|
93
|
+
limit_prob: Optional - if set, creates a limit order at this probability
|
|
94
|
+
"""
|
|
95
|
+
payload = {
|
|
96
|
+
"contractId": market_id,
|
|
97
|
+
"amount": amount,
|
|
98
|
+
"outcome": outcome
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if limit_prob is not None:
|
|
102
|
+
payload["limitProb"] = limit_prob
|
|
103
|
+
|
|
104
|
+
r = requests.post(f"{API_URL}/bet", headers=headers(), json=payload)
|
|
105
|
+
r.raise_for_status()
|
|
106
|
+
result = r.json()
|
|
107
|
+
|
|
108
|
+
print(f"Bet placed!")
|
|
109
|
+
print(f"Shares: {result.get('shares', 0):.2f}")
|
|
110
|
+
print(f"Probability after: {result.get('probAfter', 0)*100:.1f}%")
|
|
111
|
+
|
|
112
|
+
return result
|
|
113
|
+
|
|
114
|
+
# Market bet - buys at current price
|
|
115
|
+
result = place_bet(
|
|
116
|
+
market_id="abc123",
|
|
117
|
+
amount=100, # 100 Mana
|
|
118
|
+
outcome="YES"
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
# Limit order - only fills at 40% or below
|
|
122
|
+
result = place_bet(
|
|
123
|
+
market_id="abc123",
|
|
124
|
+
amount=100,
|
|
125
|
+
outcome="YES",
|
|
126
|
+
limit_prob=0.40
|
|
127
|
+
)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Cancel Bet (Limit Orders Only)
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
def cancel_bet(bet_id: str):
|
|
134
|
+
"""Cancel a limit order"""
|
|
135
|
+
r = requests.post(f"{API_URL}/bet/cancel/{bet_id}", headers=headers())
|
|
136
|
+
r.raise_for_status()
|
|
137
|
+
return True
|
|
138
|
+
|
|
139
|
+
cancel_bet("bet123")
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Sell Shares
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
def sell_shares(
|
|
146
|
+
market_id: str,
|
|
147
|
+
outcome: str = "YES",
|
|
148
|
+
shares: float = None # None = sell all
|
|
149
|
+
):
|
|
150
|
+
"""
|
|
151
|
+
Sell shares in a market
|
|
152
|
+
|
|
153
|
+
Args:
|
|
154
|
+
market_id: The market ID
|
|
155
|
+
outcome: "YES" or "NO" - which shares to sell
|
|
156
|
+
shares: Number of shares to sell (None = all)
|
|
157
|
+
"""
|
|
158
|
+
payload = {
|
|
159
|
+
"contractId": market_id,
|
|
160
|
+
"outcome": outcome
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if shares is not None:
|
|
164
|
+
payload["shares"] = shares
|
|
165
|
+
|
|
166
|
+
r = requests.post(f"{API_URL}/market/{market_id}/sell", headers=headers(), json=payload)
|
|
167
|
+
r.raise_for_status()
|
|
168
|
+
return r.json()
|
|
169
|
+
|
|
170
|
+
# Sell all YES shares
|
|
171
|
+
sell_shares("abc123", "YES")
|
|
172
|
+
|
|
173
|
+
# Sell specific amount
|
|
174
|
+
sell_shares("abc123", "YES", shares=50.0)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Get Your Bets
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
def get_my_bets(market_id: str = None):
|
|
181
|
+
"""Get your bets"""
|
|
182
|
+
params = {}
|
|
183
|
+
if market_id:
|
|
184
|
+
params["contractId"] = market_id
|
|
185
|
+
|
|
186
|
+
r = requests.get(f"{API_URL}/bets", headers=headers(), params=params)
|
|
187
|
+
r.raise_for_status()
|
|
188
|
+
bets = r.json()
|
|
189
|
+
|
|
190
|
+
for b in bets[:10]:
|
|
191
|
+
print(f"Bet: {b['outcome']} {b['amount']}M @ {b.get('probBefore', 0)*100:.0f}%")
|
|
192
|
+
|
|
193
|
+
return bets
|
|
194
|
+
|
|
195
|
+
bets = get_my_bets()
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Get Your Positions
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
def get_positions():
|
|
202
|
+
"""Get current positions across all markets"""
|
|
203
|
+
# Get user info first
|
|
204
|
+
r = requests.get(f"{API_URL}/me", headers=headers())
|
|
205
|
+
r.raise_for_status()
|
|
206
|
+
user = r.json()
|
|
207
|
+
|
|
208
|
+
# Get bets to calculate positions
|
|
209
|
+
r = requests.get(f"{API_URL}/bets", headers=headers(), params={"limit": 1000})
|
|
210
|
+
bets = r.json()
|
|
211
|
+
|
|
212
|
+
# Aggregate by market
|
|
213
|
+
positions = {}
|
|
214
|
+
for bet in bets:
|
|
215
|
+
mid = bet["contractId"]
|
|
216
|
+
if mid not in positions:
|
|
217
|
+
positions[mid] = {"yes": 0, "no": 0, "invested": 0}
|
|
218
|
+
|
|
219
|
+
if bet["outcome"] == "YES":
|
|
220
|
+
positions[mid]["yes"] += bet.get("shares", 0)
|
|
221
|
+
else:
|
|
222
|
+
positions[mid]["no"] += bet.get("shares", 0)
|
|
223
|
+
|
|
224
|
+
if not bet.get("isSold", False):
|
|
225
|
+
positions[mid]["invested"] += bet["amount"]
|
|
226
|
+
|
|
227
|
+
return positions, user.get("balance", 0)
|
|
228
|
+
|
|
229
|
+
positions, balance = get_positions()
|
|
230
|
+
print(f"Balance: {balance} Mana")
|
|
231
|
+
for mid, pos in positions.items():
|
|
232
|
+
if pos["yes"] > 0 or pos["no"] > 0:
|
|
233
|
+
print(f"Market {mid}: YES={pos['yes']:.1f}, NO={pos['no']:.1f}")
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Get Balance
|
|
237
|
+
|
|
238
|
+
```python
|
|
239
|
+
def get_balance():
|
|
240
|
+
"""Get your Mana balance"""
|
|
241
|
+
r = requests.get(f"{API_URL}/me", headers=headers())
|
|
242
|
+
r.raise_for_status()
|
|
243
|
+
user = r.json()
|
|
244
|
+
return user.get("balance", 0)
|
|
245
|
+
|
|
246
|
+
balance = get_balance()
|
|
247
|
+
print(f"Balance: {balance} Mana")
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## Complete Trading Bot Example
|
|
251
|
+
|
|
252
|
+
```python
|
|
253
|
+
#!/usr/bin/env python3
|
|
254
|
+
"""
|
|
255
|
+
Manifold arbitrage bot - finds mispriced markets
|
|
256
|
+
"""
|
|
257
|
+
|
|
258
|
+
import os
|
|
259
|
+
import time
|
|
260
|
+
import requests
|
|
261
|
+
|
|
262
|
+
API_URL = "https://api.manifold.markets/v0"
|
|
263
|
+
API_KEY = os.getenv("MANIFOLD_API_KEY")
|
|
264
|
+
|
|
265
|
+
def h():
|
|
266
|
+
return {"Authorization": f"Key {API_KEY}", "Content-Type": "application/json"}
|
|
267
|
+
|
|
268
|
+
def search(query):
|
|
269
|
+
r = requests.get(f"{API_URL}/search-markets",
|
|
270
|
+
params={"term": query, "limit": 20, "filter": "open"})
|
|
271
|
+
return r.json()
|
|
272
|
+
|
|
273
|
+
def bet(market_id, amount, outcome, limit_prob=None):
|
|
274
|
+
payload = {"contractId": market_id, "amount": amount, "outcome": outcome}
|
|
275
|
+
if limit_prob:
|
|
276
|
+
payload["limitProb"] = limit_prob
|
|
277
|
+
r = requests.post(f"{API_URL}/bet", headers=h(), json=payload)
|
|
278
|
+
return r.json()
|
|
279
|
+
|
|
280
|
+
def get_balance():
|
|
281
|
+
r = requests.get(f"{API_URL}/me", headers=h())
|
|
282
|
+
return r.json().get("balance", 0)
|
|
283
|
+
|
|
284
|
+
# Strategy: Buy extreme probabilities (likely to revert)
|
|
285
|
+
MIN_LIQUIDITY = 1000 # Only trade liquid markets
|
|
286
|
+
|
|
287
|
+
while True:
|
|
288
|
+
try:
|
|
289
|
+
balance = get_balance()
|
|
290
|
+
print(f"\nBalance: {balance} Mana")
|
|
291
|
+
|
|
292
|
+
# Search trending markets
|
|
293
|
+
markets = search("2024")
|
|
294
|
+
|
|
295
|
+
for m in markets:
|
|
296
|
+
prob = m.get("probability", 0.5)
|
|
297
|
+
liquidity = m.get("totalLiquidity", 0)
|
|
298
|
+
|
|
299
|
+
if liquidity < MIN_LIQUIDITY:
|
|
300
|
+
continue
|
|
301
|
+
|
|
302
|
+
# Buy YES on very low probability (< 10%)
|
|
303
|
+
if prob < 0.10:
|
|
304
|
+
print(f"LOW: {m['question'][:50]} at {prob*100:.1f}%")
|
|
305
|
+
if balance > 50:
|
|
306
|
+
bet(m["id"], 50, "YES", limit_prob=0.15)
|
|
307
|
+
|
|
308
|
+
# Buy NO on very high probability (> 90%)
|
|
309
|
+
elif prob > 0.90:
|
|
310
|
+
print(f"HIGH: {m['question'][:50]} at {prob*100:.1f}%")
|
|
311
|
+
if balance > 50:
|
|
312
|
+
bet(m["id"], 50, "NO", limit_prob=0.85)
|
|
313
|
+
|
|
314
|
+
time.sleep(300) # Check every 5 minutes
|
|
315
|
+
|
|
316
|
+
except Exception as e:
|
|
317
|
+
print(f"Error: {e}")
|
|
318
|
+
time.sleep(60)
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
## Multiple Choice Markets
|
|
322
|
+
|
|
323
|
+
```python
|
|
324
|
+
def bet_multiple_choice(market_id: str, answer_id: str, amount: int):
|
|
325
|
+
"""Bet on a multiple choice market"""
|
|
326
|
+
payload = {
|
|
327
|
+
"contractId": market_id,
|
|
328
|
+
"amount": amount,
|
|
329
|
+
"answerId": answer_id
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
r = requests.post(f"{API_URL}/bet", headers=headers(), json=payload)
|
|
333
|
+
r.raise_for_status()
|
|
334
|
+
return r.json()
|
|
335
|
+
|
|
336
|
+
# Get market with answers
|
|
337
|
+
market = get_market("who-will-win-2024-election")
|
|
338
|
+
for answer in market.get("answers", []):
|
|
339
|
+
print(f"{answer['text']}: {answer['probability']*100:.1f}% (ID: {answer['id']})")
|
|
340
|
+
|
|
341
|
+
# Bet on specific answer
|
|
342
|
+
bet_multiple_choice("market123", "answer456", 100)
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## Create a Market
|
|
346
|
+
|
|
347
|
+
```python
|
|
348
|
+
def create_market(
|
|
349
|
+
question: str,
|
|
350
|
+
description: str = "",
|
|
351
|
+
close_time: int = None, # Unix timestamp
|
|
352
|
+
initial_prob: float = 0.5,
|
|
353
|
+
ante: int = 100 # Initial liquidity
|
|
354
|
+
):
|
|
355
|
+
"""Create a new binary market"""
|
|
356
|
+
payload = {
|
|
357
|
+
"outcomeType": "BINARY",
|
|
358
|
+
"question": question,
|
|
359
|
+
"description": description,
|
|
360
|
+
"initialProb": int(initial_prob * 100),
|
|
361
|
+
"ante": ante
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if close_time:
|
|
365
|
+
payload["closeTime"] = close_time * 1000 # Milliseconds
|
|
366
|
+
|
|
367
|
+
r = requests.post(f"{API_URL}/market", headers=headers(), json=payload)
|
|
368
|
+
r.raise_for_status()
|
|
369
|
+
return r.json()
|
|
370
|
+
|
|
371
|
+
# Create market
|
|
372
|
+
new_market = create_market(
|
|
373
|
+
question="Will it rain tomorrow in NYC?",
|
|
374
|
+
initial_prob=0.3,
|
|
375
|
+
ante=100
|
|
376
|
+
)
|
|
377
|
+
print(f"Created: {new_market['url']}")
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
## Important Notes
|
|
381
|
+
|
|
382
|
+
1. **Mana is play money** - Can be donated to charity
|
|
383
|
+
2. **No limit on bets** - Unlike real money markets
|
|
384
|
+
3. **Market maker AMM** - Prices move based on bets
|
|
385
|
+
4. **Limit orders** - Use `limitProb` for better prices
|
|
386
|
+
5. **API rate limits** - Be gentle, ~60 requests/minute
|
|
387
|
+
6. **Shares ≠ Mana** - Shares vary based on probability
|