def find_optimal_trading_opportunities(candidates=None, back_out=False): global FETCH_DELAY global VERBOSE old_delay = FETCH_DELAY FETCH_DELAY = 5 if candidates == None: candidates = sorted(list(opinions.keys())) else: VERBOSE = True # (my_final_score, credit, final_standing, estdeb, s) output = [ ] for candidate in candidates: if am_i_the_last_trade(fetch_question(candidate)): continue res = optimal_adjustment(candidate, back_out=back_out) if res: output.append(res) output.sort(key=lambda x: x[3], reverse=True) for score, credit, final_standing, estdeb, v, steps in output: if estdeb > 0.666 or VERBOSE: print v FETCH_DELAY = old_delay VERBOSE = False
elif stop<=0.001: stop = 0.001 true = 100.0 * math.log(start / stop) / math.log(2.0) #false = 100.0 * math.log((1.0-start) / (1.0-stop)) / math.log(2.0) if abs(true) < 0.001: true = 0.001 #if abs(false) < 0.001: # false = 0.001 return true opportunities = set([]) if options.show_trading: print print "************ TRADING OPPORTUNITIES" msgs = [ ] for qid in opinions.keys(): if not by_id.has_key(qid): continue q = by_id[qid] if q['question']['settlement_at'] == None: settled_at = datetime(2050,1,1,0,0,0) else: settled_at = datetime.strptime(q['question']['settlement_at'][0:19], "%Y-%m-%dT%H:%M:%S") remaining = (settled_at - datetime.now()).total_seconds() / 86400.0 required_gain = 500.0 if remaining < 0: continue elif remaining < 1: required_gain = 0.5
stop = 0.001 true = 100.0 * math.log(start / stop) / math.log(2.0) #false = 100.0 * math.log((1.0-start) / (1.0-stop)) / math.log(2.0) if abs(true) < 0.001: true = 0.001 #if abs(false) < 0.001: # false = 0.001 return true opportunities = set([]) if options.show_trading: print print "************ TRADING OPPORTUNITIES" msgs = [] for qid in opinions.keys(): if not by_id.has_key(qid): continue q = by_id[qid] if q['question']['settlement_at'] == None: settled_at = datetime(2050, 1, 1, 0, 0, 0) else: settled_at = datetime.strptime( q['question']['settlement_at'][0:19], "%Y-%m-%dT%H:%M:%S") remaining = (settled_at - datetime.now()).total_seconds() / 86400.0 required_gain = 500.0 if remaining < 0: continue elif remaining < 1: