         "Thhe transaction is valid")))
 
 (deftest selling-a-commodity-increases-the-balance-of-the-account
-  (is false "need to write the test"))
+  (let [context (serialization/realize storage-spec purchase-context)
+        ira (-> context :accounts first)
+        commodity (-> context :commodities first)
+        _ (trading/buy storage-spec {:commodity-id (:id commodity)
+                                     :account-id (:id ira)
+                                     :trade-date (t/local-date 2016 1 2)
+                                     :shares 100M
+                                     :value 1000M})
+        _ (trading/sell storage-spec {:commodity-id (:id commodity)
+                                      :account-id (:id ira)
+                                      :trade-date (t/local-date 2017 1 2)
+                                      :shares 50M
+                                      :value 560M})
+        new-balance (->> (accounts/reload storage-spec ira)
+                         :balance)]
+    (is (= 1560M new-balance) "The account balance decreases by the amount of the purchase")))
 
 ; Selling a commodity updates a lot record (FILO updates the most recent, FIFO updates the oldest)
 ; Selling a commodity creates a lot transaction record

                    (prices/select-by-commodity-id storage-spec (:id commodity)))]
    (is (= expected actual) "The price can be retrieved from the database")))

(def ^:private sell-context
  (-> purchase-context
      (merge {:lots [{:commodity-id "APPL"

                                                      {:action :debit
                                                       :amount 1000M
                                                       :account-id "APPL"}]}]))))

(deftest sell-a-commodity
  (let [context (serialization/realize storage-spec sell-context)
