I've checked similar questions and answers but even after setting the evaluation date in ql.settings I still get zero. Like another poster, I also have the QL cookbook and have read everything I could find, but still struggling. Thanks for any help!
import QuantLib as ql
calc_date= ql.Date(21,ql.July,2023)
ql.Settings.instance().setEvaluationDate(calc_date)
dayConvention = ql.Thirty360(ql.Thirty360.BondBasis)
calendar = ql.UnitedStates(ql.UnitedStates.NYSE)
trade_date = ql.Date(20,ql.July,2023)
maturityDate = ql.Date(4,ql.August,2023)
spotDates = [ql.Date(20,ql.July,2023), ql.Date(4,ql.August,2023), ql.Date(4,ql.August,2024)]
spotRates = [0.01318, 00.01318,0.01318]
compounding = ql.Simple
compoundingFrequency = ql.Annual
spotCurve = ql.ZeroCurve(spotDates, spotRates, dayConvention, calendar, ql.Linear(), compounding, compoundingFrequency)
spotCurve.enableExtrapolation()
spotCurveHandle = ql.YieldTermStructureHandle(spotCurve)
index = ql.USDLibor(ql.Period('1W'), spotCurveHandle)
index.addFixing(ql.Date(18, ql.July, 2023),0.01318)
# index.addFixing(ql.Date(26, 6, 2020), 0.05)
notional = 54760000
rate = 1.37825/100
fra = ql.ForwardRateAgreement(trade_date, maturityDate, ql.Position.Long, rate, notional, index, spotCurveHandle)
print('NPV:', fra.NPV())