Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

consider only 1 order from each counterparty before choosing #266

Merged
merged 1 commit into from
Oct 12, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down