SiamCafe · Blog
Time Value of Money ในการจัดการการเงิน —
การเงิน การลงทุน และทองคำ

Time Value of Money ในการจัดการการเงิน —

เผยแพร่ May 28, 2026

Time Value of Money คืออะไร

Time Value of Money ในการจัดการการเงิน —

Time Value of Money (TVM) หรือมูลค่าเงินตามเวลา เป็นแนวคิดพื้นฐานที่สำคัญที่สุดในการเงิน หลักการง่ายๆคือ เงิน 1 บาทวันนี้มีมูลค่ามากกว่าเงิน 1 บาทในอนาคต เพราะเงินวันนี้สามารถนำไปลงทุนสร้างผลตอบแทนได้

TVM เป็นพื้นฐานของการวิเคราะห์การลงทุน การคำนวณสินเชื่อ การวางแผนเกษียณ การประเมินมูลค่าธุรกิจ และการตัดสินใจทางการเงินทุกประเภท สูตรหลักที่ต้องรู้คือ Present Value (PV), Future Value (FV), Annuity, NPV และ IRR

แนวคิดสูตรใช้เมื่อ
Future ValueFV = PV × (1+r)^nคำนวณเงินในอนาคต
Present ValuePV = FV / (1+r)^nคำนวณมูลค่าปัจจุบัน
Annuity PVPV = PMT × [1-(1+r)^-n] / rสินเชื่อ ค่างวด
Annuity FVFV = PMT × [(1+r)^n - 1] / rการออมสม่ำเสมอ
NPVNPV = Σ CF_t / (1+r)^tประเมินโครงการ
IRRNPV = 0 → หา rอัตราผลตอบแทน

Python — TVM Calculator

# tvm_calculator.py — Time Value of Money Calculator
import numpy as np
from dataclasses import dataclass
from typing import List, Optional

class TVMCalculator:
    """คำนวณ Time Value of Money"""

    @staticmethod
    def future_value(pv: float, rate: float, periods: int,
                     compounding: int = 1) -> float:
        """Future Value — มูลค่าอนาคต
        pv: เงินต้น
        rate: อัตราดอกเบี้ยต่อปี (เช่น 0.05 = 5%)
        periods: จำนวนปี
        compounding: จำนวนครั้งที่ทบต้นต่อปี (1=ปีละครั้ง, 12=รายเดือน)
        """
        r = rate / compounding
        n = periods * compounding
        return pv * (1 + r) ** n

    @staticmethod
    def present_value(fv: float, rate: float, periods: int,
                      compounding: int = 1) -> float:
        """Present Value — มูลค่าปัจจุบัน"""
        r = rate / compounding
        n = periods * compounding
        return fv / (1 + r) ** n

    @staticmethod
    def annuity_pv(pmt: float, rate: float, periods: int) -> float:
        """Present Value of Annuity — มูลค่าปัจจุบันของเงินงวด"""
        if rate == 0:
            return pmt * periods
        return pmt * (1 - (1 + rate) ** (-periods)) / rate

    @staticmethod
    def annuity_fv(pmt: float, rate: float, periods: int) -> float:
        """Future Value of Annuity — มูลค่าอนาคตของเงินออม"""
        if rate == 0:
            return pmt * periods
        return pmt * ((1 + rate) ** periods - 1) / rate

    @staticmethod
    def loan_payment(principal: float, rate: float, periods: int) -> float:
        """คำนวณค่างวดสินเชื่อ (PMT)"""
        if rate == 0:
            return principal / periods
        return principal * rate / (1 - (1 + rate) ** (-periods))

    @staticmethod
    def npv(rate: float, cash_flows: List[float]) -> float:
        """Net Present Value"""
        return sum(cf / (1 + rate) ** t
                   for t, cf in enumerate(cash_flows))

    @staticmethod
    def irr(cash_flows: List[float], guess: float = 0.1,
            tolerance: float = 1e-8, max_iter: int = 1000) -> float:
        """Internal Rate of Return (Newton's Method)"""
        rate = guess

        for _ in range(max_iter):
            npv = sum(cf / (1 + rate) ** t
                      for t, cf in enumerate(cash_flows))
            dnpv = sum(-t * cf / (1 + rate) ** (t + 1)
                       for t, cf in enumerate(cash_flows))

            if abs(dnpv) < 1e-12:
                break

            new_rate = rate - npv / dnpv

            if abs(new_rate - rate) < tolerance:
                return new_rate

            rate = new_rate

        return rate

    @staticmethod
    def payback_period(cash_flows: List[float]) -> float:
        """Payback Period — ระยะเวลาคืนทุน"""
        cumulative = 0
        for t, cf in enumerate(cash_flows):
            cumulative += cf
            if cumulative >= 0:
                # Interpolate
                prev_cum = cumulative - cf
                return t + abs(prev_cum) / cf if cf != 0 else t
        return float("inf")

