This is a short guide how to create, manipulate and share cash flows (as information not as money) with cffiddle.net.

This is the preferred way and (after getting used to) also the easiest way to create cash flows. Basically, you create a cash flow by describing its formula and you manipulate it with some formula.

You can type the code/formula here.

The rules are few and simple.

- 1. Only following functions are allowed:
- 1.1 Functions that generate a cash flow:
**annuity**,**installment**,**bullet**,**regular**,**zero**. - 1.2 Functions that manipulate a cash flows:
**shift_t**,**scale_t**,**shift_cf**,**scale_cf**. - 1.3 Function that add cash flows:
**+**.

- 1.1 Functions that generate a cash flow:
- 2. The commands are to be separated by semicolon
- 3. The first command of a cach flow must be a cash flow generator, the following (you can stop by product) must be a manipulation.
- If a cash flow generator allows for an unknown parameter, then enter it as 'x'. You can also denote it as 'a', 'b', 'c' or 'd' and then use it as a known parameter (i.e. result of calculation) in the next experession
- 4. Cash flows are to be added with
**+**command (takes no argument). - 5. The links that contain code either look like cffiddle.net/cf/code/
*<Your code is here>*/ (then it'll be created as a cash flow) or like cffiddle.net/portfolio/code/*<Your code is here>*/ (then it'll be created as portfolio of cash flows)

The rules above could be written in Backus-Naur form as follows (arguments of functions are left out).

- < cash flow generator > ::= annuity | installment | bullet | regular | zero
- < cash flow manipulator > ::= shift_t | shift_cf | scale_t | scale_cf
- < cash flow > ::= < cash flow generator > | < cash flow >;< cash flow manipulator >
- < code > ::= < cash flow > | < code >;+;< cash flow >

Just to get the first impression, you can create a mortgage of 200'000 USD for 10 years at 4% p.a. with monthly payments like this: annuity(200000,0.04,10,x,12). The monthly payment ('x') turns out to be 2024.90 USD.

If you get it in a half a year, then you shift its time by 0.5: annuity(200000,0.04,10,x,12);shift_t(0.5). Next, we describe the functions and manipulations.

*Short description*. A loan with fixed payments.

*Syntax*: annuity(Principal, Interest rate, Maturity, Payment per period, Payments a year)

*Example*. A loan of 10 000 at 8% p.a. with monthly payment of 500 USD: annuity(10000,0.08,x,500,12)

*Comment*. Any parameter (only one at the time) except for payments frequency for could be set as 'x' and, thus, be calculated.

*Short description*. A loan with fixed pay-off of the loan balance (interest to be paid varies).

*Syntax*: installment(Principal, Interest rate, Maturity, Number of periods a year)

*Example*. A loan of 20 000 at 4.5% p.a. for 5 years with payments every 2 months: installment(20000,0.045,3,6)

*Comment*. All parameters must be given.

*Short description*. A loan with only final payment (of face value).

*Syntax*: zero(Price, Yield-To-Maturity, Maturity, Face Value)

*Example*. A zero-bond with the price of 9'000 USD and face value of 10'000 and maturity of 3 years: zero(9000,x,3,10000)

*Comment*. Any parameter (only one at the time) could be set as 'x' and, thus, be calculated.

*Short description*. A savings account with fixed payments.

*Syntax*: regular(Saving goal, Interest rate, Maturity, Payment per period, Number of periods a year)

*Example*. A regular saving account with monthly payment of 400 USD at 0.5% p.a. and the saving goal of 30'000 USD: regular(30000,0.005,x,400,12)

*Comment*. Any parameter (only one at the time) except for payments frequency for could be set as 'x' and, thus, be calculated.

*Short description*. A loan with payments of interest and principal pay-off at the end.

*Syntax*: bullet(Principal, Coupon, Maturity, Number of periods a year)

*Example*. A bullet loan of 50'000 USD at 3.5% p.a. for 4 years and 6 months with quarterly payments: bullet(50000,0.035,4.5,4)

*Comment*. All parameters must be given.

*Syntax*: shift_t(Number of years)

*Example*. Shift the annuity from the previous example by 3 months (i.e. by 0.25 years): annuity(10000,0.08,x,500,12);shift_t(0.25)

*Syntax*: scale_t(Number)

*Example*. Accelerate twice (i.e. scale by 0.5) the time schedule of the bullet loan from the previous example: bullet(50000,0.035,4.5,4);scale_t(0.5)

*Syntax*: shift_cf(Currency Units)

*Example*. Assume that for the regular savings account from the previous example, a bank require a processing fee of 1.25 USD for each payment: regular(30000,0.005,x,400,12);shift_cf(1.25)

*Syntax*: scale_cf(Number)

*Example*. Buying 2 zero-bonds from the previous example is the same as scaling the cash flows by 2: zero(9000,x,3,10000);scale_cf(2)

Portfolios of cash flows could be also created with formula. The sn

*Syntax* *formula of the 1-st cash flow*;+;*formula of the 2-nd cash flow*;+;*formula of the 2-nd cash flow*

*Example*. Assume that the down payment (60'000 USD) of 20% of the house price (300'000 USD) is saved at 1% p.a. with the regular savings account for 5 years. Formula: regular(60000,0.01,5,x,12)

And then (i.e. 5 years later) an annuity mortgage is taken for 10 years at 4.5% p.a.: annuity(240000,0.045,10,x,12);shift_t(5)

We can combine them into one portfolio with the **+** operator: regular(60000,0.01,5,x,12);+;annuity(240000,0.045,10,x,12);shift_t(5);

Creating a cash flow manually means typing in each payment manually.

We created several cash flows generators that help create cash flows usual in commercial banking.

This is probably the most common type of loan for private persons. The idea is that the payment amount is fixed. The accrued interest is paid out, the rest is used to reduce the loan balance. With the time the percentage of the payment used to pay off the balance goes up.

On the picture below you could see how to parametrize it.

Here the loan balance will be reduced linearly over the time, besides, the accrued interest will be paid out (depending on the loan balance at the time). Thus the payments go slightly down with the time.

On the picture below you could see how to parametrize it. Notice that there are less parameters as before, the reason behind is that the installment loan is structured in a different way as annuity.

Here the loan balance will be paid off at once (at the end). The accrued interest will be consequently paid out during the time of the loan.

On the picture below you could see how to parametrize it.

Here both the loan balance and accrued interest will be paid off at once (at the end). Usually, zero bonds promise to pay out the nominal at maturity and they are traded with some discount.

On the picture below you could see how to parametrize it. Same as for annuity one parameter needs to be fixed.

Here is the opposite of annuity takes place: you pay in a fixed amount and at the end you get the principal.

On the picture below you could see how to parametrize it. Same as for annuity one parameter needs to be fixed.

You can manipulate the cash flows either operating on its time points or on amounts of payments. The operations are *scaling* (i.e. multiplying by a number) and *shifting*

As an example we take some cash flow and then double the payments and shift it by 1 year (you could regard it as grace period). On the picture below you find the initial state.

Now, we want to double the payments. You could do it as shown on the following picture.

This operation results in the following cash flow:

Now, we shift the payment schedule as shown on the picture below.

Here is the final result:

To understand better a cash flow, you could take a look on statistics.

What do we see here? In the first place the *EAPR* (effective annual percentage rate). It represents the "cost" of a loan and helps compare different cash flows. In many countries lenders are obliged by authorities to explicitely disclose it. In the same way as tobacco companies have to print on every cigarette pack, or maybe nicotine numbers would be a better comparison since lenders don't have to print "lending harms your financial health" on every mortgage application form.

Next, there's a group of discount rate dependent indicators. The *Net Present Value* sums all the payments taking the time value ("a dollar today is more precious that a dollar tomorrow") into account.

*Duration* shows how sensitive is your loan to the changes in interest rates. This is important for loans with variable interest rates. Another way to interpret duration is the amount of time the loan is paid-off at half.

*Convexity* shows how sensitive is duration to the changes in interest rate.

You can also construct portfolios consisting of cash flows. Similar as you can add a payment to your cash flow, you can add an existing cash flow to the portfolio entering its id. Creating portfolio is also a way to generate a cash flow, it's kind of arithmetics of cash flows adding and multiplying them just like numbers.

On the picture below you see a portfolio with id ea900a8f consisting of 2 cash flows.

Pay attention that the chart you see is the cash flow of the portfolio that is the sum of all cash flows. You can both save the resulting cash flow and portfolio itself.

If you save a cash flow (write something in the name and description fields to remember what is all about), you can find it later by its hex 10-digits id. You can send the link or tweet it. Remember that the access is not constrained, thus, anyone can take a look on it.

In the same manner you can save and share a portfolio (its id is a 8-digits hex).