100% found this document useful (3 votes)
320 views

(Ebook) Python for Finance and Algorithmic trading (2nd edition): Machine Learning, Deep Learning, Time series Analysis, Risk and Portfolio Management for MetaTrader™5 Live Trading by Inglese, Lucas ISBN 9798844126222, 8844126222, B0BB4SB3FV - Get the ebook instantly with just one click

The document promotes various eBooks available for instant download on ebooknice.com, focusing on topics such as Python for finance, algorithmic trading, and machine learning. It includes links to specific titles along with their ISBNs and emphasizes the importance of understanding portfolio management and statistical predictive models. Additionally, it outlines the structure of a comprehensive book that covers machine learning and deep learning applications in trading, culminating in a practical project for live trading.

Uploaded by

sunejapalano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
320 views

(Ebook) Python for Finance and Algorithmic trading (2nd edition): Machine Learning, Deep Learning, Time series Analysis, Risk and Portfolio Management for MetaTrader™5 Live Trading by Inglese, Lucas ISBN 9798844126222, 8844126222, B0BB4SB3FV - Get the ebook instantly with just one click

The document promotes various eBooks available for instant download on ebooknice.com, focusing on topics such as Python for finance, algorithmic trading, and machine learning. It includes links to specific titles along with their ISBNs and emphasizes the importance of understanding portfolio management and statistical predictive models. Additionally, it outlines the structure of a comprehensive book that covers machine learning and deep learning applications in trading, culminating in a practical project for live trading.

Uploaded by

sunejapalano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 83

Instant Ebook Access, One Click Away – Begin at ebooknice.

com

(Ebook) Python for Finance and Algorithmic trading


(2nd edition): Machine Learning, Deep Learning,
Time series Analysis, Risk and Portfolio
Management for MetaTrader™5 Live Trading by
Inglese, Lucas ISBN 9798844126222, 8844126222,
B0BB4SB3FV
https://ebooknice.com/product/python-for-finance-and-
algorithmic-trading-2nd-edition-machine-learning-deep-
learning-time-series-analysis-risk-and-portfolio-management-
for-metatradertm5-live-trading-46611030

OR CLICK BUTTON

DOWLOAD EBOOK

Get Instant Ebook Downloads – Browse at https://ebooknice.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Start reading on any device today!

(Ebook) Biota Grow 2C gather 2C cook by Loucas, Jason; Viles, James ISBN
9781459699816, 9781743365571, 9781925268492, 1459699815, 1743365578, 1925268497

https://ebooknice.com/product/biota-grow-2c-gather-2c-cook-6661374

ebooknice.com

(Ebook) Matematik 5000+ Kurs 2c Lärobok by Lena Alfredsson, Hans Heikne, Sanna
Bodemyr ISBN 9789127456600, 9127456609

https://ebooknice.com/product/matematik-5000-kurs-2c-larobok-23848312

ebooknice.com