# === ตัวอย่างการใช้งาน ===
calc = TVMCalculator()

# 1. Future Value — ฝากเงิน 100,000 บาท ดอกเบี้ย 5% 10 ปี
fv = calc.future_value(100000, 0.05, 10)
print(f"1. Future Value: {fv:,.2f} บาท")

# 2. Present Value — ต้องการ 1,000,000 ใน 20 ปี ดอกเบี้ย 6%
pv = calc.present_value(1000000, 0.06, 20)
print(f"2. Present Value: {pv:,.2f} บาท")

# 3. ออมเดือนละ 5,000 ดอกเบี้ย 7%/ปี 30 ปี
fv_annuity = calc.annuity_fv(5000, 0.07/12, 30*12)
print(f"3. Retirement Fund: {fv_annuity:,.2f} บาท")

# 4. สินเชื่อบ้าน 3,000,000 ดอกเบี้ย 5.5% 25 ปี
pmt = calc.loan_payment(3000000, 0.055/12, 25*12)
print(f"4. Monthly Payment: {pmt:,.2f} บาท")

# 5. NPV — ลงทุน 1M ได้ Cash Flow 300K/ปี 5 ปี
cash_flows = [-1000000, 300000, 350000, 400000, 350000, 300000]
npv_result = calc.npv(0.10, cash_flows)
print(f"5. NPV (10%): {npv_result:,.2f} บาท")

# 6. IRR
irr_result = calc.irr(cash_flows)
print(f"6. IRR: {irr_result:.2%}")

# 7. Payback Period
pp = calc.payback_period(cash_flows)
print(f"7. Payback Period: {pp:.1f} ปี")

Loan Amortization Schedule

Time Value of Money ในการจัดการการเงิน —
# loan_amortization.py — ตารางผ่อนชำระสินเชื่อ

class LoanAmortization:
    """สร้างตารางผ่อนชำระสินเชื่อ"""

    def __init__(self, principal, annual_rate, years):
        self.principal = principal
        self.monthly_rate = annual_rate / 12
        self.months = years * 12
        self.monthly_payment = self._calc_payment()

    def _calc_payment(self):
        r = self.monthly_rate
        n = self.months
        if r == 0:
            return self.principal / n
        return self.principal * r / (1 - (1 + r) ** (-n))

    def generate_schedule(self):
        """สร้างตารางผ่อนชำระ"""
        balance = self.principal
        schedule = []
        total_interest = 0
        total_principal = 0

        for month in range(1, self.months + 1):
            interest = balance * self.monthly_rate
            principal_paid = self.monthly_payment - interest
            balance -= principal_paid

            total_interest += interest
            total_principal += principal_paid

            schedule.append({
                "month": month,
                "payment": round(self.monthly_payment, 2),
                "principal": round(principal_paid, 2),
                "interest": round(interest, 2),
                "balance": round(max(0, balance), 2),
                "total_interest": round(total_interest, 2),
            })

        return schedule

    def print_summary(self):
        """แสดงสรุป"""
        schedule = self.generate_schedule()
        total_paid = self.monthly_payment * self.months
        total_interest = schedule[-1]["total_interest"]

        print(f"\n{'='*50}")
        print(f"Loan Amortization Summary")
        print(f"{'='*50}")
        print(f"  Principal:       {self.principal:>15,.2f} บาท")
        print(f"  Annual Rate:     {self.monthly_rate*12:>14.2%}")
        print(f"  Term:            {self.months:>12} เดือน ({self.months//12} ปี)")
        print(f"  Monthly Payment: {self.monthly_payment:>15,.2f} บาท")
        print(f"  Total Paid:      {total_paid:>15,.2f} บาท")
        print(f"  Total Interest:  {total_interest:>15,.2f} บาท")
        print(f"  Interest Ratio:  {total_interest/total_paid:>14.1%}")

        # แสดงปีแรกและปีสุดท้าย
        print(f"\n{'Month':<8} {'Payment':>12} {'Principal':>12} "
              f"{'Interest':>12} {'Balance':>15}")
        print("-" * 63)
        for s in schedule[:6]:
            print(f"{s['month']:<8} {s['payment']:>12,.2f} "
                  f"{s['principal']:>12,.2f} {s['interest']:>12,.2f} "
                  f"{s['balance']:>15,.2f}")
        print("  ...")
        for s in schedule[-3:]:
            print(f"{s['month']:<8} {s['payment']:>12,.2f} "
                  f"{s['principal']:>12,.2f} {s['interest']:>12,.2f} "
                  f"{s['balance']:>15,.2f}")

    def compare_extra_payment(self, extra_monthly=0, extra_yearly=0):
        """เปรียบเทียบการผ่อนเพิ่ม"""
        # Normal
        normal_interest = sum(
            s["interest"] for s in self.generate_schedule()
        )
        normal_months = self.months

        # With Extra Payment
        balance = self.principal
        months = 0
        total_interest = 0

        while balance > 0 and months < self.months:
            months += 1
            interest = balance * self.monthly_rate
            total_interest += interest
            principal_paid = self.monthly_payment - interest + extra_monthly

            # Extra yearly payment
            if extra_yearly > 0 and months % 12 == 0:
                principal_paid += extra_yearly

            balance -= principal_paid
            if balance < 0:
                balance = 0

        saved_interest = normal_interest - total_interest
        saved_months = normal_months - months

        print(f"\n{'='*50}")
        print(f"Extra Payment Comparison")
        print(f"{'='*50}")
        print(f"  Normal: {normal_months} months, "
              f"Interest: {normal_interest:,.0f}")
        print(f"  Extra:  {months} months, "
              f"Interest: {total_interest:,.0f}")
        print(f"  Saved:  {saved_months} months, "
              f"{saved_interest:,.0f} บาท interest")

