def compute_sector_exposures(positions, sectors, sector_dict=SECTORS):
sector_ids = sector_dict.keys()<EOL>long_exposures = []<EOL>short_exposures = []<EOL>gross_exposures = []<EOL>net_exposures = []<EOL>positions_wo_cash = positions.drop('<STR_LIT>', axis='<STR_LIT>')<EOL>long_exposure = positions_wo_cash[positions_wo_cash > <NUM_LIT:0>].sum(axis='<STR_LIT>')<EOL>short_exposure = positions_wo_cash[positions_wo_cash < <NUM_LIT:0>].abs().sum(axis='<STR_LIT>')<EOL>gross_exposure = positions_wo_cash.abs().sum(axis='<STR_LIT>')<EOL>for sector_id in sector_ids:<EOL><INDENT>in_sector = positions_wo_cash[sectors == sector_id]<EOL>long_sector = in_sector[in_sector > <NUM_LIT:0>].sum(axis='<STR_LIT>').divide(long_exposure)<EOL>short_sector = in_sector[in_sector < <NUM_LIT:0>].sum(axis='<STR_LIT>').divide(short_exposure)<EOL>gross_sector = in_sector.abs().sum(axis='<STR_LIT>').divide(gross_exposure)<EOL>net_sector = long_sector.subtract(short_sector)<EOL>long_exposures.append(long_sector)<EOL>short_exposures.append(short_sector)<EOL>gross_exposures.append(gross_sector)<EOL>net_exposures.append(net_sector)<EOL><DEDENT>return long_exposures, short_exposures, gross_exposures, net_exposures<EOL>
Returns arrays of long, short and gross sector exposures of an algorithm's
positions

Parameters
----------
positions : pd.DataFrame
    Daily equity positions of algorithm, in dollars.
    - See full explanation in compute_style_factor_exposures.

sectors : pd.DataFrame
    Daily Morningstar sector code per asset
    - See full explanation in create_risk_tear_sheet

sector_dict : dict or OrderedDict
    Dictionary of all sectors
    - Keys are sector codes (e.g. ints or strings) and values are sector
      names (which must be strings)
    - Defaults to Morningstar sectors