(Ebook) SAT II Success MATH 1C and 2C 2002 (Peterson's SAT II Success) by Peterson's
ISBN 9780768906677, 0768906679

https://ebooknice.com/product/sat-ii-success-math-1c-and-2c-2002-peterson-s-sat-
ii-success-1722018

ebooknice.com

(Ebook) Cambridge IGCSE and O Level History Workbook 2C - Depth Study: the United
States, 1919-41 2nd Edition by Benjamin Harrison ISBN 9781398375147, 9781398375048,
1398375144, 1398375047

https://ebooknice.com/product/cambridge-igcse-and-o-level-history-
workbook-2c-depth-study-the-united-states-1919-41-2nd-edition-53538044

ebooknice.com
(Ebook) Master SAT II Math 1c and 2c 4th ed (Arco Master the SAT Subject Test: Math
Levels 1 & 2) by Arco ISBN 9780768923049, 0768923042

https://ebooknice.com/product/master-sat-ii-math-1c-and-2c-4th-ed-arco-master-
the-sat-subject-test-math-levels-1-2-2326094

ebooknice.com

(Ebook) Deep Learning for Finance: Creating Machine & Deep Learning Models for
Trading in Python by Kaabar, Sofien ISBN 9781098148393, 1098148398

https://ebooknice.com/product/deep-learning-for-finance-creating-machine-deep-
learning-models-for-trading-in-python-56363826

ebooknice.com

(Ebook) Deep Learning for Finance: Creating Machine & Deep Learning Models for
Trading in Python by Sofien Kaabar ISBN 9781098148393, 1098148398

https://ebooknice.com/product/deep-learning-for-finance-creating-machine-deep-
learning-models-for-trading-in-python-54868706

ebooknice.com

(Ebook) Machine Learning for Algorithmic Trading by Stefan Jansen

https://ebooknice.com/product/machine-learning-for-algorithmic-trading-55838194

ebooknice.com

(Ebook) Machine Learning for Algorithmic Trading by Stefan Jansen

https://ebooknice.com/product/machine-learning-for-algorithmic-trading-55910148

ebooknice.com
nd
2 edition

Python for finance and


algorithmic trading

Lucas INGLESE
Disclaimer: I am not authorized by any financial authority to
give investment advice. This book is for educational purposes
only. I disclaim all responsibility for any loss of capital on your
part. Moreover, 78.18% of private investors lose money trading
CFD. Using the information and instructions in this work is at
your own risk. Suppose any code samples or other
technologies this work contains or describes are subject to
open-source licenses or the intellectual property rights of
others. In that case, your responsibility is to ensure that your
use thereof complies with such licenses and rights. This book
is not intended as financial advice. Please consult a qualified
professional if you require financial advice. Past performance is
not indicative of future performance.

WARNINGS: Any partial or complete reproduction


without the author's consent may result in legal action.

A question to ask the author? Section 1.3 "Join the


community”
Table of contents
Table of contents
Why should you read this book?
Chapter 1: Read me
1.1. Find the code
1.2. Conventions used in this book
1.3. Join our community
Chapter 2: Prerequisites
2.1. Mathematical prerequisites
2.1.1. Algebra
2.1.2. Statistics
2.1.3. Optimization
2.2. Prerequisites in finance
2.2.1. Market efficiency
2.2.2. Basics of trading
2.2.3. Basics of portfolio management
2.3. Prerequisites in Python
2.3.1. Libraries for data sciences
2.3.2. Libraries for finance
2.3.3. Libraries for mathematics
Part 1: Portfolio management, risk management and
backtesting
Chapter 3: Static Portfolio management
3.1. Explanation behind portfolio optimization
method
3.1.1. Systemic risk and specific risk
3.1.2. Diversification
3.2. The traditional portfolio optimization
methods
3.2.1. Portfolio utility function
3.2.2. Mean-variance criterion
3.2.3. Mean-variance-skewness-kurtosis
criterion
3.3. The modern portfolio optimization
methods
3.3.1. Sharpe criterion
3.3.2. Sortino criterion
Chapter 4: Tactical portfolio management
4.1. How dynamic methods works?
4.1.1. Short a stock
4.1.2. Momentum factor
4.1.3. Rebalancing
4.2. Moving average strategy
4.2.1. Moving average
4.2.2. Moving average factor
4.2.3. Build the strategy
4.3. Trend following strategy
4.3.1. Correlation
4.3.2. Trend following factor
4.3.3. Compute the strategy
Chapter 5: Risk management and
backtesting
5.1. The backtesting metrics
5.1.1. The CAPM metrics
5.1.2. Sharpe and Sortino
5.1.3. Drawdown
5.2. Risk management metrics
5.2.1. Value at risk (VaR)
5.2.2. Conditional Value at risk (cVaR)
5.2.3. Contribution risk
5.3. Automate the analysis
5.3.1. Create a function
5.3.2. Analyze static portfolio
5.3.3. Analyze dynamic portfolio
Chapter 6: Advanced backtest methods
6.1 Useful backtest advice
6.1.1 Backtest is not a searching tool
6.1.2 Big days are not your friends
6.1.3 Understand your strategy
6.2 Compute the strategy returns using TP and
SL
6.2.1 Find the extremum
6.2.2 Calculate the returns
6.2.3 Analyze the backtest
6.3 Advanced backtest tools
6.3.1 Backtest metrics list
6.3.2 Monte Carlo simulation
6.3.3 Easy Trailing stop
Part 2: Statistics predictive models
Chapter 7: Statistical arbitrage Trading
7.1. Stationarity to Cointegration
7.1.1. Stationarity
7.1.2. Cointegration
7.2. Pairs trading
7.2.1. How it works
7.2.2. Applications
Chapter 8: Auto Regressive Moving
Average model (ARMA)
8.1. Time series basics
8.1.1. Trend, cycle, seasonality
8.1.2. Log price properties
8.1.3. The linear regression
8.2. AR and MA models
8.2.1. Autoregressive model (AR)
8.2.2. Moving average model (MA)
8.3. ARMAs models
8.3.1. ARMA model
8.3.2. ARIMA model
Chapter 9: Linear regression and logistic
regression
9.1. Regression and classification
9.1.1. Reminder about regression
9.1.2. Understand the classification
9.2. Linear regression
9.2.1. Preparation of data
9.2.2. Implementation of the model
9.2.3. Predictions and backtest
9.3. Logistic regression
9.3.1. Preparation of data
9.3.2. Implementation of the model
9.3.3. Predictions and backtest
Part 3: Machine learning, deep learning, live trading
Chapter 10: Features and target
engineering
10.1 Motivation and intuition
10.1.1 Features engineering
10.1.2 Target engineering
10.1.3 Why is it so important?
10.2 Trading application
10.2.1 Create trading indicators and useful
trading features
10.2.2 Target labeling
Chapter 11: Support vector machine (SVM)
11.1. Preparation of data
11.1.1. Features engineering
11.1.2. Standardization
11.2. Support Vector Machine Classifier (SVC)
11.2.1. Intuition about how works an SVC
11.2.2. How to create an SVC using Python
11.2.3. Predictions and backtest
11.3. Support Vector Machine Regressor (SVR)
11.3.1. Intuition about how works an SVR
11.3.2. How to create an SVR using Python
11.3.3. Predictions and backtest
Chapter 12: Ensemble methods and
decision tree
12.1. Decision tree
12.1.1. Decision Tree classifier
12.1.2. Decision tree regressor
12.1.3. Optimize the hyperparameters
12.2. Random Forest
12.2.1. Random Forest classifier
12.2.2. Random Forest Regressor
12.2.3. Optimize the hyperparameters
12.3. Ensemble methods
12.3.1. Voting method
12.3.2. Bagging method
12.3.3. Stacking method
Chapter 13: Deep Neural Networks (DNN)
13.1. Intuition behind DNN
13.1.1. Forward propagation
13.1.2. Gradient descent
13.1.3. Backpropagation
13.2. DNN for classification
13.3.1. Preparation of data
13.2.2. Implementing a DNN for a
classification task
13.2.3. Prediction and Backtest
13.3. DNN for regression
13.3.1. Implementing a DNN for a regression
task
13.3.2. Custom loss function
13.3.3. Prediction and Backtest
Chapter 14: Recurrent neural network
14.1 Principles of RNN
14.1.1. How an RNN works
14.1.2. LSTM neuron
14.1.3. GRU cell
14.2. RNN for classification
14.2.1. Transform 2d data to 3d data
14.2.2. Implementing the model
14.2.3. Prediction and backtest
14.3. RNN regressor
14.3.1. Precision about standardization
14.3.2. Implementing the model
14.3.3. Predictions and backtest
Chapter 15: Bonus / Example of RNN with
CNN (RCNN)
15.1. Intuition of CNN
15.2. Create an RCNN
15.3. Backtest
Chapter 16: Real-life full project
16.1. Preparation of the data
16.1.1. Import the data
16.1.2. Features engineering
16.1.3. Train, test and validation sets
16.2. Modelling the strategy
16.2.1. Find the best assets
16.2.2. Combine the algorithms
16.2.3. Apply portfolio management technics
16.3. Find optimal take profit, stop loss and
leverage
16.3.1. Optimal take profit (tp)
16.3.2. Optimal stop loss (sl)
16.3.3. Optimal leverage
Chapter 17: From nothing to live trading
17.1 Trading strategies creation guidelines
17.1.1 The trading plan
17.1.2 The process of a trading strategy
building
17.1.3 Trading journal
17.2 Do not put all your eggs in one basket
17.2.1 Bet sizing
17.2.2 Why create a trading strategy
portfolio?
17.3. Live trading process
17.3.1. Safety first
17.3.2 Incubation phase
17.3.3 When to quit?
Annex: Compounding versus simple
interest
What is the difference between the simple and
the compounding methods?
How to compute the simple and compounding
interest
Annex: Save and load scikit-learn and
Tensorflow models
Annex: MetaTrader class
Additional readings
Why should you read this
book?
The financial sector is undergoing significant restructuring.
Traders and portfolio managers are increasingly becoming
financial data scientists. Banks, hedge funds, and fintech are
automating their investments by integrating machine learning
and deep learning algorithms into their decision-making
process. This book presents the benefits of portfolio
management, statistics, and machine learning applied
to live trading with MetaTrader 5.

Part 1 is dedicated to portfolio management, risk


management, and back testing. These chapters will allow
us to understand how to combine strategies and which metrics
to look at to understand the strategy robustness.

Part 2 discusses statistical predictive models . We will


discuss the statistical arbitrage and autoregressive moving
average (ARMA) model and introduce the classification
algorithms through logistic regression.

Part 3 gives us an understanding of Machine Learning and


Deep Learning predictive models . We will see these
algorithms using trading strategies example: Support Vector
Machines (SVM), decision tree, random forest, ensemble
methods, Artificial Neural Network (ANN), Recurrent Neural
Network (RNN), Recurrent Convolutional Neural Network
(RCNN)

The book ends with a concrete project from A to Z:


Importing data from your broker, creating a portfolio of trading
strategies, deployment in live trading, or using a screener.

Who am I?
I am Lucas, an independent quantitative trader specializing in
Machine learning and data science and the founder of Quantreo,
an algorithmic trading E-learning website ( www.quantreo.com ).

I graduated in mathematics and economics from the University of


Strasbourg (France). I already help more than 56.000 students
through my online courses and YouTube channel dedicated to
algorithmic trading.

I have a quantitative trading approach, combining predictive


models, financial theory, and stochastic calculus.

To show you some realistic results, you can see the profit of my
last portfolio of strategies in live trading: 2.5% of return for a
0.6% drawdown without leverage in 1 month and a half.

Figure 1: My last live trading signal on BullTrading


You can see one of my last signals on BullTrading
(bulltrading.be), a copy trader platform. This strategy is based
on machine learning and quantitative analysis (the same as in
the book).
Chapter 1: Read me

1.1. Find the code

All the resources in the book are available on the GitHub


repository ( https://github.com/Quantreo/2nd-edition-BOOK-
AMAZON-Python-for-Finance-and-Algorithmic-Trading ). If
there is an issue with this link or something else related to the
code, contact us using the contact page www.quantreo.com .
Before reading this book, you should download Jupyter
Notebook using Anaconda Navigator (
https://www.anaconda.com ). In Chapter 01, you can find a
notebook that installs all the necessary libraries for the book.
All the additional readings can be found on the README.md
file on the repository Github.

1.2. Join our community

Follow us on social media to obtain the latest algorithmic


trading information, tips, and ready-to-use strategies.
Moreover, join the discord forum of the community to ask any
questions about the book to read it easily!
Linktree QRCODE

Chapter 2: Prerequisites
This chapter discusses the necessary prerequisites to
understand this book thoroughly. First, we will discuss some
math, statistics, algebra, and optimization basics. Then, the
leading financial theories and the Python basics are mandatory
to implement our trading strategies.

2.1. Mathematical prerequisites

This section aims to detail many mathematical terms and


concepts necessary for the book's whole comprehension.
However, it is not complete math for the finance course. We
will cover some introductory algebra, statistics, and
optimization.

2.1.1. Algebra
Algebra is a significant field to know when we work in finance.
Indeed, we will work with matrices all the time because it is
the heart of algebra. Thus, it is required to understand the
basics about them.

There are many theories about matrices in math, more


complex than others, but for us, it will be straightforward: a
matrix will be a set of data. Let us see an example of a matrix
A with shape ( n,m ), where m is the number of columns
and n is the number of rows in the matrix.

We can imagine that matrix A with a shape of (3,2) will give us


the daily return of some assets. Usually, the rows will be the
days, and the columns represent the assets. Thus, the matrix
has two assets and three daily returns for each.
There are many essential operations that we can apply to a
matrix. Let us see some of them:

Addition : we need matrices with the same shape to


add them. Then, we must add matrix A's coefficients to
matrix B's coefficients, one by one. Let us take an
example to explain.

Subtraction : We need matrices with the same shape


to add them. Then, we must subtract the coefficients of
matrix A from the coefficients of matrix B, one by one.
Let us take an example to explain.
Scalar multiplication : We multiply each coefficient
by the scalar (just a number). Let us take an example
to explain.

The three previous operations are the basic operations


between matrices but exist more complex operations like
inverse, comatrix, and transpose. Thankfully, we only need to
know the transpose matrix for the rest of this book. Suppose
each matrix coefficient is noted where is the row number
and the column number of the coefficient. All matrix
coefficients A become in the transpose matrix called
. Let’s take an example to explain it.

2.1.2. Statistics
Statistics are mandatory when we work in quantitative finance.
From calculating the returns to the computation of
probabilities, we will see the necessary skills to work on a
financial project with peace of mind.
First, we will see some statistical metrics, but do not worry if
you do not understand them 100% because we will discuss
them later in the book! To compute an example of each metric,
we will work with these vectors (vectors are matrices with a
shape (1,n))

Mean : It is the most detailed statistic. It is the sum of


all values divided by the number of values.

Variance : The variance is a measure of the dispersion


of values in a sample. This metric allows an
understanding of how much the values are dispersed
around the mean.

Standard deviation : The variance is a measure of


the dispersion of values in a sample. This metric also
allows us to understand the values' dispersion around
the mean. It is the squared root of the variance. In
finance, it allows us to compute the volatility of an
asset.

Cumulative sum : This metric returns a vector, not


only a float. A cumulative sum is a sequence of partial
sums of a given sequence.
Cumulative product : This metric returns a vector,
not only a float. It does the product of all the values
before for each coefficient.

Mean squared error (MSE): This metric is used to


compute the loss of an algorithm which allows us to
train it (but we will talk more about it later). To penalize
the significant error, it will compute all the differences
between predictions and actual values. We need two
vectors or matrices with the same shapes.

Mean absolute error (MAE): This metric is also used


to compute the loss of an algorithm. It will compute all
the differences between predictions and take the
absolute value of the subtraction. We need two vectors
or matrices with the same shapes.

Where |-x| = |x| = x. It means that the absolute value takes


only the values not the sign.
Now, let us discuss statistic tests. There are many, but we will
see only one in this book, which is essential to understand: the
augmented Dick and Fuller test. However, first, let us explain
how a statistic test generally works. Usually, there are two
hypotheses: H0 and H1. The objective of the test is to test the
H0 hypothesis.

It is a vast and exciting field that can be covered in an entire


book. So, we will try to make it simple quickly. When we
perform a statistical test, we will have only two possibilities:
we reject H0, or we cannot reject H0. To find the situation we
are in, we will use the p-value (a value between 0 and 1). The
following rules can be applied to every hypothesis test; if we
take an error threshold s and the p-value of a test which is
called p, we have these two possibilities:

• p > s: we can’t reject H0


• p < s : we can reject H0

Finally, we need to discuss probability laws. They are essential


in finance because they allow us to understand how the
observations are distributed. The most used law in finance is
the normal law. Thus, we will illustrate the following notion
taking it. There are two essential functions in a probability law:

Cumulative distribution function or repartition


function (CDF) : This function returns the probability
that the random variable X is below the value x. The
CDF takes in all absolute values and returns a value
between 0 and 1 because it is a probability. Let us
formalize this a little bit.
Probability density function (PDF) : This function
allows us to understand the distributions of
observations. Let us see inf figure 2.1 the difference
between CDF and PDF.

Figure 2.1: CDF and PDF for the normal law

We can see the CDF to the right and the PDF to the left of the
figure. However, the percentage between the standard
deviation interval is only available with a normal law, not for
the others.

2.1.3. Optimization
When we talk about portfolio management, it always implies
talking about optimization. The optimization methods allow us
to minimize or maximize a function under constraints. For
example, in portfolio management, we maximize the portfolio's
utility under constraints that the portfolio's weight must equal
100%. Let us take an example of an optimization problem
explaining each part.
The function to maximize is , and we want to maximize
it. However, we have a constraint which
meaning we want to invest all our capital. The vector of the
weights is the variable that allows us to optimize the
function.

2.2. Prerequisites in finance

This section will explain some mandatory theories to know


before creating some algorithmic trading strategies: market
efficiency, basics of trading, and portfolio management theory.

2.2.1. Market efficiency


The theory of market efficiency implies that we cannot predict
the stock behavior because it is a random walk. However, it is
the theory. In practice, it is possible to predict stock behavior.
Let us see the different levels of efficiency to explain that.

Weak market efficiency : This part implies that it is


impossible to predict the stock price using past prices.
Thus, the stock price is a random walk. However, we
can predict the future stock price using machine
learning techniques. This book will only use quantitative
predictive models to prove that weak efficiency is not
always respected.
Semi-strong market efficiency : This part implies
that all the information is always considered in the
stock’s prices. It means that we cannot make a profit
using the news. Indeed, the market should already
consider the news before it comes using the previsions
of the investors. However, it is possible to prove that the
semi-strong efficiency market is not always respected
using Natural Language Processing (NLP). For example,
using machine learning algorithms, we can use tweets,
news, and TV to find opportunities.

Strong market efficiency: This part implies that all


the information is available to anybody. However, it is
incorrect because the firm's CEO can access some
information that private investors do not have. It can be
used to make a profit on the market. Thus, this proves
that the strong efficiency market is not always
respected. However, we cannot use algorithms to
predict it.

2.2.2. Basics of trading


When we talk about trading in this book, we speak only about
speculative trading. The goal is to make profit using CFD
(Contract for Differences).

A Contract for Differences (CFD) is a derivative that follows the


same variation as its underlying. The advantage of the CFD is
that we can bet on the decrease of the stock. It is called
shorting an asset (we will discuss that later).
When we buy a CFD, we will pay some fees. These fees are
either commission or spread. The spread is the difference
between the bid price and the asking price. Moreover, the
commissions are a fixed amount that we will pay the broker
to enter positions and exit.

The last notion that we need to know is leverage . A financial


tool available when we open an account with the broker
allows, we to multiply the strategy's returns. Thus, it is good
when we earn money and wrong when we lose it. Leverage is
a powerful tool that can be a destructor of our capital in the
wrong hands (reminder: with great power comes great
responsibility)
Usually, leverage is taken by the account and not by each
trade. As we said earlier, leverage increases the risk of losing
money. However, it allows people with little capital to invest in
the market. So, in practice, it is strongly recommended to work
on accounts with capital coverage, which means that the
broker closes our positions before we run out of capital so that
we do not get into debt with the broker, even though during
extremely volatile movements, we may owe the broker money
if he could not close the positions in time.

There is another variable that we need to consider: the swap


. It is an interest paid to the broker to keep the position open
the night. As the swap is a difference in interest rates, it can
be negative or positive.

When we have opened trades, we can set a Stop Loss (SL)


or a Take Profit (TP). The stop loss is a threshold that is the
associate's price to the worst loss that we want to accept. It
means that if we do not want to lose more than 1% of our
capital, we set our stop loss at the asset price, which makes
we lose only 1% of the capital. For example, we have 100$ of
capital, and we want to limit the loss on this position to 1%. If
we are in an extended position, we will set the stop loss at
99$. If the price goes below 99$, the position is closed
automatically. It allows us to limit the risk of the investment.
The take profit is the same thing but with the inverse
reflection. We will close the position when we earn the desired
amount.

2.2.3. Basics of portfolio management


The goal of portfolio management is to invest using technic to
reduce the portfolio’s risk (diversification). The foundation of
portfolio management was put in place by M.Markovitz (1952).
The mean-variance portfolio theory was the basis of the
portfolio management technique. Indeed, the first theory
focuses more on statistics than the other parameters. It will be
the foundation of our static portfolio analysis.

2.3. Prerequisites in Python

In this part, we will discuss the main functions of the libraries


for data science, math, and finance that we will use.

2.3.1. Libraries for data sciences

Numpy

np.array(obj) create an array


np.zeros([n,m]) create a matrix of size
(n,m)
np.ones([n,m]) create a matrix full of
one
np.mean(array, axis=) return the mean of the
array
np.std(array, axis=) return the standard
deviation of the array
np.var(array, axis=) return the variance of
the array
np.sum(array,axis=) return the sum of the
array
np.cumprod(array, axis=) return the cumulative
product of the array

np.where(condition, apply condition to a


value_true, value_false) numpy array

np.concatenate([arr,…],axis concatenate some


=) arrays

Pandas
pd.DataFrame(obj, create a dataframe
index=[], columns=[])
df.columns = change the columns
[col,…,col] of a dataframe

pd.Series(obj, index= create a series


[])

Matplotlib
plt.figure() modify the figure
plt.plot(x,y) plot a line
plt.fill_between(x,y,conditio plot an area
n)
plt.title(“title”) give a title
plt.xlabel(“title”) give x label
plt.ylabel (“title”) give y label
plt.legend([col,…,col]) name the legend
plt.xlim([a,b]) Resize the limit
plt.show() show a figure

2.3.2. Libraries for finance

Yfinance

yf.download(ticker, download stock price


start=, end=)

Datetime

datetime.now() give the date in


datetime format
datetime.now().strftime(% datetime to string
Y-%m-%d)
datetime.now().week() Find weekday

Time
time.sleep(n) Put the computer in a
break of n seconds

2.3.3. Libraries for mathematics

Scipy

scipy.optimize.minimize(criterio Minimize a
n, x, args=()) function

StatsModels
statsmodels.tsa.stattools.adfuller(arr) Compute adfuller
test

statsmodels.api.stat.OLS(x,y).fit() Train model


model.resid() Give the residuals
statsmodels.tsa.arima_model.ARIMA(arr) Compute ARIMA
model
statsmodels.graphics.tsaplots.plot_acf(arr Plot the acf
)
statsmodels.graphics.tsaplots.plot_pcaf(a Plot the pacf
rr)
Part 1: Portfolio
management, risk
management and
backtesting
In this part, we will discuss static portfolio optimization
methods, such as mean-variance optimization and Sharpe ratio
optimization. We will also see some dynamic portfolio
optimization, such as momentum criteria. Once we have
created some portfolios, we will analyze the risk of these
portfolios and backtest them.

Summary:

Chapter 3: Static portfolio optimization

Chapter 4: Dynamic portfolio optimization

Chapter 5: Risk management and backtesting

Chapter 6: Advanced backtest methods


Chapter 3: Static Portfolio
management
This chapter will discuss static portfolio optimization methods.
First, we will see the intuition behind portfolio optimization and
why they are so valuable for portfolio management. Then, we
will look at the traditional portfolio optimization method like
the mean-variance criterion or mean-variance skewness
kurtosis criterion. Moreover, we will study how to do our
criterion for portfolio optimization.

3.1. Explanation behind portfolio


optimization method

This section will explain why portfolio optimization is so


valuable in finance. First, we will see the difference between
systemic and specific risks. Then, we highlight the advantages
of diversification.

3.1.1. Systemic risk and specific risk


When we talk about the risk of an asset, we think about asset
volatility. In contrast, we can decompose the risk of an asset in
two ways: the systemic risk and the specific risk.

Asset-specific risk is the risk associated with an asset that does


not depend on market conditions. For example, an issue in a
factory of Tesla can reduce the price of the Tesla stock but only
the Tesla stock because there are no reasons that this issue
affects the Netflix stock price, for example.

The systemic risk is a macroeconomic risk on all the economy's


assets. For example, suppose there is a significant recession
caused by geopolitical instability. In that case, all stock prices
will decrease because people do not want to consume because
of the uncertainty of the future. It is a systemic risk because it
affects all the economy's assets.

The big difference between specific and systemic risk is that


the systemic risk does not depend on the firm's actions. Thus,
the objective of the portfolio optimization methods is to reduce
the specific risk in the portfolio. To do that, we use
diversification.

This book only sees how to reduce the


specific risk, but it is possible to reduce the
systemic risk using derivatives.

3.1.2. Diversification
Diversification is the core process of portfolio management. It
allows us to reduce the specific risk of the portfolio, as
explained above. The strategy aims to increase the number of
assets in the portfolio to make the specific risk of each asset
insignificant. The explanation is shown in figure 3.1.

Figure 3.1: Risk of portfolio


In this figure, we see the decomposition of the risk between
the specific risk and systemic risk. The more the number of
asset increases, the more we are closer to the systemic
portfolio risk.

The figure shows that the increase in the number of assets


allows us to reduce the portfolio's risk to the portfolio's
systemic risk because each asset's specific risk decreases with
the number of assets. So, the figure highlights the power of
diversification to decrease the risk of a portfolio.

Diversification decreases the specific risk to


a theoretical level of 0, but in practice, the
cost of the transaction or tax forces to limit
the diversification a little and find a
reasonable allocation considering the cost of
the transaction.

3.2. The traditional portfolio optimization


methods
In this section, we will learn the traditional portfolio
optimization methods. This book will not focus on the theory of
the portfolio utility function but only on this calculation and its
advantages [1] . Next, we will use a derivative of the portfolio
utility function to create advanced diversification criteria.

3.2.1. Portfolio utility function


We will explain some exciting results about the portfolio utility
function and the process we will follow in the following parts.
The portfolio utility function is the main point in portfolio
management theory. Indeed, with this function, we can
quantify the satisfaction given by the portfolio. Naturally, we
will use this function to maximize the investor's utility.

The utility function is tough to compute in its original form.


Thus, to avoid this issue, we will use the Taylor approximation
of this function to find the mean-variance and the mean-
variance skewness kurtosis criterion.

The equation is the mean-variance criterion, and the


is the mean-variance-skewness-kurtosis criterion. In
the following equation, μ is the mean of the portfolio's returns,
the portfolio's volatility, s the skewness of the portfolio, and
k the kurtosis of the portfolio. Moreover, is the level of risk
aversion (we set it at 3 because it is a usual risk aversion),
the risk-free wealth (we set 1.0025), and w the wealth of the
portfolio.
Don’t worry we will show you how to compute it in the next
section!

3.2.2. Mean-variance criterion


In this subsection, we will implement a mean-variance
optimization [2] . It is necessary to download a database with
some assets' adjusted close stock prices. To do the portfolio
optimization, we will use these assets: Facebook, Netflix, and
Tesla. For the importation, we will use the library yfinance ,
which allows us to import data very quickly. Moreover, we
transform the data into daily variation to put all assets on the
same scale.

Code 3.1: Importation of data


# Importation of data
list_tickers = [ "FB" , "NFLX" , "TSLA" ] 1
database = yf.download(list_tickers) 2
# Take only the adjusted stock price
database = database[ "Adj Close" ] 3
# Drop missing values

data = database.dropna().pct_change( 1 ).dropna( ) 4

1 Create a list of tickers using the Yahoo


notation.
2 Use the download() function of yfinance to
import the dataset.

3 Select only the adjusted close prices.

4 Create returns and remove missing values.

Figure 3.2: Extract from the database


Date 05- 05- 05- 05- 05- 05- Extract
21 22 23 24 25 29 from the
Facebook -0.110 -0.089 0.032 0.032 -0.34 -0.096 database
Netflix 0.025 -0.056 0.062 -0.023 -0.001 -0.011 from code
3.1, which
Tesla 0.044 0.071 0.007 -0.024 -0.016 0.063
imports the
data of Facebook (FB), Netflix (NFLX), and Tesla (TSLA) from
2012 to 2021.

Now, we need to define the function MV_criterion to calculate


the utility of the function and find the best distribution among
the three assets. To do it, we will compute the equation in part
3.2.1 ( ).

Code 3.2: mean-variance criterion function


def MV_criterion ( weights , data ):
"""
--------------------------------------------------------------------------
| Output: optimization portfolio criterion |
--------------------------------------------------------------------------
| Inputs: -weight (type ndarray numpy): Weight for portfolio |
| -data (type ndarray numpy): Returns of stocks |
--------------------------------------------------------------------------
"""

# Parameters 1
Lambda = 3
W= 1
Wbar = 1 + 0.25 / 10 0 2
# Compute portfolio returns
portfolio_return = np.multiply(data, np.transpose(weights)
) 3
portfolio_return = portfolio_return. sum (axis= 1 ) 4
# Compute mean and volatility of the portfolio
mean = np.mean(portfolio_return, axis= 0 ) 5
std = np.std(portfolio_return, axis= 0 ) 6
# Compute the criterion
criterion = Wbar ** ( 1 - Lambda) / ( 1 + Lambda) + Wbar ** (-
Lambda)
\ * W * mean - Lambda / 2 * Wbar ** ( -1 - Lambda) * W ** 2 *\
std
** 2 7

criterion = -criterio n 8
return criterion

1 Set the parameters of the model above.

2 The risk-free wealth is 1 + the risk-free rate


(0.25%).

3 Multiply the columns by their coefficient to


keep a matrix with shape (n,m).

4 Sum all the columns to have the portfolio


(shape=(n,1)).
5 Compute the mean of the portfolio daily
returns (using axis=0 to do on the rows).

6 Compute the daily volatility of the portfolio (the


standard deviation).

7 Compute using the previous formula.

8 Return the opposite of the criterion to minimize


it.

Maximizing a function is the same as


minimizing the opposite of this function. So,
we will use the minimize function in the
following code because the MV_criterion
returns us .

Once we have a function to minimize (maximize the inverse of


U(w)), we need to configure the bounds for the following
optimization problem.

It means we will maximize the utility under the constraints to


use all the capital because the sum of must equal 100%.
Therefore, we need to use all our capital. Thus, the bounds for
each asset are (0,1).

We also need to set a weight for the start of the optimization.


Furthermore, we will only perform the optimization on the train
set (70% of the data) and analyze the test set's performance
(30% of the data).
Code 3.3: Implementation of the portfolio optimization
problem
split = int( 0.7 * len (data) ) 1
train_set = data.iloc[:split, :]
test_set = data.iloc[split:, :]

# Find the number of assets


n = data.shape[ 1 ] 2
# Initialization weight value

x0 = np.ones(n ) 3
# Optimization constraints problem
cons = ({ 'type' : 'eq' , 'fun' : lambda x: sum ( abs (x)) - 1
} ) 4
# Set the bounds

Bounds = [( 0 , 1 ) for i in range ( 0 , n) ] 5


# Optimization problem solving
res_MV = minimize(MV_criterion, x0, method= "SLSQP" ,
args=(train_set), bounds=Bounds,

constraints=cons, options={ 'disp' : True } ) 6


# Result
X_MV = res_MV.x 7

1 The variable split is an integer representing


the value at 70% of the data. It is a tip to
select the train and test sets.

2 n is the number of assets, so we use the


command .shape[1] to have the number of
columns which is the number of assets.

3 Initialize the value of the weight vector. It is


a vector full of one with a shape (n,).

4 Define the constraints of the optimization.


Here, we want the investor to use all its
capital. Thus, we wish that the sum of the
weight equal 100%. (There is absolute value
if we wish to short also).

5 Define the bound of the optimization. We


define the bounds from 0 to 1 because we
want a long-only strategy. If we create a long-
short strategy, bounds will be (-1,1).

6 Minimize the opposite of the using


the minimize function of scipy.

7 Extract the optimal weight for our portfolio.

With the previous code, we have found the best allocation for
this asset and, the vector of the weights is available in figure
3.3.

Figure 3.3: Weights allocation of the portfolio using MV


criterion
Asset Faceboo Netflix Tesla As we can
k see, the
Weight 33.35% 33.35% 33.30% optimization
with the MV
criterion takes the Facebook stock for 33.35%, the Netflix
stock for 33.35%, and the Tesla stock for 33.30%.

Now, we have the weights of each asset in our portfolio. So,


we need to display the returns of the portfolio on the test set
to see if the portfolio optimization is good or not. Even if the
cumulative returns of the portfolio cannot say alone if it is a
good optimization or not, it is a good indication.

Code 3.4: Testing performance on test set


# Compute the cumulative return of the portfolio (CM)
portfolio_return_MV =

np.multiply(test_set,np.transpose(X_MV)) 1
portfolio_return_MV = portfolio_return_MV. sum (axis= 1 )
2
# Plot the CM
plt.figure(figsize=( 15 , 8 ) ) 3
plt.plot(np.cumsum(portfolio_return_MV)* 100 ,
color= "#035593" , linewidth= 3 ) 4
plt.ylabel( "Cumulative return %" , size= 15 , fontweight=
"bold" ) 5
plt.xticks(size= 15 ,fontweight= "bold" )
plt.yticks(size= 15 ,fontweight= "bold" )
plt.title( "Cumulative return of the mean variance potfolio" ,
size= 20 )

plt.axhline( 0 , color= "r" ,linewidth= 3 ) 6


plt.show( ) 7

1 We have multiple columns by his coefficient.


Thus, we always have a shape (n,m) matrix.

2 We do the sum of each column to have the


portfolio return.
Random documents with unrelated
content Scribd suggests to you:
The Tale of the Four
White Swans

T he story that I will tell you now is one of the most famous
among all the peoples of the Gael. It is called sometimes
“The Tale of the Four White Swans,” sometimes “The Fate of the
1
Children of Lir,” sometimes simply “Fionula,” because of the beauty
and tenderness of Lir’s daughter.
The tale is of the old far-off days. It was old when Ossian was a
youth, and Fionn heard it as a child from the lips of grey-beards.
Often I have spoken to you, Peterkin, of the Danann folk, the
Tuatha-De-Danann who lived in the lands of our race before the
foreign peoples came and drove the ancient dwellers in Ireland and
Scotland to the hills and remote places. When men allude to them
now in this late day, they speak of the Dedannans (as they are often
called) as the Hidden Folk, the Quiet People, the Hill Folk, and even
as the Fairies. It is natural, therefore, that years are as dust in the
chronicles of this lost race. They live for hundreds of years where we
live for ten; and so it is that the foam of time is white against the
brief wave of our life, when against the mighty and long reach of
theirs it is but flying spray.
You have heard Eilidh singing the song of the Four White Swans.
It is a music that hundreds of tired ears have heard. It is so sweet,
Peterkin, that old men grow young, and old women are girls again,
and weary hearts ache no more, and dreams and hopes become
real, and peace puts out her white healing hand.
“Have you heard that singing, Ian?”
“Yes, my boykin, often. And you, too, shall often hear it. It is in
lonely places, in lonely hours, that you shall hear it. It is a beautiful
strange sound, and so old and so wonderful that in it you will hear
the beating of the heart of the world thousands of years ago. But
first I will tell you the story of the Four Swans, and then we can
speak again of the strange singing I have heard at times, and that
you often shall hear.”
The Dedannans were the most wonderful and happy people in
the world till they became discontented with what the unknown and
beautiful gods had given them. Then they split into sections, and
some sought one vain thing and some another, and in the end all
found weariness. Their wise men knew that as long as they were at
one no enemy could prevail against them; but it has never been the
way of the unquiet to believe in the old wisdom, and so feuds arose,
and the Fairy Host itself—as the great array of the warriors of the
Tuatha-De-Danann was called—ceased to be invincible, because the
banners blew to the four winds.
Not all their ancestral sojournings in the dim lands of the East,
nor in the ages of their migration to the country of fjords which has
its whole length in the sea, nor in Alba, that is now Scotland, nor
Eiré, that is now Ireland, not all they had learned in their remote
past helped them against the undoing of their own folly.
It has been said that the Dedannans never fought against men
till the Milesians, the warriors of Miled out of some land in the south
—the land, mayhap, we know as Spain—came against them upon
the banks of a river then as now called the Blackwater, in the heart
of Meath.
But before the Dedannans themselves ever saw it, the Green
Isle was held by the Firbolgs, a terrible, heroic race, but allied to the
dark powers. Some say they became demons, after they were
defeated in many battles by the Tuatha-De-Danann, and at last
wholly conquered. But so old is this ancient tired world, that long
before the Dedannans and the Firbolg people fought for sovereignty,
the Firbolg had striven with and overcome an earlier race—the
Nemedians—which had come to Ireland under a mysterious king,
Nemed. None knows who Nemed was, though he may have been a
god, seeing that he overcame that most ancient people who were
the first to set foot in the Isle of Destiny, under Partholan, a son of
him who was called the Most High God.
Whether it be true or not that the overlordship of the world was
meant for man, certain it is that man has thought so. Therefore are
all stories of his cosmic strife coloured by this destiny. Terrible and
mighty were the Firbolgs, fierce and terrible and beautiful were the
Dedannans, but now there is no rumour of either, save in the wail of
the wind, or in the stirring of swift, stealthy feet in the moonshine.
But now, Peterkin, I will tell you about the children of Lir, who
was one of the great princes of the Dedannans.
The first great battle between the Milesians and the Dedannans
had been fought, and the ancient people, for all their secret powers
of wonders and enchantment, had been defeated. Throughout all
Erin—for Ireland at that time was called either Eiré (Erin), or Fola, or
Banba, after three great queens—there was a rumour of
lamentation. It was the beginning of the end, though few save the
wisest Druids foresaw it.
But the people knew that their dissensions were the cause of
their sorrow. They clamoured for one king to be overlord, so that the
whole Dedannan race might be united.
There were five great princes who claimed to be king by right.
Of these two were greater than the others—Bove Derg, son of
Dagda, one of the divine race (and some say a mighty god), and Lir
of Shee Finnaha. In the end Bove Derg was elected Ardree, or High
King. Even Midir the Haughty acquiesced in this judgment of the
people, but Lir was wroth and held aloof. All the princes and warriors
were fierce with Lir because he had left the assembly in anger,
paying heed to no one, and scornfully ignoring the majesty of the
king. A hundred swords of proven heroes leapt before Bove Derg, for
all were eager to follow Lir and destroy him and his, because of the
insult to the king and to the voice and freewill of the people. But
Bove Derg was a wise and generous prince, and forbore. This was
well. For in time a great sorrow came upon Lir. When the rumour of
this sorrow reached Bove Derg, he saw how he might win over Lir.
“In my house,” he said, “are my three foster-children, the
daughters of Aileel of Ara. Each is beautiful, all are wise and sweet
and noble. Let messengers go to Lir, and tell him that my friendship
is his if he will have it. Surely now he will submit to the will of the
people. And he can have to wife whomsoever of the three daughters
of Aileel he may choose, if so be that she will gladly and freely go
with him.”
Lir was glad at this message. He called his warriors together, and
in fifty chariots he and they set forth. They rested not till they came
to the palace of Bove Derg, by the Great Lake, nigh to the place now
called Killaloe. Great were the rejoicings, and again at the alliance
which after many days was made between the king and Lir.
When Lir saw the three daughters of Aileel, he could not say
who was the most beautiful.
“Each is alike beautiful, O king,” he said; “and I cannot tell which
is best. But surely the eldest must be the noblest of the three, and
so I will choose her, if so be that she gladly and freely come with me
as my wife.”
And so it was. When Lir returned to his own place, he took with
him as his wife the beautiful Aev, who was the eldest of the
daughters of Aileel of Ara, and was foster-child of Bove Derg the
king. From that day, too, a deep and true friendship lived between
Bove Derg and Lir.
In the course of time Aev bore him twin children, a son and a
daughter. The daughter was named Fionula, because of her lovely
whiteness, and the son was named Aed, for that his eyes, and the
mind behind his eyes, were bright and wonderful as a flame of fire.
And at the end of the second year Aev again bore twin children.
Both were sons, and they were named Fiachra and Conn. But in
giving them life she lost her own.
Lir was in bitter distress because of her death, and for the
reason that his four little children were now motherless. He was
comforted by Bove Derg, who not only gave him friendship and
kingly aid and counsel, but said that he should not be left alone to
mourn, and that his little ones should not go motherless.
Thus it was that Aeifa, the second of the daughters of Aileel of
Ara and foster-child of Bove Derg the king, came to Shee Finnaha
and espoused Lir.
For some years all went well. Aeifa nursed the children, and
tended them. They were so fair and beautiful that the poets sang of
them far and wide. Even Bove Derg loved them as though they were
his own. As for Lir, so great was his love, that he could not bear to
be long apart from them. His sleeping-room was separated from
them only by a deerskin, and this often he pulled aside at dawn, so
that he might see his dear ones, and perchance go to them to talk
lightly and happily, or to caress them with loving laughter and joy.
Lir was never sad save when the four children went south to the
Great Lake to stay awhile with Bove Derg, who in his turn was filled
with melancholy when the time came for them to go home again.
Nor was Lir ever so proud as when, at the Feast of Age, whenever
that festival came to be held at Shee Finnaha, the king and the
nobles and the warriors delighted in the beauty and marvellous
sweet charm of Fionula and Aed and Fiachra and Conn. Thus it was
that the saying grew: “Fair as the four children of Lir.”
But there was a deep shadow behind all this joy. This shadow
came out of the heart of Aeifa. In love there is sometimes a
poisonous mist. It is what we call Jealousy. At first Aeifa truly loved
her step-children. But as the years lapsed, and when Fionula was
passing from girlhood into maidenhood, the wife of Lir was filled
with anger against the four children. She was bitter at heart because
their father loved them with so great a tenderness, and that even
the king himself cared for them above all else, and because all the
Dedannans had joy of them.
The time came when this dull smouldering fire, which she might
have overcome had she loved nobly and not ignobly, burst into
flame. This flame withered her heart, and rose thence till it obscured
her mind.
She had something of the old druidical wisdom, but she feared
the counter-spells of others wiser than herself. Nevertheless she set
herself to learn one or other of the ancient incantations against
which even the gods are powerless to avert evil from men and
women.
While she was brooding thus—and for weeks and even months
she lay in the house of Lir as one stricken with some terrible ill—her
rage grew till she could no longer endure the sight of her husband or
of her step-children.
One day she arose and ordered the horses to be yoked to her
chariot, and bade a small chosen company to be ready to go with
her and the four children to the Great Lake: for, she said, she wished
to see Bove Derg, her foster-father, and to take the children to
gladden his heart. Lir was sad, and sadder still when he saw the
tears in Fionula’s eyes. In vain he asked her why this drifting dew
was there instead of the sun-bright laughing glancings he joyed so
much to see. She would not answer: for all she could have said was
that in a dream she had fore-knowledge of the evil desire of Aeifa to
kill her and her brothers. Perhaps, she thought, it was but a dream.
She loved honour, too, and would not put her father against his wife
because of a visionary thing that came to her in the night.
It was when they were in a deep gorge of the hills that Aeifa
was overcome by her hatred. Turning to her attendants, she offered
them wealth and whatsoever they desired if only they would slay the
four children of Lir then and there, inasmuch as these had come
between her and her husband, and had therein and in all else made
her life a burden to her.
The attendants listened with horror. Not one there would lift a
hand against Lir’s children. What was wealth, or any fruit of desire,
compared with so foul a treachery, so terrible a crime! The oldest
among them even warned Lir’s wife that the very thought of such
evil would surely work a dreadful punishment against her.
At this, Aeifa laughed wildly. Then, seizing a sword, she strove to
wield it herself against the defenceless children. The three boys
stood, wondering. In the blue eyes of Fionula there was something
the wife of Lir dreaded more than the wrath of husband or king.
Dashing the sword to the ground, she cried to the chariot-driver to
make haste onward.
No word was spoken among them till they reached the hither
2
end of the Lake of Darvra. There Aeifa called a halt, and the horses
were unyoked for rest. It was a fair and warm day, so when she
bade the children undress and go into the water, they did so gladly.
While their white sunlit bodies were splashing in the lake, she
took from beneath the rim of the chariot, where she had secreted it,
a druidical fairy wand. This had been given her by a Dedannan
druid, and was a dreadful thing to possess, for its power was of the
black magic, against which nothing might prevail. Going to the side
of the clear water, she struck lightly with the wand the shoulder of
each of the four children; and, as she touched Fionula, Lir’s fair
young daughter became a beautiful snow-white swan, and as she
touched Aed and Fiachra and Conn, Lir’s three young sons were
changed like unto Fionula.
A cry of lamentation arose from the witnesses of this deed,
though none guessed that the ill was so dreadful and beyond the
reach of druidic skill, nor did the children know at first what evil had
befallen them, but swam to and fro laughing in their hearts, and
rejoicing in their white feathers and in their swift joy in the water.
But when Fionula heard the lamentation, and looked upon the evil
face of Aeifa her stepmother, she knew that the hour of doom had
come.
Then Aeifa stretched out her arms, and chanted these words:

“Lost far and wide on Darvra’s gloomy water,


With other lonely birds tost far and wide.
For nevermore shall Lir behold his daughter,
And never shall his sons lie by his side.”

Then while all on the shore stood in deep grief, Fionula swam close,
and looked up into the white face of Aeifa, which was whiter then
than the whitest breast-feathers of these poor bewildered swans.
“This is an evil deed thou hast done, O Aeifa,” she said. “Out of
a bitter heart thou hast wrought this cruel wrong upon us who love
thee, and have never done or wished thee ill. Nevertheless it is not
our ill that shall endure for ever, but thine own evil. There shall be
an avenging terrible for thee, whensoever it come.”
It was then that Fionula for the first time sang as a swan, and
even then the marvellous sweet singing brought both gladness and
tears into the hearts of those who heard.

“In the years long ago, long ago now, long ago,
We were loved by her who dooms us to this evil cruel woe:
Who with magic wand and words
Hath changed us into birds—
Snow-white swans to drift and drift for evermore
Homeless, weary, tempest-baffled hence from shore to shore.”

A silence followed this melancholy singing. Then at last Fionula


spoke again.
“Tell us, O Aeifa, how long this doom is to be upon us, so that
we may know when death shall come to take away our suffering?”
Then because in that day it was not honourable to refuse the
truth when asked, Aeifa did as Fionula prayed of her.
“Better would it be for thee and thy brothers to know nothing
and to hope much. But since thou hast asked this thing I will tell it:
“Three hundred years shall ye, Fionula, and Aed and Fiachra and
Conn, who are now four white swans, abide here on this great
lonely, desolate lake of Darvra. For three hundred years thereafter
shall ye inhabit the wild sea of Moyle, which lies between the
Stairway of the Giants, and the bleak shores of the great headland
3
of Alba. And for yet another three hundred years ye shall drift to
and fro among the storm-swept seas off the rocky isles to the west
of Erin.
“Furthermore, ye shall be idle sport for the storms until Lairgnen,
a great prince of the north, has union with Decca, in the south: until
4
the Taillkenn, the new prophet, shall come to Erin and preach a
new faith that shall chase away the old gods: and until ye shall be
filled with fear and wonder at a strange sound, that shall be the
ringing of the first Christian bell. All this I tell ye because of the
prophetic sight I have, and that has come to me through the druidic
wand wherewith I have changed ye into four wild white swans. And
this too, I say unto ye, Fionula and Aed and Fiachra and Conn, that
neither by your own power nor by your prayers, nor by mine, nor by
the power of Lir and Bove Derg, nor by that of all kings and princes
and druids whatsoever; no, nor by any god, nor by any power in
heaven or earth, can ye be freed from this spell I have put upon ye,
until the times and events I have spoken of shall be fulfilled.”
When Aeifa had ceased speaking, there was no sound to be
heard, save the lap-lapping of the lake-water upon the shore. Of the
company of those with her none spake a word, each dreading the
evil that was sure to come. At last a faint sobbing came from amid
the sedges, where the young brothers nestled by the side of Fionula,
who had already begun to mother these dear ones whom she loved.
When she heard these sobs, Aeifa’s heart smote her. Even if she
would, she could not now undo the age-long spell she had set upon
the children of Lir. But one thing was left to her that she might do
with the fairy wand, which could be moved once again if stirred by
the breath of her will.
“Hearken, O children of Lir,” she cried, “for I have yet one thing
to say: and that out of the sorrow in my heart because of the doom
I have put upon ye. Although ye are turned into wild swans, ye shall
not become as the desert birds, and have no speech but the savage
screams and cries of the wilderness. Ye shall keep for ever your own
sweet Gaelic speech, and so be able to talk each with the other, and
with any of the human kind whom ye may meet. And more than
this, ye shall be able to sing the most sweet, plaintive songs, and
the most wild, haunting music that ever man has heard; so that all
whose ears list shall be lulled into deep sleep, or into a peace
sweeter than slumber itself. Nor shall the law of the soulless brutes
be upon you, but ye shall be Fionula and Aed and Fiachra and Conn,
the children of Lir.”
Having said these words, Aeifa raised her arms and chanted this
song:

“Speed hence, speed hence, O lone white swans,


Across the wind-sprent foam;
The wave shall be your father now,
And the wind alone shall kiss your brow,
And the waste be your home.
Speed hence, speed hence, O lone white swans,
Your age-long quest to make;
Three hundred years on Moyle’s wild breast,
Three hundred years on the wilder west,
Three hundred on this lake.
Speed hence, speed hence, O lone white swans,
And Lir shall call in vain;
For all his aching heart and tears,
For all the weariness of his years,
Ye shall not come again.
Speed hence, speed hence, O lone white swans,
Till the ringing of Christ’s bell;
Then at the last ye shall have rest,
And Death shall take ye to his breast
At the ringing of Christ’s bell.”
Having sung this farewell song, Aeifa ordered the horses to be
yoked again to her chariot.
This done, she drove away westward, nor was there a single
heart in those who accompanied her but was filled with sorrow and
foreboding.
When the lake was no longer visible, and the gloom of the
mountains came down upon the pass which led towards the
westlands where Bove Derg dwelled, a faint wild aerial singing was
heard, delicate as tinkling cowbells on far hill-pastures.
Before Aeifa drew near to the great dun of Bove Derg, she put
each of her company under a solemn bond of silence as to what she
had meant to do and not done, and as to what later she had done;
and because of the lealty of the bond to a woman, and also because
of the fear of each towards the druidical fairy wand that she still
carried, the oath was taken by one and all.
Therefore it was easy for Aeifa to mislead Bove Derg as to the
reason why she had not brought the children of Lir with her.
Nevertheless he doubted greatly that his foster-daughter deceived
him, for he could not think that Lir his friend would so mistrust him
as to refuse to let Fionula and her brothers accompany their
stepmother.
So, secretly, he sent a swift messenger across the hills and
straths to the dun of Lir.
Lir was at once wroth and filled with fear when he heard that
Aeifa had reached the dun of Bove Derg without the children. Some
treachery surely had been done, he cried.
Then, calling together a company, he set forth with all speed.
Towards sundown, the cavalcade came upon the wide desolate
shores of the great lake of Darvra.
“What is that sound?” cried Lir.
“It is the wind in the reeds, O Lir,” answered a spearman by his
side.
“The wind in the reeds is a sweet sound to hear, Coran, but
never have I heard any wind that could make so sweet a music.”
“It is the little gentle lapping of the wavelets by the west wind, O
Lir.”
“It is no gentle lapping of the wavelets by the west wind, Coran,
nor yet is it the wind in the reeds; but that is the voice of Fionula
singing.”
And as the sound grew clearer, all heard it, and soon the words
were audible:

“Behold the Danann host is on the shore,


Seeking for those now lost for evermore;
But let us haste towards that proud array
And tell the tidings of this fatal day.”

And while the song was still in the ears of all there, Lir gave a
great cry and pointed to where above the midmost of the lake four
wild swans were winging swiftly towards the eastern shore.
When he heard from Fionula—and he knew her voice, which was
sweeter than any other he had ever heard—of all that had
happened, and of the strange and dreadful doom that was put upon
her and her brothers, he fell sobbing to the ground. From all his
company the keening of a bitter lamentation arose.
Alas, as he knew well, not even the great length of years which
the Dedannan folk lived—and a score of years is to them what one
year is to us—would enable him to see his dear ones again. Three
hundred years on Darvra, these he might mayhap live to see; but
not the three hundred years on the bleak and wild region of the
Moyle, nor the three hundred on the wild tempestuous western seas,
nor the far-off day when a prophet called Taillken would come to
Erin with a new faith, and in the glens and across the plains would
be heard the strange chiming of Christ’s bell.
Yet was he comforted when he heard that his children were to
keep their Gaelic speech, and to be human in all things save only in
their outward shape. And glad he was that they were to be able to
chant music so wild and sweet that all who should hear it would be
filled with joy and peace. For music is the most beautiful and
wonderful thing in the world, and is the oldest, as it will be the latest
speech.
“Remain with us this night, here by the lake,” said Fionula, “and
we shall sing to you our fairy music.”
So all abode there, and so sweet was the song of the children of
Lir, that he himself and all his company fell into a deep, restful
slumber. All night long they sang their sweet sad song, and were
glad because of the quiet dark figures by the lake-side lying
drowned in shadow. Slowly the moon sank behind the hills. Then the
stars glistened whitelier and smaller, and a soft rosy flush came over
the mountain crest in the east. Then Lir awoke, and Fionula and Aed
and Fiachra and Conn ceased their singing, and spread out their
white pinions to the light of a new day, and ruffled their snowy
breasts against the frothing that the dawn-wind made upon the lake.
Lir took a harp from one of his followers, and sang a song of
farewell to his children. At that singing all awoke, and the heart of
each man was heavy because of the doom that had fallen upon the
children of Lir.
He sang of the fateful hour when he had taken Aeifa to wife, and
of the cruel hardness of her heart, that thus out of jealous rage she
could work so great and unmerited evil. And what rest could there
be for him, he chanted, since whenever he lay down in the dark he
would see his loved ones pictured plain before him: Fionula, his
pride and joy; Aed, so agile and adventurous; the laughing Fiachra;
and little Conn, with his curls of gold.
Then with a heavy heart indeed Lir went on his way. Before he
and his company entered the great pass at the western end of
Lough Darvra, he looked back longingly. In the blue space of heaven
he saw four white cloudlets drifting idly in a slow circling flight.
“O Fionula,” he cried, “O Aed, O Fiachra, O Conn, farewell, my
little ones! Well do I know that you have risen thus in high flight so
that my eyes may have this last glimpse of you. Nevertheless I will
come again soon.”
It was a weary journey thence to the dun of Bove Derg, but all
weariness was forgotten in wrath against Aeifa.
No sooner had Lir spoken to the king, no sooner had the king
looked at the face of Aeifa as she heard the accusation, than Bove
Derg knew that the truth had been told, and that Aeifa was guilty of
this cruel wrong. Turning to his foster-daughter, he exclaimed, in the
hearing of all:
“This ill deed that thou hast wrought, Aeifa, will be worse for
thee than all thou hast put upon the children of Lir. For in the end
they shall know joy and peace, while as long as the world lasts thou
shalt know what it is to be lonely and accursed and abhorred.” Then
for a brief time Bove Derg brooded. There was naught in all the
world so dreaded in the dim ancient days as the demons of the air,
and no doom could be more dreadful than to be transformed into
one of those dark and lonely and desperate spirits that make night
and desolate places so full of terror. At last the king rose. Taking his
druidical magic wand, he struck Aeifa with it, and therewith turned
her into a demon of the air. A great cry went up from the whole
assemblage as they saw Aeifa spread out gaunt shadowy wings, and
struggle as in a sudden anguish of new birth. The next moment she
gave a terrible scream, and flew upward like a swirling eagle, and
disappeared among the dark lowering clouds which hung over the
land that day.
Thus was it that Aeifa became a demon o the air. Even now her
screaming voice may be heard among the wild hills of her own land,
on dark windy nights, when tempests break, or in disastrous hours.
But out of a wrong done the gods may work good. So was it
with the Dedannans.
For not only Lir, and all his people, but Bove Derg and a great
part of the nation assembled by the shores of Lake Darvra, and
there pitched their tents, which afterwards grew into a vast rath,
wherein the king builded a mighty dun.
For Lir and Bove Derg had vowed that henceforth they would
live their years by the shores of Darvra, where they might converse
with their dear ones, and where they might listen to the sweet
oblivious songs which Fionula and her brothers sang to the easing of
the heart, and the silence of all pain and weariness.
But so great was the rumour of this marvel that all Erin heard of
it. The Milesians in the south agreed to a long truce of three
hundred years; and came and dwelt in amity with the Dedannans,
for they too loved the sweet and wonderful music of the white
swans that were the children of Lir.
“Three hundred years yet may we live,” said Bove Derg to Lir,
“and as I am a king, I swear never to leave the lough of Darvra
while the four swans that are thy sons and daughter inhabit it. The
heavy years shall pass for us, listening to their beautiful sweet
singing; and therein we shall know peace and joy.”
“So be it,” said Lir, and he spoke the truth, for in that day the
Dedannans lived to a great age; some say to three hundred, some
to five, some to seven hundred years.
The years went by, one after the other, and by tens and by
scores, and still Lir and Bove Derg and the Dedannans and Milesians
dwelled by the shores of Lake Darvra. For never in the world’s
history has there been chronicle of so sweet a singing as that of the
four children of Lir. All day the swans discoursed lovingly with their
father and Bove Derg, and their kith and kin, and all who sought
them; and each night they sang their slow, sweet, fairy music—a
music so wonderful and passing sweet, that all who listed to it forgot
weariness and pain and bitter memories and the burden of years,
and fell into a deep restful slumber, whence they awoke each
morrow as though they had drunken overnight of the Fountain of
Youth.
The hair of Lir and Bove Derg was long and white, and almost
had the Dedannans and the Milesians forgotten their ancient enmity,
when a day of the days came whereon Fionula called aside her three
brothers.
“Dear brothers,” she said, as she looked sadly at the three
beautiful white swans, and at the four drifting shadow-swans in the
depths of the lake, “dear brothers, do you know that the time has
come when we must put away our happiness as a dream that has
been dreamed? For now the three hundred years of our sojourn here
are at an end, and at dawn to-morrow we must arise and wing our
sad flight across the dear lands of Erin, till we come to the wild and
stormy waters of the sea-stream of the Moyle.”
Aed and Fiachra and Conn made so loud and bitter lamentation
at this that all heard, and soon the whole host that was encamped
there filled the region with long keening cries of grief, and a
sorrowful mourning strain as of the melancholy wind among the
hills.
But once more all were soothed that night into deep slumber
and happy peace, because of the slow, sweet, fairy music of the
chanting swans.
At dawn, the four swans arose, and with their white pinions
circled high above the lake, glittering as they soared into the
sunflood as it swept across the summits of the eastern hills.
“Farewell! farewell! farewell!” they chanted, and at that sad
sound all the Dedannan host and all the Milesians, headed by Lir and
Bove Derg, kneeled along the lake pastures and amid the reeds and
sedges.
Then Fionula, as she and her brothers slowly descended in wide-
sweeping curves, sang this song:
“Farewell! Farewell! Farewell!
Far hence we lost ones go:
Hearken our knell,
Hearken our woe!
Farewell! Farewell! Farewell!
With breaking hearts we flee:
For none can tell
Our wild home on the sea.
For ages on the Moyle,
In loneliness and pain,
Our feet shall tread no soil,
Wild wave, wild wind, wild rain.
For ages in the west,
Fierce storms and fiercer cold
Shall be alone our rest,
While ye grow old.
Let not our memories pass,
O ye who stay behind—
Who are as the grass
And we the wind.
Farewell! Farewell! Farewell!
Far hence we lost ones go:
Hearken our knell,
Hearken our woe!”

As Fionula ceased this song, she and her brothers swept so close
to the water’s edge that their white wings made a little dazzle of
spray. Then with swift pinions they rose again, and soared in great
spirals of flight, till they gleamed against the morning blue like four
white banners adrift before a skiey wind.
Then for a brief while they suspended on outspread wings, and
looked longingly down upon the dear ones and all their kith and kin,
who on their part could scarce see the four white swans for the mist
of tears that was before all faces.
Suddenly they swung hither and thither, like foam tossed by a
tidal wind, and then flew straight to the northward. Soon they were
but white specks; then the blue closed in upon them, as the wastes
of the sea close at last behind the hulls of drifting ships.
Before the torch of a stormy sun sank that night amid the tossed
green billows of the Moyle, there where the sea flows to and fro
betwixt Erin and Alba, the children of Lir drooped their weary wings.
Their home now was the running wave. In darkness and loneliness
and sorrow, they floated close to each other, waiting for the dawn to
steal into that first night of bitter exile.
From that day they were severed from those who loved them. Of
a truth, there was keening and lamentation and sorrow by the
shores of the lough of Darvra. At the last, as the snow melts, the
great host of the Dedannans and Milesians passed away: to the
westward, some; others, to the south.
As for Bove Derg and Lir, their white hairs and the grey ashes of
their lives were the mournful refrain of many a song on the lips of
wandering bards.
* * * * *
There were tears in the eyes of Peterkin when Ian Mor ceased
speaking. His heart was sore because of Fionula and Aed and
Fiachra and Conn.
Nevertheless, he too would be glad to be a swan for a time, if
only so as to be able to soar into the blue spaces of the sky, and to
spread white wings over the dancing waters, and to move through
them swifter than any boat. With what joy he had once climbed on
to the fan of an old windmill, and slowly revolved through the hot
August air, which winnowed around him a coolness like the flowing
of wind over the summit of a hill.
A bright shining came into his eyes, then laughter bubbled to his
lips.
Eilidh looked at him, half in mock reproof, half rejoicingly.
“Peterkin, why do you laugh?”
“Oh, for sure, dear, it’s not laughing I am at the poor swans, but
at the face of Old Nanny, my nurse, when she came out of the
cottage in the glen and saw me lying flat and holding on to the fan
of the windmill, with my hair all blown back, and both my legs
hanging in the air.”
“Some day you will kill yourself, Peterkin,” said Eilidh gravely.
“Then I’ll be a swan! and I’ll fly round and round Iona, and
whenever you or Ian want to go to the mainland, I’ll take you on my
back.”
Suddenly Peterkin sprang to his feet, and jumped to and fro,
clapping his hands.
“Ah, how I would love it!” he exclaimed.
“Love what, dearie?”
“Love to see Ian fall off my back and go plump in among the
herrings in the Sound! What a splash he would make!”
“And poor Ian—— Why, he might be drowned, Peterkin!”
“Oh, no; I would swoop down the way a gannet does when it
sees a fish, and would scoop him up with my bill.”
The picture was too much for Peterkin. The thought of grabbing
the dripping half-drowned Ian in his bill, and of soaring away with
him to the white dry sands, was better than any dream of the fairies
he had ever had, even than that when he rode a fairy horse in the
guise of a white mouse, with grasshoppers for hounds, and a great
bumble-bee as a wild boar for the occasion. He threw himself on the
floor in front of the hearth, and rolled over and over, contorting his
small body into alarming convulsions, clapping his hands, and
laughing, laughing, laughing.
Eilidh, too, let the laughter take her, and then Ian found it
sweet; and soon the little room was full of joyous laughter upon
laughter, and of the leaping flame-light from the blazing log on the
peats, and of the dancing of the shadow-men in the corners and up
and down the walls.
“The swans! The swans!” cried Peterkin suddenly, as he grabbed
wildly at some shadowy shapes which slid along the floor. But these
swans proved as tantalising as the wind-shadows on the grass which
so often he chased, and suddenly in a flash they disappeared
altogether. They seemed to spring right into Ian Mor; at any rate it
was in his arms that Peterkin found himself.
“Where are the shadows? Where are the shadows, Ian?” he
cried: “I believe you are hiding them inside yourself! Where are
they? Where are they?”
“Why, you boykin, where could they be?”
“They are in your heart, Ian! I know they are! I see them! I see
them!”
Ian glanced at Eilidh. Then, putting his arm round Peterkin, he
laid his lips against his downy cheek and whispered:
“Yes, my little lad, you’ve guessed right.”
“Then why don’t you chase them out, Ian?”
Again Ian Mor glanced at Eilidh.
“They live there, lennavan-mo. They jumped out because of your
laughter, but they are back now.”
“Then I’ll be laughing often, Ian dear, and some day I’ll catch
them and drive them out into the sunshine, and then they’ll melt—
ay, ay, they’ll melt for sure, Ian, and what will you be after doing
then?”
“Well, like Fionula and the wild swans, Peterkin, I’ll rise up and
soar away on the great flood of the sun across the sea till I come to
Hy Brásil, the Isle of Youth far away in the West.”
“Yes, I know,” Peterkin said gravely: “Hy Brásil: Eilidh told me
that is where she and you are going to live. Will you take me there
too?”
“Yes, you will come there too, mochree, some day.”
“But with you — when you and Eilidh go?”
“Perhaps we’ll not be going there together, Peterkin. But we
won’t be forgetting our dear little Peterkin. We’ll be on the shore
looking out for you when you come.”
“Why are your eyes wet, Ian, and Eilidh’s too?”
“Why, you unfeeling little wretch, it’s because we have left the
poor swans, Fionula, and Aed, and Fiachra, and Conn, alone on the
rough seas of the Moyle all this while.”
“Tell me, tell me now about the children of Lir. Did they see any
one up there? Were they ever happy?”
“Eilidh knows the rest of the story as well as I do, Peterkin, so
go and sit in her lap while she tells it to you and to me.”
With that, Ian Mor rose and put another log on the red peats. A
shower of sparks shot up into the dark hollow of the chimney.
Peterkin laughed.
“Hush!” whispered Eilidh, with smiling eyes: and then in her
sweet, low voice resumed the tale of the Children of Lir, from where
Ian had stopped.
It was at the edge of winter when Fionula and her brothers
reached the wild bleak seas of the Moyle.
At first there was no too bitter cold or too fierce
tempestuousness to make their evil lot still more hard to bear; but
sad indeed were their hearts as day after day they saw nothing but
the same grey skies, the same grey wastes and dark sullen waves,
the same bleak, rocky coasts inhabited only by the cormorant and
the sea-mew. Never to see a familiar face, never to hear a familiar
voice: to dwell from morning dusk till evening dark in loneliness and
sorrow—that, indeed, was a hard fate upon the four children of Lir.
From hunger and cold, too, they suffered much. No longer could
they be cheered as they were on Lough Darvra, and often and often
they lamented that their doom could not have permitted them to
remain as swans indeed, but as swans on that now dear and home-
sweet inland sea of Darvra.
Day after day passed, but while their misery and want did not
grow less they were not yet tortured by wintry storms and bitter
frosts.
But one forlorn afternoon a terrible congregation of clouds, black
and heavy and flanked with livid gleams, appeared above the
horizon and slowly invaded the whole west, and then all the sky
northward and all southward.
Fionula saw that a great tempest was nigh, so she called Aed,
and Fiachra, and Conn, to come to her side.
“Dear brothers,” she exclaimed, “the storm that will soon be
upon us will be worse than any we have yet known. Hardly can we
hope not to be driven far apart. Let us agree, therefore, to meet
somewhere, if so be that we are not utterly destroyed. For though
Aeifa, our cruel stepmother, doomed us to these long ages of
suffering, it may well be that even her potent spell is not strong
enough against death: and death may come to us through famine,
or cold, or in the drowning wave.”
At first the brothers could answer nothing. Then Aed spoke.
“Thou art wise, dear Fionula. Let us, then, fix upon the rocky isle of
Carrick-na-ron, as that place is well known to each of us, and can be
descried from a great way off.”
Thus it was that Carrick-na-ron was made their place of meeting,
if so be that in the blind fury and confusion of the tempest they
should be driven the one from the other.
This was well: for that night, with the darkening of the night into
a hollow of starless blackness, a terrible tempest swept over the
seas, and lashed them into foam and into vast heaving, rolling,
swaying billows. Amid the noise of the waves, and behind the
screaming of the wind, the four weary rain-drenched bewildered
swans could hear the crashing of the thunder and see the wild fitful
blue glare of savage lightnings.
Before midnight they were whirled this way and that by the
fierce paws of the gale. Soon they were separated, and with
despairing cries, each swept solitary through the night. In the heart
of each of the children of Lir there was little hope of any morrow. All
nearly died of weariness and despair. Nevertheless dawn broke at
last, and with the first coming of light the tempest passed away.
When the sun rose the waters were almost smooth again. A
sparkling came into the crest of every wave. The sea blued.
Fionula was the first to descry the rocky isle of Carrick-na-ron,
and gladly she swam towards it, for she was now too weary to fly.
Eagerly she hoped to find her brothers there, safe-havened. Alas,
there was not a sign of any, not even when she flew to the summit
of the highest rock and looked far and wide across the wilderness of
waters.
Great sorrow was hers, for sure, when she beheld nothing but
wave upon wave, wave upon wave, till on the far horizon the long
low line of sea climbed into the sky.
A song of mourning broke from Fionula, so sad and sweet and
despairing that the gannets and sea-mews and dark fierce
cormorants wheeled around Carrick-na-ron, wondering at the marvel
of this wild swan, with the strange remote voice of the human kind.
It was a song of farewell.
When Fionula ceased her lament she looked once more across
the wastes of the sea. Suddenly she uttered a glad cry, for she
descried Conn swimming slowly towards the rocky isle, slowly, and
with drooping head, for he was drenched with the salt brine, and so
weary that he could scarce move.
Hardly had she welcomed him with joy, and helped him to reach
a flat ledge of rock whereon the sunlight poured with healing
warmth, than she saw Fiachra desperately striving to make his way
towards them, but so far spent that it seemed as though death
would overtake him before he reached the foam-edged rocks.
Fionula sprang into the running wave, and soon was beside Fiachra,
aiding him to her utmost. With difficulty she helped him to the ledge
where Conn crouched in the sun, but so weak was he that when he
was spoken to he could utter no word in reply. Fionula looked with
pity upon her two young brothers. It was hard for her to see their
unmothered pain and weariness. So she spread out her broad white
pinions, and gave the warmth of her body to the two drenched and
shivering swans.
“Ah!” she exclaimed, as she crouched on the ledge, with Fiachra
nestling by her right side and Conn by her left; “ah! if only Aed were
here too, all might yet be well. And even if it be death, sweeter far
that we might all perish together.” It was as though her loving prayer
were answered, for before long she descried Aed swimming swiftly
through the sunny foam-splashed seas. He, at least, she saw with
joy, had not suffered as his younger brothers had done, for he came
on with head erect and his white plumage all unruffled and
dazzlingly ashine.
Nevertheless, Aed, too, was glad to rest in the sunshine, so
Fionula placed him under her breast.
Noon found them thus: Fionula with sad eyes staring out across
the wastes of windy seas; under the warm feathers of her breast,
Aed; and close nestled to the warm down of her sides, Fiachra and
Conn. She heard their low breathing as they slept, and that they
might sleep the deeper and longer she sang her low, sweet, fairy
music:
Sleep, sleep, brothers dear, sleep and dream,
Nothing so sweet lies hid in all your years.
Life is a storm-swept gleam
In a rain of tears:
Why wake to a bitter hour, to sigh, to weep?
How better far to sleep——
To sleep and dream.
To sleep and dream, ah, that is well indeed:
Better than sighs, better than tears;
Ye can have nothing better for your meed
In all the years.
Why wake to a bitter hour, to sigh, to weep?
How better far to sleep——
To sleep and dream, ah, that is well indeed!

This and other songs Fionula chanted low throughout the day, till
at last she too was overcome by her weariness; and she slept.
At the rising of the moon, all awoke. Full glad were Aed and
Fiachra and Conn that their tribulation was over; only Fionula knew
that the doom which Aeifa had put upon them held worse things,
and many, in store for them.
For some days thereafter there was peace. Then a snow-whisper
came, and the inland hills and the peaked summits of the isles were
white. The cold grew deeper day by day; at each dawn the frost bit
with a keener grip. The bitter hardships of the children of Lir were
now more almost than they could bear. Nevertheless, they had a yet
more dreadful trial to endure: for at mid-winter there came a
tempest of whirling snow and icy wind so fierce and terrible, that for
a day and a night the waves were strewn with the dead bodies of
sea-mews and terns. Nothing the four swans had ever suffered was
like unto what they suffered at this time.
But when Fionula had again found and sheltered her dear ones,
and mothered them with her great love, she knew that whatever
their sufferings they would now surely endure until the end. Had
they been subject to the mortal law, they could not have survived
that dreadful day, and still more awful night.
And so another year passed. The worst sorrow of the children of
Lir was their great loneliness, a thing more bitter than hunger or
thirst or any privation. They longed for their kind as the first white
flowers of the year long for the sun. When mid-winter came again a
terrible frost arose. All the north isles were like black bosses in a
gleaming shield, for sheets of ice covered the seas, and each island
was gripped as in an iron vice. Day by day the cold grew more
terrible. On the morrow of the ninth day the four children of Lir
thought that the end of their misery was at hand. The whole sea
was one solid floor of ice; the isle of Carrick-na-ron, where they
were, was like a black iceberg; into ice lapsed each faint failing
breath that they drew with ever greater pain.
Each morning they had waked to find their feet frozen to the
rock, and even the edges of their wings; and a bitter thing it was to
tear themselves free, and to leave clinging to the rock the soft
feathers of their breasts and the outer quills of their wings and the
skin of their feet.
How fain each was of death! How gladly they would have passed
away from the world of the living, though in exile, and longing with
aching hearts to see once more their own dear land and the faces of
those whom they loved! But their doom was on them, and they
could not leave the sea of Moyle, nor could they win death.
The brave heart of Fionula knew this. She knew too what cruel
pain it would give her and her brothers to swim through the salt
seas with their bleeding wounds, for the brine would enter them and
cause agony. Nevertheless, she led them forth towards the coast of
the mainland. There they found a fjord and a haven amid the pine-
clad shores, and before long their wounds were healed, and the
feathers on their wings and breasts grew again.
But of what avail to tell the tale of all their years? Fionula saw
that while they must ever return each night to the sea of Moyle till
the three hundred years were over and done, they might fly as far
and wide as they could between dawn and dusk. Mighty and strong
were they now upon the wing, and fit to endure the slashing of
rains, the buffetings of wild winds, the whirling briny sleet of the
seas, and the cold of the high forlorn spaces of the lonely sky.
Far and wide therefore they roamed, sometimes along the foam-
swept headlands of Alba, sometimes by the stormy coasts of Erin,
sometimes for leagues and leagues out into the vast dim wilderness,
wherein, so men said, Hy Brásil lay—Hy Brásil, the Isle of Rest, the
Isle of Joy, the Isle of Youth Eternal.
One day, far in the oblivion of these selfsame years, they
chanced to be flying past the mouth of the Bann, on the north coast
of Erin: and Aed gave a cry of joy, and bade Fionula and his brothers
look inland, for there, coming out of the south-west, was a stately
cavalcade, the horsemen mounted on white steeds, beautifully
apparelled, and with weapons gleaming in the sun.
How joyous it was to see their own kind again! All gave a cry of
rapture, their hearts aching the while that they could not set foot
upon the land, as that was forbidden to them, though they might
adventure to the shore.
Long and earnestly Fionula looked, but she could not tell who
the strangers were.
“Keen are your eyes, Aed,” she said; “can you discern who the
men of yonder cavalcade are?”
“I know them not as men: but it seems to me that they are a
troop of our own Dedannan folk, or perchance they may be of the
Milesians.”
But while they were still wondering and discussing, the
cavalcade drew nearer, and the men of it saw the four swans, and,
recognising them as the children of Lir, made signs to Fionula and
her brothers to alight on the shore.
With joy the Dedannans, for so they were, hailed the poor
exiles, for whom indeed they had long been seeking along the north
coasts of Erin. As for the children of Lir they could scarce speak, so
great was their happiness to hear their dear familiar speech once
more and to see the faces of their own people.
Again and again they were embraced by the two chiefs of the
Fairy Host, as the Dedannan warriors were called—Aed the keen-
witted, and Fergus the chess-player, the two sons of Bove Derg, king
of the Tuatha-De-Danann.
With joy the children of Lir learned that their father was still
alive, and was even then celebrating at his house at Shee Finnaha,
along with Bove Derg and the chiefs of the Dedannans, the Feast of
Age. As for Aed and Fergus and all their following, they wept when
they heard the tale of the misery of these lost years, when Fionula
and Aed and Fiachra and Conn were the sport of the winds.
While eagerly and lovingly they were conversing, none noticed
that the sun was sinking upon the low wavering line of the ultimate
wave. But when at last Fionula saw this, she uttered a sad cry of
warning to her brothers, and all four rose on their white wings and
made ready to fly back to the bleak and desolate sea of Moyle. And
sad, sadder than ever, was the heart of Fionula, for she knew that
they could not be there till nightfall, and that the penalty of this
would be that they should not again see the face of their kind, either
on the shores of Erin or Alba, until the end of the three hundred
years on the wastes of the Moyle.
As they circled in the air, she sang this song, the last of the
swan-songs heard of any of the Dedannans who were in that
company:
Happy our father Lir afar,
With mead, and songs of love and war:
The salt brine, and the white foam,
With these his children have their home.
In the sweet days of long ago
Soft-clad we wandered to and fro:
But now cold winds of dawn and night
Pierce deep our feathers thin and light.
The hazel mead in cups of gold
We feasted from in days of old:
The sea-weed now our food, our wine
The salt, keen, bitter, barren brine.
On soft warm couches once we pressed
While harpers lulled us to our rest:
Our beds are now where the sea raves,
Our lullaby the clash of waves.
Alas! the fair sweet days are gone
When love was ours from dawn to dawn:
Our sole companion now is pain,
Through frost and snow, through storm and rain.
Beneath my wings my brothers lie
When fierce the ice-winds hurtle by:
On either side and ’neath my breast
Lir’s sons have known no other rest.
Ah, kisses we shall no more know,
Ah, love so dear exchanged for woe,
All that is sweet for us is o’er,
Homeless for aye from shore to shore.

A great lamentation went up from the cavalcade of the Fairy


Host when Fionula ended this song, and she and her brothers flew
swiftly northward athwart the waves, red and wild because of the
stormy setting of the sun.
Sad was the tale the Dedannans had to relate when they
returned to Shee Finnaha.
Nevertheless, Bove Derg, the aged king, and white-haired Lir
himself, took comfort in this, that Fionula and her brothers were still
alive. Moreover, they knew that in the end the spell of Aeifa would
be broken and that the exiles would be freed from their sufferings.
But often, often, they thought with tears, as the slow revolving
seasons lapsed one into the other, of the children of Lir upon the
desolate far seas of the Moyle.
* * * * *
Here Eilidh’s voice lapsed into silence. Then, looking no longer at
Peterkin, but staring into the red heart of the peats, she sang a
Gaelic song, called the Sorrow of the Grey Hairs of Lir.
Peterkin never loved Eilidh so well as when she sang; but he was
sorrowful to-night when he saw that the song brought tears into her
eyes.
“Eilidh,” he whispered.
“Yes, Peterkin, dear.”
“Wouldn’t you be liking to kiss Ian?”
Eilidh laughed low, a faint flush coming and going upon her face.
“For why, boykin?”
“Oh, I know that whenever you have tears in your eyes Ian can
chase them away. I have seen him kiss you when you are tired.”
At this Ian Mor rose and lifted Peterkin in his arms.
“Eilidh is thinking of something sad, Peterkin; that is all. See, she
is smiling now, and laughing too by the same token.” The boy tossed
his curls, and with a roguish smile added:
“Ah, that is just because I said she wanted to kiss you.”
“You’re much too wise, Peterkin. But there, down with you! Now
run to the door, and tell me if it is still raining.”
Peterkin never could go straight anywhere, for his progress was
ever like that of a kid or lambkin, a series of jumps and little sudden
runs. No sooner was he gone, than Ian turned to Eilidh, and took
her in his arms.
“Sweetheart,” he whispered, “that little burst o’ sunshine is right.
A kiss from your lips is the best thing to chase away the tears. But
why are you sad, mochree?”
“I was thinking of the sorrow of old Lir; and how little it matters
whether one live fifty years or five hundred, as these old Dedannans
did. Then suddenly the thought flashed across me that some day
soon we should lose Peterkin: he too will become a wild swan, and it
will be we who shall hear the far-off singing of his laughing
childhood.”
“Perhaps he will take his childhood with him into manhood, dear.
Let him look often into your beautiful eyes, Eilidh, and the little one
will learn much without knowing that he is learning. And then, too,
to be near you: why, that is to be a child always deep down, and to
have sunshine in the heart and mind—for have you forgotten your
name, ‘Sunshine’?”
As he spoke, Ian Mor leaned and kissed her. Puzzled at the
sudden radiant smile on her face, he looked round. There was
Peterkin, sitting squatted on the hearth, with an impish smile in his
blue eyes. He had crawled behind the hanging curtain at the door,
and unseen and unheard gained the fireside.
With a joyous laugh he sprang to his feet.
“Ah, Ian, you and your rain! Is it not hearing you are? It’s on the
window as if the brownies were throwing little wee stones. It was
not the rain you were wanting, but only a kiss from Eilidh! Now,
Eilidh, tell me true?”
“Tell you true, Blumpits. Why——”
But here Peterkin, overcome by some sudden memory
suggested by the pet name which Eilidh sometimes gave him, went
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like