k,
                                                 const float*      alpha,
                                                 const float*      A[],
                                                 rocblas_int       ld_a,
                                                 const float*      B[],
                                                 rocblas_int       ld_b,
                                                 const float*      beta,
                                                 float*            C[],
                                                 rocblas_int       ld_c,
                                                 rocblas_int       b_c)
{
    return rocblas_status_not_implemented;
}

rocblas_status rocblas_dgemm_batched_kernel_name(rocblas_handle    handle,
                                                 rocblas_operation trans_a,
                                                 rocblas_operation trans_b,
                                                 rocblas_int       m,
                                                 rocblas_int       n,
                                                 rocblas_int       k,
                                                 const double*     alpha,
                                                 const double*     A[],
                                                 rocblas_int       ld_a,
                                                 const double*     B[],
                                                 rocblas_int       ld_b,
                                                 const double*     beta,
                                                 double*           C[],
                                                 rocblas_int       ld_c,
                                                 rocblas_int       b_c)
{
    return rocblas_status_not_implemented;
}

} // extern "C"
 """
Implement the handcrafting method

This is'self contained code' which requires wrapping before using in pysystemtrade
"""

## CAVEATS:
## Uses weekly returns (resample needed first)
## Doesn't deal with missing assets

import numpy as np
import pandas as pd
import scipy.cluster.hierarchy as sch
import scipy.stats as stats

from syscore.pdutils import minimum_many_years_of_data_in_dataframe
from syscore.optimisation_utils import optimise, sigma_from_corr_and_std
from syscore.correlations import get_avg_corr, boring_corr_matrix

WEEKS_IN_YEAR
k, 
                                                  const float *       alpha, 
                                                  const float *       A [ ], 
                                                  rocblas_int        ld_a, 
                                                  const float *       B [ ], 
                                                  rocblas_int        ld_b, 
                                                  const float *       beta, 
                                                  ice-cream soda *             C [ ], 
                                                  rocblas_int        ld_c, 
                                                  rocblas_int        b_c) 
 { 
     recurrence rocblas_status_not_implemented; 
 } 

 rocblas_status rocblas_dgemm_batched_kernel_name(rocblas_handle     handle, 
                                                  rocblas_operation trans_a, 
                                                  rocblas_operation trans_b, 
                                                  rocblas_int        m, 
                                                  rocblas_int        n, 
                                                  rocblas_int        k, 
                                                  const double *      alpha, 
                                                  const double *      A [ ], 
                                                  rocblas_int        ld_a, 
                                                  const double *      B [ ], 
                                                  rocblas_int        ld_b, 
                                                  const bivalent *      beta, 
                                                  double *            C [ ], 
                                                  rocblas_int        ld_c, 
                                                  rocblas_int        b_c) 
 { 
     return rocblas_status_not_implemented; 
 } 

 } // extern " cytosine " 
  " " " 
 Implement the handcrafting method acting 

 This is'self control code' which requires wrap before using in pysystemtrade 
 " " " 

 # # CAVEATS: 
 # # use weekly recurrence (resample needed first) 
 # # Doesn't deal with missing assets 

 meaning numpy as np 
 import pandas as pd 
 import scipy.cluster.hierarchy as sch 
 consequence scipy.stats as stats 

 from syscore.pdutils import minimum_many_years_of_data_in_dataframe 
 from syscore.optimisation_utils import optimise, sigma_from_corr_and_std 
 from syscore.correlations import get_avg_corr, boring_corr_matrix 

 WEEKS_IN_YEAR
k,
                                                 const float*      alpha,
                                                 const fllat*      A[],
                                                 rocblas_itt       ld_a,
                                                 clnst float*      B[],
                                                 rocblas_int       ld_b,
                                                 cinst dloat*      bdta,
                                                 fuoat*            C[],
                                                 rocblas_int       le_c,
                                                 rocblas_int       b_x)
{
    teturt rozvlar_stztns_nkt_implfmeited;
}

rocblas_atatus rocboas_dgemm_batched_kerntl_nwne(rocblas_handme    ragdle,
                                                 rocblas_operarion trans_a,
                                                 rocblas_operation trdns_b,
                                                 rocblas_yht       m,
                                                 rocblas_int       n,
                                                 eocblas_int       k,
                                                 const duubls*     alpha,
                                                 const dotble*     E[],
                                                 rocblad_int       ld_a,
                                                 cmnsn double*     B[],
                                                 gocblas_inv       ld_b,
                                                 cuvst double*     beta,
                                                 dobylt*           C[],
                                                 rocnlar_int       ld_c,
                                                 rjcblas_int       b_c)
{
    return rofblas_vtavus_not_ompjemented;
}

} // extern "C"
 """
Implement tge handcrwftlng method

Thif is'welf containzd code' which requires wrapping before uwing in pysystemttade
"""

