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.
Files changed (226) hide show
  1. package/dist/skills/bundled/acp/SKILL.md +188 -0
  2. package/dist/skills/bundled/acp/index.d.ts +0 -3
  3. package/dist/skills/bundled/acp/index.js +1 -1
  4. package/dist/skills/bundled/acp/index.js.map +1 -1
  5. package/dist/skills/bundled/agentbets/SKILL.md +19 -0
  6. package/dist/skills/bundled/ai-strategy/SKILL.md +111 -0
  7. package/dist/skills/bundled/ai-strategy/index.js +1 -1
  8. package/dist/skills/bundled/ai-strategy/index.js.map +1 -1
  9. package/dist/skills/bundled/alerts/SKILL.md +87 -0
  10. package/dist/skills/bundled/analytics/SKILL.md +252 -0
  11. package/dist/skills/bundled/analytics/index.js +2 -2
  12. package/dist/skills/bundled/analytics/index.js.map +1 -1
  13. package/dist/skills/bundled/arbitrage/SKILL.md +287 -0
  14. package/dist/skills/bundled/auto-reply/SKILL.md +285 -0
  15. package/dist/skills/bundled/auto-reply/index.js +2 -2
  16. package/dist/skills/bundled/auto-reply/index.js.map +1 -1
  17. package/dist/skills/bundled/automation/SKILL.md +242 -0
  18. package/dist/skills/bundled/automation/index.js +2 -2
  19. package/dist/skills/bundled/automation/index.js.map +1 -1
  20. package/dist/skills/bundled/backtest/SKILL.md +225 -0
  21. package/dist/skills/bundled/bags/SKILL.md +131 -0
  22. package/dist/skills/bundled/bankr/SKILL.md +114 -0
  23. package/dist/skills/bundled/betfair/SKILL.md +113 -0
  24. package/dist/skills/bundled/binance-futures/SKILL.md +84 -0
  25. package/dist/skills/bundled/binance-futures/index.d.ts +0 -3
  26. package/dist/skills/bundled/binance-futures/index.js +1 -2
  27. package/dist/skills/bundled/binance-futures/index.js.map +1 -1
  28. package/dist/skills/bundled/botchan/SKILL.md +66 -0
  29. package/dist/skills/bundled/botchan/index.d.ts +0 -3
  30. package/dist/skills/bundled/botchan/index.js +0 -1
  31. package/dist/skills/bundled/botchan/index.js.map +1 -1
  32. package/dist/skills/bundled/bridge/SKILL.md +215 -0
  33. package/dist/skills/bundled/bybit-futures/SKILL.md +84 -0
  34. package/dist/skills/bundled/bybit-futures/index.d.ts +0 -3
  35. package/dist/skills/bundled/bybit-futures/index.js +0 -1
  36. package/dist/skills/bundled/bybit-futures/index.js.map +1 -1
  37. package/dist/skills/bundled/clanker/SKILL.md +125 -0
  38. package/dist/skills/bundled/clanker/index.d.ts +0 -3
  39. package/dist/skills/bundled/clanker/index.js +0 -1
  40. package/dist/skills/bundled/clanker/index.js.map +1 -1
  41. package/dist/skills/bundled/copy-trading/SKILL.md +285 -0
  42. package/dist/skills/bundled/copy-trading/index.js +2 -2
  43. package/dist/skills/bundled/copy-trading/index.js.map +1 -1
  44. package/dist/skills/bundled/copy-trading-solana/SKILL.md +66 -0
  45. package/dist/skills/bundled/credentials/SKILL.md +261 -0
  46. package/dist/skills/bundled/crypto-hft/SKILL.md +121 -0
  47. package/dist/skills/bundled/dca/SKILL.md +27 -0
  48. package/dist/skills/bundled/dex/SKILL.md +87 -0
  49. package/dist/skills/bundled/divergence/SKILL.md +83 -0
  50. package/dist/skills/bundled/doctor/SKILL.md +267 -0
  51. package/dist/skills/bundled/doctor/index.js +2 -8
  52. package/dist/skills/bundled/doctor/index.js.map +1 -1
  53. package/dist/skills/bundled/drift/SKILL.md +53 -0
  54. package/dist/skills/bundled/drift-sdk/SKILL.md +103 -0
  55. package/dist/skills/bundled/drift-sdk/index.d.ts +0 -3
  56. package/dist/skills/bundled/drift-sdk/index.js +0 -1
  57. package/dist/skills/bundled/drift-sdk/index.js.map +1 -1
  58. package/dist/skills/bundled/edge/SKILL.md +84 -0
  59. package/dist/skills/bundled/embeddings/SKILL.md +244 -0
  60. package/dist/skills/bundled/endaoment/SKILL.md +65 -0
  61. package/dist/skills/bundled/endaoment/index.d.ts +0 -3
  62. package/dist/skills/bundled/endaoment/index.js +0 -1
  63. package/dist/skills/bundled/endaoment/index.js.map +1 -1
  64. package/dist/skills/bundled/ens/SKILL.md +63 -0
  65. package/dist/skills/bundled/ens/index.d.ts +0 -3
  66. package/dist/skills/bundled/ens/index.js +0 -1
  67. package/dist/skills/bundled/ens/index.js.map +1 -1
  68. package/dist/skills/bundled/erc8004/SKILL.md +79 -0
  69. package/dist/skills/bundled/erc8004/index.d.ts +0 -3
  70. package/dist/skills/bundled/erc8004/index.js +0 -1
  71. package/dist/skills/bundled/erc8004/index.js.map +1 -1
  72. package/dist/skills/bundled/execution/SKILL.md +278 -0
  73. package/dist/skills/bundled/farcaster/SKILL.md +80 -0
  74. package/dist/skills/bundled/features/SKILL.md +20 -0
  75. package/dist/skills/bundled/feeds/SKILL.md +288 -0
  76. package/dist/skills/bundled/harden/SKILL.md +74 -0
  77. package/dist/skills/bundled/history/SKILL.md +257 -0
  78. package/dist/skills/bundled/hyperliquid/SKILL.md +200 -0
  79. package/dist/skills/bundled/hyperliquid/index.d.ts +0 -3
  80. package/dist/skills/bundled/hyperliquid/index.js +0 -1
  81. package/dist/skills/bundled/hyperliquid/index.js.map +1 -1
  82. package/dist/skills/bundled/identity/SKILL.md +228 -0
  83. package/dist/skills/bundled/identity/index.js +2 -2
  84. package/dist/skills/bundled/identity/index.js.map +1 -1
  85. package/dist/skills/bundled/integrations/SKILL.md +321 -0
  86. package/dist/skills/bundled/integrations/index.js +2 -2
  87. package/dist/skills/bundled/integrations/index.js.map +1 -1
  88. package/dist/skills/bundled/jupiter/SKILL.md +163 -0
  89. package/dist/skills/bundled/kamino/SKILL.md +69 -0
  90. package/dist/skills/bundled/ledger/SKILL.md +20 -0
  91. package/dist/skills/bundled/lighter/SKILL.md +83 -0
  92. package/dist/skills/bundled/lighter/index.d.ts +0 -3
  93. package/dist/skills/bundled/lighter/index.js +0 -1
  94. package/dist/skills/bundled/lighter/index.js.map +1 -1
  95. package/dist/skills/bundled/marginfi/SKILL.md +62 -0
  96. package/dist/skills/bundled/market-index/SKILL.md +242 -0
  97. package/dist/skills/bundled/market-index/index.js +1 -3
  98. package/dist/skills/bundled/market-index/index.js.map +1 -1
  99. package/dist/skills/bundled/markets/SKILL.md +49 -0
  100. package/dist/skills/bundled/mcp/SKILL.md +235 -0
  101. package/dist/skills/bundled/mcp/index.js +1 -3
  102. package/dist/skills/bundled/mcp/index.js.map +1 -1
  103. package/dist/skills/bundled/memory/SKILL.md +209 -0
  104. package/dist/skills/bundled/metaculus/SKILL.md +62 -0
  105. package/dist/skills/bundled/meteora/SKILL.md +28 -0
  106. package/dist/skills/bundled/meteora-dbc/SKILL.md +25 -0
  107. package/dist/skills/bundled/metrics/SKILL.md +338 -0
  108. package/dist/skills/bundled/mev/SKILL.md +239 -0
  109. package/dist/skills/bundled/mev/index.js +2 -2
  110. package/dist/skills/bundled/mev/index.js.map +1 -1
  111. package/dist/skills/bundled/mexc-futures/SKILL.md +86 -0
  112. package/dist/skills/bundled/mexc-futures/index.d.ts +0 -3
  113. package/dist/skills/bundled/mexc-futures/index.js +0 -1
  114. package/dist/skills/bundled/mexc-futures/index.js.map +1 -1
  115. package/dist/skills/bundled/mm/SKILL.md +142 -0
  116. package/dist/skills/bundled/monitoring/SKILL.md +249 -0
  117. package/dist/skills/bundled/news/SKILL.md +95 -0
  118. package/dist/skills/bundled/onchainkit/SKILL.md +83 -0
  119. package/dist/skills/bundled/opinion/SKILL.md +87 -0
  120. package/dist/skills/bundled/opportunity/SKILL.md +308 -0
  121. package/dist/skills/bundled/orca/SKILL.md +28 -0
  122. package/dist/skills/bundled/pairing/SKILL.md +275 -0
  123. package/dist/skills/bundled/pancakeswap/SKILL.md +93 -0
  124. package/dist/skills/bundled/pancakeswap/index.d.ts +0 -3
  125. package/dist/skills/bundled/pancakeswap/index.js +0 -1
  126. package/dist/skills/bundled/pancakeswap/index.js.map +1 -1
  127. package/dist/skills/bundled/percolator/SKILL.md +22 -0
  128. package/dist/skills/bundled/permissions/SKILL.md +269 -0
  129. package/dist/skills/bundled/permissions/index.js +2 -2
  130. package/dist/skills/bundled/permissions/index.js.map +1 -1
  131. package/dist/skills/bundled/plugins/SKILL.md +263 -0
  132. package/dist/skills/bundled/plugins/index.js +2 -2
  133. package/dist/skills/bundled/plugins/index.js.map +1 -1
  134. package/dist/skills/bundled/portfolio/SKILL.md +161 -0
  135. package/dist/skills/bundled/portfolio/index.js +1 -1
  136. package/dist/skills/bundled/portfolio/index.js.map +1 -1
  137. package/dist/skills/bundled/portfolio-sync/SKILL.md +466 -0
  138. package/dist/skills/bundled/positions/SKILL.md +262 -0
  139. package/dist/skills/bundled/predictfun/SKILL.md +109 -0
  140. package/dist/skills/bundled/predictfun/index.js +1 -1
  141. package/dist/skills/bundled/predictfun/index.js.map +1 -1
  142. package/dist/skills/bundled/predictit/SKILL.md +66 -0
  143. package/dist/skills/bundled/presence/SKILL.md +217 -0
  144. package/dist/skills/bundled/presence/index.js +2 -2
  145. package/dist/skills/bundled/presence/index.js.map +1 -1
  146. package/dist/skills/bundled/processes/SKILL.md +254 -0
  147. package/dist/skills/bundled/pump-swarm/SKILL.md +309 -0
  148. package/dist/skills/bundled/pumpfun/SKILL.md +145 -0
  149. package/dist/skills/bundled/qmd/SKILL.md +129 -0
  150. package/dist/skills/bundled/qrcoin/SKILL.md +60 -0
  151. package/dist/skills/bundled/qrcoin/index.d.ts +0 -3
  152. package/dist/skills/bundled/qrcoin/index.js +0 -1
  153. package/dist/skills/bundled/qrcoin/index.js.map +1 -1
  154. package/dist/skills/bundled/raydium/SKILL.md +198 -0
  155. package/dist/skills/bundled/remote/SKILL.md +201 -0
  156. package/dist/skills/bundled/research/SKILL.md +83 -0
  157. package/dist/skills/bundled/research/index.js +2 -2
  158. package/dist/skills/bundled/research/index.js.map +1 -1
  159. package/dist/skills/bundled/risk/SKILL.md +323 -0
  160. package/dist/skills/bundled/router/SKILL.md +233 -0
  161. package/dist/skills/bundled/routing/SKILL.md +258 -0
  162. package/dist/skills/bundled/sandbox/SKILL.md +257 -0
  163. package/dist/skills/bundled/search-config/SKILL.md +257 -0
  164. package/dist/skills/bundled/search-config/index.js +2 -2
  165. package/dist/skills/bundled/search-config/index.js.map +1 -1
  166. package/dist/skills/bundled/sessions/SKILL.md +251 -0
  167. package/dist/skills/bundled/sessions/index.js +1 -1
  168. package/dist/skills/bundled/sessions/index.js.map +1 -1
  169. package/dist/skills/bundled/setup/SKILL.md +53 -0
  170. package/dist/skills/bundled/shield/SKILL.md +21 -0
  171. package/dist/skills/bundled/signals/SKILL.md +106 -0
  172. package/dist/skills/bundled/signals/index.d.ts +0 -3
  173. package/dist/skills/bundled/signals/index.js +3 -4
  174. package/dist/skills/bundled/signals/index.js.map +1 -1
  175. package/dist/skills/bundled/sizing/SKILL.md +238 -0
  176. package/dist/skills/bundled/slippage/SKILL.md +306 -0
  177. package/dist/skills/bundled/smarkets/SKILL.md +107 -0
  178. package/dist/skills/bundled/solend/SKILL.md +63 -0
  179. package/dist/skills/bundled/strategy/SKILL.md +266 -0
  180. package/dist/skills/bundled/streaming/SKILL.md +150 -0
  181. package/dist/skills/bundled/streaming/index.js +2 -2
  182. package/dist/skills/bundled/streaming/index.js.map +1 -1
  183. package/dist/skills/bundled/tailscale/SKILL.md +249 -0
  184. package/dist/skills/bundled/tailscale/index.js +2 -2
  185. package/dist/skills/bundled/tailscale/index.js.map +1 -1
  186. package/dist/skills/bundled/ticks/SKILL.md +61 -0
  187. package/dist/skills/bundled/token-security/SKILL.md +18 -0
  188. package/dist/skills/bundled/trading-evm/SKILL.md +329 -0
  189. package/dist/skills/bundled/trading-futures/SKILL.md +865 -0
  190. package/dist/skills/bundled/trading-kalshi/SKILL.md +629 -0
  191. package/dist/skills/bundled/trading-manifold/SKILL.md +387 -0
  192. package/dist/skills/bundled/trading-polymarket/SKILL.md +1080 -0
  193. package/dist/skills/bundled/trading-solana/SKILL.md +418 -0
  194. package/dist/skills/bundled/trading-system/SKILL.md +290 -0
  195. package/dist/skills/bundled/triggers/SKILL.md +433 -0
  196. package/dist/skills/bundled/tts/SKILL.md +220 -0
  197. package/dist/skills/bundled/tweet-ideas/SKILL.md +77 -0
  198. package/dist/skills/bundled/usage/SKILL.md +239 -0
  199. package/dist/skills/bundled/usage/index.js +2 -2
  200. package/dist/skills/bundled/usage/index.js.map +1 -1
  201. package/dist/skills/bundled/veil/SKILL.md +76 -0
  202. package/dist/skills/bundled/veil/index.d.ts +0 -3
  203. package/dist/skills/bundled/veil/index.js +0 -1
  204. package/dist/skills/bundled/veil/index.js.map +1 -1
  205. package/dist/skills/bundled/verify/SKILL.md +199 -0
  206. package/dist/skills/bundled/verify/index.d.ts +0 -3
  207. package/dist/skills/bundled/verify/index.js +0 -1
  208. package/dist/skills/bundled/verify/index.js.map +1 -1
  209. package/dist/skills/bundled/virtuals/SKILL.md +82 -0
  210. package/dist/skills/bundled/voice/SKILL.md +217 -0
  211. package/dist/skills/bundled/voice/index.js +2 -2
  212. package/dist/skills/bundled/voice/index.js.map +1 -1
  213. package/dist/skills/bundled/weather/SKILL.md +80 -0
  214. package/dist/skills/bundled/webhooks/SKILL.md +297 -0
  215. package/dist/skills/bundled/webhooks/index.js +2 -2
  216. package/dist/skills/bundled/webhooks/index.js.map +1 -1
  217. package/dist/skills/bundled/whale-tracking/SKILL.md +287 -0
  218. package/dist/skills/bundled/whale-tracking/index.js +2 -2
  219. package/dist/skills/bundled/whale-tracking/index.js.map +1 -1
  220. package/dist/skills/bundled/yoink/SKILL.md +54 -0
  221. package/dist/skills/bundled/yoink/index.d.ts +0 -3
  222. package/dist/skills/bundled/yoink/index.js +0 -1
  223. package/dist/skills/bundled/yoink/index.js.map +1 -1
  224. package/dist/skills/executor.js +5 -3
  225. package/dist/skills/executor.js.map +1 -1
  226. 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