{"slug":"selling-mutual-funds-at-a-loss","qid":"dca_lots","label":"A monthly buyer's lot prices and running average cost: VTI, July 2021 to December 2022","post_title":"Selling Mutual Funds at a Loss: How Basis Works","post_url":"/blog/selling-mutual-funds-at-a-loss#q-dca_lots","columns":["month","month_label","lot_price_usd","average_cost_usd"],"rows":[{"month":"2021-07","month_label":"July 2021","lot_price_usd":226.72,"average_cost_usd":226.72},{"month":"2021-08","month_label":"August 2021","lot_price_usd":233.17,"average_cost_usd":229.94},{"month":"2021-09","month_label":"September 2021","lot_price_usd":222.03,"average_cost_usd":227.31},{"month":"2021-10","month_label":"October 2021","lot_price_usd":236.92,"average_cost_usd":229.71},{"month":"2021-11","month_label":"November 2021","lot_price_usd":233.47,"average_cost_usd":230.46},{"month":"2021-12","month_label":"December 2021","lot_price_usd":241.48,"average_cost_usd":232.3},{"month":"2022-01","month_label":"January 2022","lot_price_usd":226.82,"average_cost_usd":231.52},{"month":"2022-02","month_label":"February 2022","lot_price_usd":221.16,"average_cost_usd":230.22},{"month":"2022-03","month_label":"March 2022","lot_price_usd":227.76,"average_cost_usd":229.95},{"month":"2022-04","month_label":"April 2022","lot_price_usd":207.14,"average_cost_usd":227.67},{"month":"2022-05","month_label":"May 2022","lot_price_usd":206.57,"average_cost_usd":225.75},{"month":"2022-06","month_label":"June 2022","lot_price_usd":188.74,"average_cost_usd":222.66},{"month":"2022-07","month_label":"July 2022","lot_price_usd":206.28,"average_cost_usd":221.4},{"month":"2022-08","month_label":"August 2022","lot_price_usd":198.56,"average_cost_usd":219.77},{"month":"2022-09","month_label":"September 2022","lot_price_usd":179.37,"average_cost_usd":217.08},{"month":"2022-10","month_label":"October 2022","lot_price_usd":194,"average_cost_usd":215.64},{"month":"2022-11","month_label":"November 2022","lot_price_usd":204.07,"average_cost_usd":214.96},{"month":"2022-12","month_label":"December 2022","lot_price_usd":191.25,"average_cost_usd":213.64}],"shape":"series","sql":"WITH monthly AS (\n    SELECT toStartOfMonth(toDate(toTimeZone(window_start, 'America/New_York'))) AS month_start,\n           argMax(close, window_start) AS close_price\n    FROM global_markets.delayed_stocks_minute_aggs\n    WHERE ticker = 'VTI'\n      AND toDate(toTimeZone(window_start, 'America/New_York')) >= toDate('2021-07-01')\n      AND toDate(toTimeZone(window_start, 'America/New_York')) <= toDate('2022-12-31')\n      AND (toHour(toTimeZone(window_start, 'America/New_York')) * 60\n           + toMinute(toTimeZone(window_start, 'America/New_York'))) BETWEEN 570 AND 959\n    GROUP BY month_start\n)\nSELECT formatDateTime(month_start, '%Y-%m') AS month,\n       formatDateTimeInJodaSyntax(month_start, 'MMMM yyyy') AS month_label,\n       round(close_price, 2) AS lot_price_usd,\n       round(avg(close_price) OVER (ORDER BY month_start\n             ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW), 2) AS average_cost_usd\nFROM monthly\nORDER BY month_start","computed_at":"2026-08-01T08:03:24.815670+00:00","elapsed":0.003157532}