5

By default, QuantLib expects a continuously compounded rate in the FlatForward constructor. So the PV you are getting is basically: from math import exp print(110 * exp(-0.1)) If you define your curve with an annually compounded rate like so: curve_30_360 = ql.YieldTermStructureHandle( ql.FlatForward(calc_date, risk_free_rate, ql....


4

You could just use the ql.Date().from_date method. Example: d0 = pd.to_datetime(date(2010,1,1)) df = pd.DataFrame() df['month #'] = np.arange(0,60) df['dates'] = df.apply( lambda x: d0 + pd.DateOffset(months = x['month #']) , axis = 1 ) df['cf'] = 0 df.iloc[0,2] = -100 df.iloc[1:,2] = 2 df['qldate'] = df.dates.apply(ql.Date().from_date) df['dayc act 365'] =...


3

I believe that Taleb made a mistake in his book. Several days ago I met the same question, and I came to read the original article of Parkinson(1980). After doing some simple math, I was aware that the 1.66( the sqrt of 4log2) was already counted in the Parkinson Number Formula. As a result, I believe that the theoretical ratio of Parkinson number to close-...


2

I think that you almost had both. You were just missing the combination of an InterestRate and the includeSettlementDateFlows boolean flag. The following works: import QuantLib as Ql import logging ql = Ql # Set up logging numeric_level = getattr(logging, 'INFO', None) logging.basicConfig(level=numeric_level, format='%(asctime)s %(levelname)-8s %(message)s',...


2

Fractional differentiation (or differencing) is a technique that transforms an input series to a stationary series while retaining "long-term" memory. Consider the following example based on S&P 500 closing prices. The daily returns pass the ADF test however the memory is now lost: t-stat: -13.77 p-value: 0.00 CV 1%: -3.43 ...


2

QuantLib has a concept of evaluation date (for a number of reasons that I'm now glossing over). By default, it's today's date, which implies that all your cashflows are in the past and thus worthless. If you want to calculate the NPV as of the calc date, add: ql.Settings.instance().evaluationDate = calc_date before calculating. Your construction of the ...


2

By default, QuantLib will set the evaluation data as the present date. If you inspect your current date with: ql.Settings.instance().evaluationDate You will see that you are trying to get the npv of all past cashflows, which would be zero. Try inserting this line after defining the d1. ql.Settings.instance().setEvaluationDate(d1)


1

It's normal that it takes very long to come close to the efficient frontier with random portfolios. How close you come how fast will be strongly influenced by how you sample the portfolios. In your code, you sample uniformly. You may want to look at the weight distributions of the portfolios on the frontier, and then consider how likely it is that you arrive ...


1

In case this is useful for anyone else who comes across this, the issue was that I had set up my vector of terminal values the wrong way round (ie from smallest to largest rather than largest to smallest). The code to set up the terminal vector should read as follows: # set up terminal vector and prob vector c_n = np.zeros(steps + 1) c_n[0] = s * (u ** ...


1

There are many (hundreds?) of ways to get historical equity data online, both free and paid. Check out the "What data sources are available online?" megathread: What data sources are available online? I have my own data service I just started, https://tendollardata.com, that I really do think is worth checking. I write out why in that thread (https:...


Only top voted, non community-wiki answers of a minimum length are eligible