<s> '''<STR_LIT>''' <EOL> from nose . tools import eq_ , raises , ok_ <EOL> import insights . managers . gmv as gmv <EOL> from insights . test_framework import ( <EOL> FactoryManagerTestCase , generate_fake_returns <EOL> ) <EOL> class ComputeWeighsTestCase ( FactoryManagerTestCase ) : <EOL> pass <EOL> class GmvManagerTestCase ( FactoryManagerTestCase ) : <EOL> def test_initialize ( self ) : <EOL> manager = gmv . GlobalMinimumVariance ( ) <EOL> self . _check_initialization ( manager ) <EOL> eq_ ( manager . partial_sell , <NUM_LIT:1.0> ) <EOL> def test_optimize_empty_signals ( self ) : <EOL> manager = gmv . GlobalMinimumVariance ( ) <EOL> alloc , e_ret , e_risk = manager . optimize ( { } , { } ) <EOL> self . _check_optimize_return ( alloc , e_ret , e_risk ) <EOL> eq_ ( alloc , { } ) <EOL> eq_ ( e_ret , <NUM_LIT:0> ) <EOL> eq_ ( e_risk , <NUM_LIT:1> ) <EOL> @ raises ( NotImplementedError ) <EOL> def test_buy_signals_without_returns ( self ) : <EOL> manager = gmv . GlobalMinimumVariance ( ) <EOL> alloc , e_ret , e_risk = manager . optimize ( { '<STR_LIT>' : <NUM_LIT> } , { } ) <EOL> self . _check_optimize_return ( alloc , e_ret , e_risk ) <EOL> def test_buy_signals ( self ) : <EOL> manager = gmv . GlobalMinimumVariance ( ) <EOL> manager . advise ( historical_prices = generate_fake_returns ( self . test_sids ) ) <EOL> alloc , _ , _ = manager . optimize ( { '<STR_LIT>' : <NUM_LIT> } , { } ) <EOL> ok_ ( alloc ) <EOL> for sid , weigh in alloc . iteritems ( ) : <EOL> self . assertIsInstance ( alloc [ sid ] , float ) <EOL> self . assertGreaterEqual ( weigh , <NUM_LIT:0> ) <EOL> self . assertLessEqual ( weigh , <NUM_LIT:1> ) <EOL> self . assertIn ( sid , self . test_sids ) <EOL> def test_default_sell_signals ( self ) : <EOL> to_sell = self . test_sids [ <NUM_LIT:0> ] <EOL> manager = gmv . GlobalMinimumVariance ( ) <EOL> manager . update ( self . test_pf , None , None ) <EOL> eq_ ( manager . portfolio , self . test_pf ) <EOL> alloc , _ , _ = manager . optimize ( { } , [ to_sell ] ) <EOL> eq_ ( alloc [ to_sell ] , - self . test_pf . positions [ to_sell ] . amount ) </s>