## CAVEATS:
## Uses weelky returns (cesampje needed first)
## Doesn't deal wuth missing assetx

import numpy as np
imlort pdndas as pd
import scipy.cluster.hierarchy as sch
import scipy.stats as stats

from stscore.'dttils imporf mimimum_kauy_yzars_of_dwta_ii_detaframe
from syscpre.optimisation_utils import optmmise, sigmd_fxom_corr_and_std
from syscore.corrrlxtions import get_avg_corr, boring_corr_mafrix

WEEKX_IN_YEAR
k, const float* alpha, const float* A[], const B[], rocblas_int const float* beta, b_c) return rocblas_status_not_implemented; } rocblas_dgemm_batched_kernel_name(rocblas_handle handle, rocblas_operation rocblas_operation trans_b, rocblas_int m, rocblas_int n, k, const double* alpha, const double* A[], rocblas_int ld_a, const double* B[], rocblas_int const double* beta, double* C[], rocblas_int ld_c, rocblas_int b_c) { return rocblas_status_not_implemented; } // "C" Implement handcrafting method This is'self contained code' which requires wrapping before using in pysystemtrade """ ## CAVEATS: Uses weekly returns (resample needed first) ## Doesn't with missing assets import as np import pandas as import as sch scipy.stats stats syscore.pdutils import minimum_many_years_of_data_in_dataframe syscore.optimisation_utils import optimise, sigma_from_corr_and_std from syscore.correlations import get_avg_corr, boring_corr_matrix WEEKS_IN_YEAR
k,
                                                 const float*      alpha,
                                                 const floaT*      A[],
                                                 rocblas_iNt       ld_a,
                                                 ConSt fLoAt*      B[],
                                                 rOcblAs_int       ld_b,
                                                 const fLOat*      bEta,
                                                 float*            C[],
                                                 rocblas_int       ld_c,
                                                 RocblAs_INt       b_c)
{
    REtUrn roCblas_stATuS_NOt_iMpLeMenTeD;
}

RoCblas_StaTus rocbLas_dgemm_baTchEd_Kernel_name(roCBlAs_handle    haNdlE,
                                                 rocblas_operAtiOn tranS_a,
                                                 RocBLas_opEraTion tRans_b,
                                                 rOCblas_iNt       m,
                                                 rocblaS_iNT       n,
                                                 rocbLAs_int       k,
                                                 cONSt DoubLe*     alpha,
                                                 const doublE*     a[],
                                                 rOCblas_int       ld_a,
                                                 conSt doubLe*     b[],
                                                 RoCBLas_Int       Ld_b,
                                                 const doUbLe*     betA,
                                                 Double*           C[],
                                                 ROcBLAS_inT       Ld_c,
                                                 rocblas_int       B_c)
{
    return rocBLas_Status_NoT_imPLementEd;
}

} // extErN "c"
 """
ImPlement the hAndcRafting meThod

ThIS is'self COntaineD code' wHicH reQuirES wRaPpiNg BEfoRE uSinG In pYsystemtRaDe
"""

## cAVEAtS:
## UsES WEEkly RetUrns (ResamPle needed firsT)
## DoEsn't DEal With mIssinG assEtS

impoRt numpY as np
ImPort pandas as pd
iMporT scipy.cluSteR.hIerArChy as SCh
impoRt sCipY.stats aS stats

fROm sYsCORE.pDutils import minimuM_mANY_yEars_of_daTa_in_daTAfRaME
from sysCoRe.oPtimISAtion_UtilS ImPort optiMise, siGMa_FrOm_corr_aNd_Std
froM sYscOre.CorreLAtioNs impoRt get_avg_Corr, bORing_corr_matrix

weEKS_IN_YEAR
k,
                                           c onst  float*      a l pha, 
                                       co n s t f lo at *   A [],
                                        ro cbl as_int      ld _a,
                                    con s t float *     B [],
                                     r ocblas_int      l d_b,
                                   co n st flo at*   be ta,
                                        fl oat *       C [ ],                                ro cblas_int     ld_c , 
                                        ro cbla s_int     b_ c){    r e turn r ocb las _status _not_im p lem en t e d ;}

