Errata

Machine Learning and Data Science Blueprints for Finance

Errata for Machine Learning and Data Science Blueprints for Finance

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
ePub Page GitHub repo
n/a

The GitHub repo is a little dated and does not work "out of the box". In particular, the "requirements.txt" cannot be used as is, and many versions of the libraries are now a little old.

It would be great if the authors could redo the library setup as, otherwise, every purchaser of the book has to spend a few hours to get it working. I just did it and it would be infinitely more sensibly if the authors did it: "once, and done".

Great book. Thanks!

EdHayes  Dec 27, 2022 
Printed Page Chapter 9 - Reinforcement Learning/Case Study 1
ReinforcementLearningBasedTradingStrategy.ipynb

The notebook runs and trains the Agent but when the testing data is considered the Agent does not take any buying or selling actions, the profit & loss is zero and the equity curve shows only the price line. I thought the issue was the saving and loading of the compiled trained model but apparently not as I am able to print the parameters of the model loaded from disk. This is an error that is appearing in my platform (Windows 10) as well as in the platform of my students (Mac or Windows). I have not yet looked at the weights. But this is a serious issue.

Rosario Trigo  Jun 15, 2023 
Other Digital Version 43
end

model.fit(data, Y, nb_epoch=10, batch_size=32) => nb_epoch is obsolet
now: model.fit(data, Y, epochs=10, batch_size=32)

Michael Merz  Oct 09, 2022 
Printed Page 99
2.2 Loading the data. (relating to the variable "stk_data")

In Chapter 5, Case study 1, there is a "no data fetched using YahooDailyReader" error when attempting to download the stock price data into variable: stk_dat. Apparently, there have been changes to Pandas DataReader related to Yahoo Finance.

This error occurs on my laptop, on Google Colab, and on mybinder.org/v2/gh/tatsath/fin-ml/master.

Thank you.

Dennis Uyemura  Oct 11, 2021 
Printed Page 99, 100,
99 - last line, 100 - near top of page

Hi Hariom, Sahil & Brad,
Very impressed with ML&DSBFF - enjoying it very much. But I'm having a problem with your coding. The use of the concat method (in Case Study 1) is just drawing NANs from the second dataframe. If you paste your github code into Jupyter from Anaconda, the coding fails at your In[52] with the error "Reindexing only valid with uniquely valued Index objects".

Any help would be very much appreciated.

Terence Athaide  Mar 11, 2022 
PDF Page 99
code after the first paragraph, in section 2.2

stk_data = web.DataReader(stk_tickers, 'yahoo')

this line returns the following error : "string indices must be integers"

this is the solution i found:
stk_data = web.get_data_yahoo(stk_tickers)

similarly the following lines of code have to be changed to work as intended:
ccy_data = web.DataReader(ccy_tickers, 'fred')
idx_data = web.DataReader(idx_tickers, 'fred')

this is the solution i found:
idx_data = web.get_data_fred(idx_tickers)
ccy_data = web.get_data_fred(ccy_tickers)



Silvia Maria Benfenati  Oct 09, 2023 
PDF Page 111
111

Dear Hariom , Sahil and Brad,

I am an Associate Professor at SKEMA Business School, Lille, France, and I will teach a Machine Learning in Finance course in the fall, 2021.
So, this was my wish list:

1 - Simplicity
2 - Data availability. Data science examples without data are useless.
3 - Meaningful applications, not artificial examples
4 - Easy access to code.
5 - I was not looking for a theoretical book, but I also did not want a book that lacked rigour.

Long story, after looking at several books, I was almost giving up when I found Machine Learning
& Data Science Blueprints for Finance. Thanks for writing such an excellent book. Great job!!!

Here is some quick feedback, I will probably be sending more.

Regards,
Bernardo


Page 116 - vloatility
Page 128 -
"We use this data and normalize the risky assets with the price of a stock index (S&P500) in 2007 versus 2009 to get risk tolerance."
I didn't get that. Why is it necessary? How is this a normalization?
Page 143 - Federal public debt, in the comment it says BN, in the github it says MM.
Page 144 - My data set is starting from 2016, and dataset.shape gives me

(243, 15)


Jupyter notebook, case study 4, three small typos:
"
Form the correlation plot, we see that the 1 month and the 30 year yield data points are negatively autocorrelated. The 5 year yield also seems toe be negativly correlated with the changes in foreign goverment purchases. "
- In all examples I got an error when using


kfold = KFold(n_splits=num_folds, random_state=se


My fix was

kfold = KFold(n_splits=num_folds, shuffle=True,random_state=seed)

Bernardo Pagnoncelli  Jul 26, 2021 
PDF Page 182
Case Study 3: Bitcoin Trading Strategy

On "Case Study 3: Bitcoin Trading Strategy" section, you are writing this line :
dataset['signal'] = np.where(dataset['short_mavg'] > dataset['long_mavg'], 1.0, 0.0)

This line of code is very important for this section since it calculates the Y values for the training of the model. But, in my opinion, it does not make any sense since it is using the Close values that are already known (we should use unseen close values for the Y values whereas in your case Y values are calculated with values that are also used by the training dataset...).
What are your objectives here ? For education only ? Because it is useless in real world.
Thank you

Anonymous  Apr 01, 2021 
PDF Page 211,214
def optimizedPorfolio()

[1] pc_w = pcs[i] / sum(pcs[i])
[2] eigen_prtfi = pd.DataFrame(data ={'weights': pc_w.squeeze()*100}, index = stock_tickers)
[3] eigen_prtfi.sort_values(by=['weights'], ascending=False, inplace=True)
[4] eigen_prti_returns = np.dot(X_train_raw.loc[:, eigen_prtfi.index], pc_w)

The author re-arrange the columns of X_train in descending order of weights. However, this change does not match with the order of tickers in `pc_w`. Hence the calculation of `eigen_prti_returns` is not correct.

Indeed, the reallocation of columns is not necessary. [2] and [3] can simply be replaced by:
eigen_prti_returns = np.dot(X_train_raw, pc_w)

The similar problem goes to P.214 the `eigen` used at:
eigen_prti_returns = np.dot(X_test_raw.loc[:, eigen_prtfi.index], eigen)

Please feedback if I am correct or not. Thank you very much.

Anonymous  Nov 10, 2020 
PDF Page 315
output

when I run the DQN model( trading bot), it runs on training but not in testing(profit =0, chart appears without buying or sell)

Amal  May 13, 2021