# ตัวอย่าง: สินเชื่อบ้าน 3 ล้าน ดอกเบี้ย 5.5% 25 ปี
loan = LoanAmortization(3000000, 0.055, 25)
loan.print_summary()
loan.compare_extra_payment(extra_monthly=2000)

Investment Comparison

# investment_compare.py — เปรียบเทียบการลงทุน
calc = TVMCalculator()

projects = [
    {
        "name": "Project A — ร้านกาแฟ",
        "cash_flows": [-500000, 150000, 180000, 200000, 220000, 250000],
    },
    {
        "name": "Project B — ร้านออนไลน์",
        "cash_flows": [-300000, 80000, 120000, 150000, 180000, 200000],
    },
    {
        "name": "Project C — ตู้จำหน่ายสินค้า",
        "cash_flows": [-200000, 60000, 70000, 80000, 90000, 100000],
    },
]

discount_rate = 0.08  # 8%

print(f"\n{'='*60}")
print(f"Investment Comparison (Discount Rate: {discount_rate:.0%})")
print(f"{'='*60}")
print(f"\n{'Project':<30} {'NPV':>12} {'IRR':>8} {'Payback':>10}")
print("-" * 62)

for p in projects:
    npv = calc.npv(discount_rate, p["cash_flows"])
    irr = calc.irr(p["cash_flows"])
    pp = calc.payback_period(p["cash_flows"])

    invest = abs(p["cash_flows"][0])
    pi = (npv + invest) / invest  # Profitability Index

    print(f"{p['name']:<30} {npv:>12,.0f} {irr:>7.1%} {pp:>8.1f} ปี")

print(f"\nRecommendation: เลือกโครงการที่ NPV สูงสุดและ IRR > {discount_rate:.0%}")

แนวคิดสำคัญ

  • Compound Interest: ดอกเบี้ยทบต้นเป็นพลังที่ทรงพลังที่สุดในการเงิน ยิ่งลงทุนนานยิ่งได้ผลตอบแทนมาก
  • Opportunity Cost: เงินที่ไม่ได้ลงทุนคือเงินที่สูญเสียผลตอบแทน ต้องเปรียบเทียบทางเลือกเสมอ
  • Inflation: ต้องคำนึงถึงเงินเฟ้อ Real Return = Nominal Return - Inflation
  • Risk-Return Tradeoff: ผลตอบแทนสูงมาพร้อมความเสี่ยงสูง ใช้ Risk-adjusted Return เปรียบเทียบ
  • Diversification: กระจายการลงทุนลดความเสี่ยง อย่าใส่ไข่ในตะกร้าใบเดียว
  • DCA: Dollar Cost Averaging ลงทุนสม่ำเสมอลดผลกระทบจาก Market Timing

Time Value of Money คืออะไร

แนวคิดที่ว่าเงินวันนี้มีมูลค่ามากกว่าเงินจำนวนเดียวกันในอนาคต เพราะนำไปลงทุนสร้างผลตอบแทนได้ เป็นพื้นฐานของการวิเคราะห์การลงทุน สินเชื่อ การออม และการวางแผนการเงิน