Notebook Instructions
You can run the notebook document sequentially (one cell at a time) by pressing shift + enter. While a cell is running, a [*] will display on the left. When it has been run, a number will display indicating the order in which it was run in the notebook [8].
Enter edit mode by pressing Enter or using the mouse to click on a cell's editor area. Edit mode is indicated by a green cell border and a prompt showing in the editor area.
This course is based on specific versions of python packages. You can find the details of the same in this manual. The manual also explains how to use these codes in other versions of python packages.
Hurst exponent strategy
In this notebook, we will create a strategy using the Hurst exponent and the RSI. The strategy works as follows:
Fetch the minute data for Ethereum/USDT from a csv file
Convert the unix epoch time to normal datetime format and set it as index
Compute the hurst value for the entire price series
Compute the rolling hurst values for with a lookback period of 240 minutes
Compute the signals to indicate the persistent nature of the market
Calculate the RSI values
Calcualte the market returns
Calcualte the strategy returns
Compute the cumulative strategy return and plot it
Compute the slippage
Calculate the net profit after slippage
Import data and libraries
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-3-53613acd3550> in <module>()
3 import pandas as pd
4 #import talib as ta
----> 5 from hurst import compute_Hc
ModuleNotFoundError: No module named 'hurst'
Collecting hurst
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fa1cb878a50>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/hurst/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fa1cb878c10>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/hurst/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fa1cb878050>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/hurst/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fa1cb878610>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/hurst/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fa1cb878590>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/hurst/
Could not find a version that satisfies the requirement hurst (from versions: )
No matching distribution found for hurst
Convert the unix time stamp to datetime
Compute the hurst value for the data
Compute the rolling hurst values
We are using the past 4 hour data to calculate the hurst exponent.
Generate the persitence signals
Compute the RSI
Compute the market return
Compute the strategy returns
We use RSI here to gauge the overbought/oversold condition of the market.
We buy when
RSI is more than 75 and Persistence signal is 1
RSI is less than 25 and Persistence signal is -1
We sell when
RSI is more than 75 and Persistence signal is -1
RSI is less than 25 and Persistence signal is 1