Scored based on total dollar volume of identical-direction trades made within one hour.
[ higher of 0 or the net amount traded in the same direction as the user, by any other users, in the hour after trading in any given market; ]
Jul 15, 11:22pm: Clone script (Python):
## Place API key in key.txt
## SET THESE PARAMETERS:
CLONE = {'Jack': 1/200, } #'Olivia': 1/30,}# 'Gigacasting': 1/3}
TIME_LIMIT = 60 * 60 * 1e3; PRICE_LIMIT = 0.03
##
import requests, json, time, zlib, pickle, shutil
from collections import defaultdict
URL = 'http://manifold.markets/api/v0'
API_KEY = open('key.txt', 'r').read().split('\n')[0]
def getMarkets():
markets = []; prior = None
for i in range(100):
try: m = requests.get(URL + '/markets',
params = {'before': prior} if prior else {}).json()
except: break
if len(m) == 0: break;
markets.extend(m)
prior = m[-1]['id']
return markets
markets = getMarkets()
try: cache = pickle.load(open('cache.pkl', 'rb'))
except:
try: cache = pickle.load(open('cache.pkl.backups', 'rb'))
except: pass
print(len(cache))
errs = defaultdict(int); errs['YVDsNCQWr7hUrAiFiKIV'] = 5
def updateMarket(m):
if errs.get(m['id'], 0) >= 3: return
try:
r = requests.get(URL + '/market/{}'.format(m['id']) ).json()
print('updated {}'.format(r['question']))
cache['market/' + m['id']] = zlib.compress(json.dumps(r, sort_keys = True).encode('utf-8'))
except Exception as e:
errs[m['id']] += 1; print(e); time.sleep(0.1)
def updateMarkets():
markets = getMarkets()
for m in markets:
c = cache.get('market/' + m['id'], None)
try: c = json.loads(zlib.decompress(c))
except: updateMarket(m); continue;
if c['volume'] != m['volume']:
updateMarket(m)
try: shutil.copy('cache.pkl', 'cache.pkl.backup')
except: pass;
pickle.dump(cache, open('cache.pkl', 'wb'))
updateMarkets()
users = requests.get(URL + '/users').json()
uids = {u['id']: (u['name'], CLONE.get(u['name']))
for u in users if CLONE.get(u['name'], False)}
for k, v in uids.items(): print(k, v)#print(uids)
max_time = max([ max([b['createdTime'] for b in json.loads(zlib.decompress(v))['bets']] + [0])
for k, v in cache.items()])
s = set(); a = set()
def runTrades():
for k, v in cache.items():
m = json.loads(zlib.decompress(v))
if m['outcomeType'] != 'BINARY': continue;
bets = m['bets'][::-1];
if len(bets) == 0: continue;
last = bets[0]['probAfter']
for b in bets:
if b['userId'] in uids and b['createdTime'] > max_time - TIME_LIMIT:
if b['id'] in s: break;
if b.get('isRedemption', False): continue;
cid, o, amt = b['contractId'], b['outcome'], b['amount']
u = uids[b['userId']]
if amt < 0: amt = abs(amt); o = {'YES': 'NO', 'NO': 'YES'}[o]
if (last - b['probAfter']) * (1 if o == 'YES' else -1) > PRICE_LIMIT:
if b['id'] not in a: print('price past limit for ', m['question'], u[0], o, int(round(amt))); a.add(b['id']);
continue;
ramt = int(round(amt)); amt = int(round(amt * u[1]));
if amt < 1: continue;
print('\nTrading', m['question'], o, amt, '\n from', u[0], o, ramt, ); s.add(b['id'])
try: submit(cid, o, amt);
except Exception as e: print(e)
print()
def submit(cid, o, amt):
r = requests.post(URL + '/bet',
json = {'contractId': cid, 'outcome': o, 'amount': amt, },
headers = {'Authorization': 'Key {}'.format(API_KEY)});
try: c = json.loads(r.content); print(' ', c); s.add(c['betId']);
except: print(r.status_code, r.content)
while True:
updateMarkets()
runTrades()
time.sleep(1);
Jul 15, 11:25pm: Inputs are the display name and clone ratio (e.g. 1/50 = M$1 per M$50 the user trades) for as many users as you'd like; and a time and price slippage limit (currently 60 minutes, *AND* no more than 3% price move);
Market will resolve the % fraction of total volume by user, for anyone with a >1% total share.
Jul 15, 11:29pm: [fine print: all 'follow-ons' are capped at the user's net activity; e.g. if you bet M$1 and others trade M$30 the same way, it counts as M$1; if you buy M$50 and sell M$50, capped at M$0; code to be released in the future, and will count all activity regardless of intent]
Jul 15, 11:32pm: [[[correction:
.....
except:
try: cache = pickle.load(open('cache.pkl.backups', 'rb'))
except: cache = {}
print(len(cache))
.....
]]]
Jul 16, 12:13am: Prior 30-day rankings with more egalitarian settings (M$1000 cap per market, M$200 cap per market-hour ):
TOP 25, Quadratic Scaling, Final Resolution would be:
Gurkenglas 0.261268
Pepe 0.128643
John Beshir 0.120275
Undox 0.078754
S G 0.058789
Michael Wheatley 0.047862
Jack 0.043325
Yev 0.033564
Predictor ๐ฅ 0.024368
Martin Randall 0.018564
BTE 0.017863
Gigacasting 0.015660
Matt P 0.015248
Gabrielle 0.013968
Duncan 0.013133
Austin 0.013100
George Vii 0.012721
Adrian 0.011645
Joel Becker 0.011523
Em of the Night 0.010374
[the main effect was to remove the up-arrow/down-arrow market from completely dominating rankings]
Let the copy-trading (natural or algorithmic) begin!