radium.pair package¶
Submodules¶
radium.pair.cadf_test module¶
-
radium.pair.cadf_test.cadf_test(pair)¶ Conducts a Cointegrated Augmented Dickey Fuller Test on a pair of equities.
Prints t-statistic, p-value and critical values
- Parameters
pair (radium.Pair) –
- Raises
TypeError – If pair is not of type radium.Pair.
radium.pair.johansen_test module¶
-
radium.pair.johansen_test.johansen_test(pair)¶ Conducts a Johansen Test on a pair of equities.
Print trace/eigenvalue statistics and critical values.
- Parameters
pair (radium.Pair) –
- Raises
TypeError – If pair is not of type radium.Pair.
radium.pair.pair module¶
-
class
radium.pair.pair.Pair(equity1, equity2)¶ Bases:
objectClass for a pair of equities.
-
price_spread¶ Price spread of equities for self.hedge_ratios
- Type
float np.ndarray[]
-
equity1¶ - Type
-
equity2¶ - Type
-
start_date¶ - Type
datetime.date
-
end_date¶ - Type
datetime.date
-
hedge_ratios¶ Day-wise pairs of hedge ratios
- Type
float np.ndarray[][2]
Initialise Pair class
- Parameters
equity1 (radium.Equity) –
equity2 (radium.Equity) –
- Raises
TypeError – If equity1 or equity2 is not of type radium.Equity.
ValueError – If equity1 and equity2 do not share any date ranges
-
budget(hedge_ratio, dec)¶ Calculates budget needed to buy integer number of equities.
- Parameters
hedge_ratio (int np.ndarray[2]) – Hedge ratios of pair
dec (int) – Number of decimals to truncate to
- Returns
budget – Budget needed rounded to 2 d.p.
- Return type
float
- Raises
TypeError – If hedge_ratio isnt a list of floats, or dec isnt an integer.
ValueError – If hedge_ratio isn’t length 2 or dec < 0.
-
hedge(method, lookback)¶ Calculates the hedge_ratios given a method and lookback and stores it in self.hedge_ratios
- Parameters
method (str) – Method for calculating hedge ratios (‘ols’)
lookback (int) – Number of signals to lookback on when calculating hedge ratios
- Raises
TypeError – If method isn’t a string. If lookback isn’t an integer.
ValueError – If lookback <= 0. If method isn’t available.
Notes
Available methods: ‘OLS’
-
plot_closed(start_date=None, end_date=None)¶ Plots closed prices of both equities between two dates as a line graph
- Parameters
start_date ((optional) str or datetime or datetime.date) – First date to plot in YYYY-MM-DD form, defaults to equity start date
end_date ((optional) str of datetime or datetime.date) – Last date to plot in YYYY-MM-DD form, defaults to equity end date
- Raises
ValueError – End date is same as or before start date
-
plot_price_spread()¶ Plots price spread of the pair given hedge_ratios
- Raises
Exception – If self.hedge_ratios is not defined.
-
property
price_spread¶ Price spread of equities for self.hedge_ratios
- Raises
TypeError – If self.hedge_ratios isn’t defined.
Notes
Spread calculated using y = h1*y1 + h2*y2.
- Type
float np.ndarray[]
-