Skip to Content
Learn Algorithmic Trading
book

Learn Algorithmic Trading

by Sebastien Donadio, Sourav Ghosh
November 2019
Beginner content levelBeginner
394 pages
10h 31m
English
Packt Publishing
Content preview from Learn Algorithmic Trading

Implementation of the relative strength indicator

Now, let's implement and plot a relative strength indicator on our dataset:

import statistics as statstime_period = 20 # look back period to compute gains & lossesgain_history = [] # history of gains over look back period (0 if no gain, magnitude of gain if gain)loss_history = [] # history of losses over look back period (0 if no loss, magnitude of loss if loss)avg_gain_values = [] # track avg gains for visualization purposesavg_loss_values = [] # track avg losses for visualization purposesrsi_values = [] # track computed RSI valueslast_price = 0 # current_price - last_price > 0 => gain. current_price - last_price < 0 => loss.for close_price in close: if last_price == 0: last_price = close_price ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

High-Frequency Trading: A Practical Guide to Algorithmic Strategies and Trading Systems

High-Frequency Trading: A Practical Guide to Algorithmic Strategies and Trading Systems

Irene Aldridge
Developing High-Frequency Trading Systems

Developing High-Frequency Trading Systems

Sebastien Donadio, Sourav Ghosh, Romain Rossier

Publisher Resources

ISBN: 9781789348347Supplemental Content