瀏覽代碼

[finance] Fix division by zero and no mention on hodl show

Innokentiy Enikeev 5 年之前
父節點
當前提交
140de2feb0
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. 4 3
      plugins/finance.lisp

+ 4 - 3
plugins/finance.lisp

@@ -226,7 +226,7 @@
            (duration (- close-at open-at))
            (income (when close-amount (- close-amount open-amount)))
            (roi (when income (/ income open-amount)))
-           (annual (when roi (* (/ roi duration) (* +day+ 365.25)))))
+           (annual (when (and roi (not (zerop duration))) (* (/ roi duration) (* +day+ 365.25)))))
       `((:row-id . ,row-id)
         (:user-id . ,user-id)
         (:user-name . ,user-name)
@@ -245,7 +245,7 @@
         (:annual . ,annual)))))
 
 (defun print-order-info (idx info)
-  (format nil "~A) @~A: *~A* ~A _~A_ @ *~$* ~A _~A_ @ *~$*, заработал *~$*, ROI *~$*%"
+  (format nil "~A) ~A: *~A* ~A _~A_ @ *~$* ~A _~A_ @ *~$*, заработал *~$*, ROI *~$*%"
           idx
           (agets info :user-name)
           (agets info :amount)
@@ -267,7 +267,8 @@
                                          (loop for order in orders for idx from 1
                                             collect (print-order-info idx (get-order-info order))))
                           "Нет ходлеров :(")
-                      :parse-mode "markdown")))
+                      :parse-mode "markdown"
+                      :disable-notifications 1)))
 
 (defun handle-hodl-buy ()
   (handler-case