From f6b8e6b389e3533f0e526248875e979a5629c00a Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Sun, 11 Oct 2015 00:05:18 +0300 Subject: [PATCH] consider only 1 order from each counterparty before choosing --- lib/common.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/common.py b/lib/common.py index 722b1c89..03338914 100644 --- a/lib/common.py +++ b/lib/common.py @@ -532,7 +532,14 @@ def choose_orders(db, cj_amount, n, chooseOrdersBy, ignored_makers=[]): debug('ERROR not enough liquidity in the orderbook n=%d suitable-counterparties=%d amount=%d totalorders=%d' % (n, len(counterparties), cj_amount, len(orders))) return None, 0 #TODO handle not enough liquidity better, maybe an Exception - orders = sorted(orders, key=lambda k: k[2]) #sort from smallest to biggest cj fee + #restrict to one order per counterparty, choose the one with the lowest cjfee + #this is done in advance of the order selection algo, so applies to all of them. + #however, if orders are picked manually, allow duplicates. + if chooseOrdersBy != pick_order: + orders = dict((v[0],v) for v in sorted(orders, key=lambda k: k[2], reverse=True)).values() + else: + orders = sorted(orders, key=lambda k: k[2]) #sort from smallest to biggest cj fee + debug('considered orders = \n' + '\n'.join([str(o) for o in orders])) total_cj_fee = 0 chosen_orders = []