# Johansen cointegration Test for spread generation

I'm using the python statsmodels version of the johansen cointegration test and I'm looking for some advice on how best to generate the spread used within a pairs trading algorithm.

For example I've got the following output from the Johansen test of 2 stocks:

--------------------------------------------------
--> Trace Statistics
variable statistic Crit-90% Crit-95%  Crit-99%
r = 0    13.7837 13.4294 15.4943 19.9349
r = 1    0.6236 2.7055 3.8415 6.6349
--------------------------------------------------
--> Eigen Statistics
variable statistic Crit-90% Crit-95%  Crit-99%
r = 0    13.16 12.2971 14.2639 18.52
r = 1    0.6236 2.7055 3.8415 6.6349
--------------------------------------------------
eigenvectors:
[[ 0.04981179  0.00546497]
[-0.08553954  0.02214011]]
--------------------------------------------------
eigenvalues:
[0.0510797  0.00248153]
--------------------------------------------------


Now I can see that I have some level of cointegration and I understand that the first row of the eigenvectors represents the best estimators for cointegration, but how should I use them in my code. I've previously calculated spread like so (when using beta from an OLS on the two stocks): stock1 - B * stock2

However now I've switched to using the Johansen method I believe I'm presented with two estimators to use for each price series but I'm unsure of how to use them.

I'd be grateful for some advice ?