Index: src/engine/cap-gains.c
===================================================================
--- src/engine/cap-gains.c	(revision 16576)
+++ src/engine/cap-gains.c	(working copy)
@@ -168,7 +168,7 @@
 static inline GNCLot *
 xaccAccountFindOpenLot (Account *acc, gnc_numeric sign, 
    gnc_commodity *currency,
-   guint64 guess,
+   gint64 guess,
    gboolean (*date_pred)(Timespec, Timespec))
 {
    struct find_lot_s es;
@@ -195,7 +195,7 @@
           sign.denom);
       
    lot = xaccAccountFindOpenLot (acc, sign, currency,
-                   G_MAXUINT64, earliest_pred);
+                   G_MAXINT64, earliest_pred);
    LEAVE ("found lot=%p %s baln=%s", lot, gnc_lot_get_title (lot),
                gnc_num_dbg_to_string(gnc_lot_get_balance(lot)));
    return lot;
@@ -210,7 +210,7 @@
 	  sign.num, sign.denom);
       
    lot = xaccAccountFindOpenLot (acc, sign, currency,
-                   0, latest_pred);
+                   G_MININT64, latest_pred);
    LEAVE ("found lot=%p %s", lot, gnc_lot_get_title (lot));
    return lot;
 }