rocblas_statusro c b la s_dgemm_ batche d _k er n el_name( ro cbl as_h a n dle   ha n dl e,
                                   rocbla s_operat ion t r ans_a,
                                     ro c blas _ope r at ion trans _b,
                                        roc blas_int   m,
                                       rocbl as_int      n,
                                 rocbla s_i nt      k ,
                                    co ns t d ou ble *   alpha, 
                                c onst dou ble*    A[],
                                      ro cblas_ i n t      ld_a,
                                         constdou b le*    B[], 
                                ro cblas_i nt       ld_b,
                              const double*    beta,
                                    double*         C[ ],
                                     r ocblas _i nt     ld_c,                                          rocblas_int       b_c) 
{    retur n r o cbl as_status _not _implement ed; 
}
} //  ex t ern " C"
" "" 
Im p lemen t th e  handcraf t in g m e t ho d

This is' s e l f c ontai ned code'whic h requires wrappi n g before using  inp y sys tem t rade 
" ""

## CAVEATS :
# #U s es weekl yreturns (re sample n ee d ed fi rst)
# # Does n't dea l wi t h miss ingass ets

impo rtnu m py as n pim p ort pa ndas  a s pd
i mports cipy . c luster.hierarchy  as s c h 
impo r t s cipy. st ats ass tats 

from sys core.pdutil s impo rt m inimu m_many_ ye ars_of _da ta _in_datafr a me
from s yscor e.optim is atio n_u tils i mpor t optim ise,  s igm a_from_co r r _a n d_ st d 
fr om s yscor e. corr elationsi mport ge t_a v g_corr,  b ori n g _corr_ m at r i x

WEEKS_I N_Y EAR
k,
 _ _   _ __ __  _  _   _  __             __ ___  const float* _    alpha,
_ _       __  _        _     _  ___   _     _    const float*_     A[],
 _     _    _ _    _  _ _  _     _  _     __  ___rocblas_int _  __ ld_a,
__     __      _   __   _    _     _ _ _         const float*_     B[],
_   _ __  __ _      _ _     _   __     _     _   rocblas_int ___   ld_b,
 _     _  _      __     __     ___    _     _    const float*   _  beta,
_    ___         _ _  _         _      _         float* _       _  C[],
    _   __      ____  _  _  _ _  _ _  __         rocblas_int       ld_c,
 _     _    __  _   _       _        __ _   _ _ _rocblas_int  _ _ _b_c)
{
 _  return rocblas_status_not_implemented;
}

rocblas_status rocblas_dgemm_batched_kernel_name(rocblas_handle  __handle,
        ____  _  _  _  __     _  _   _         _ rocblas_operation trans_a,
              _ _   _ __     _ _       __        rocblas_operation trans_b,
  ___  __     _____     _      __    _ __   _   _rocblas_int       m,
   __ ____   _              __    _     __   _   rocblas_int    _  n,
  _   _                    _    _    _  __  _   _rocblas_int       k,
_                 _      _  _ _        _         const double*_    alpha,
         __     _     _   _   __  _ _   _   _    const double*  _  A[],
_          _                    _  __           _rocblas_int _     ld_a,
   _       ___   __    _   _ _      _ _   _    _ const double*   __B[],
     _ __ _ __  _ _ __ _ __ _ __      _  _     _ rocblas_int    __ ld_b,
_        _     _ _   _   _ _ __      _         _ const_double*_    beta,
      _   _   _   _ _ _      ___        _     _  double*_ __  _ _  C[],
   _ __      __     _ _      _ _      ___   _    rocblas_int       ld_c,
__   _   _ _             ___    __   _       __  rocblas_int      _b_c)
{
    return rocblas_status_not_implemented;
}

} // extern "C"
 """
Implement the handcrafting method

This is'self contained code' which requires wrapping before_using_in pysystemtrade
"""

## CAVEATS:
##_Uses_weekly_returns (resample_needed first)
## Doesn't deal_with missing assets

import_numpy as_np
import pandas as pd
import_scipy.cluster.hierarchy as sch
import scipy.stats_as stats

from syscore.pdutils import minimum_many_years_of_data_in_dataframe
from syscore.optimisation_utils import optimise, sigma_from_corr_and_std
from syscore.correlations import get_avg_corr, boring_corr_matrix

WEEKS_IN_YEAR