<s> '''<STR_LIT>''' <EOL> from nose . tools import ok_ , eq_ <EOL> from insights . test_framework import FactoryAlgorithmTestCase <EOL> import insights . algorithms . dummy as dummy <EOL> class RandomAlgoTestCase ( FactoryAlgorithmTestCase ) : <EOL> def test_doc ( self ) : <EOL> self . _check_yaml_doc ( dummy . Random ) <EOL> def test_initialize_default ( self ) : <EOL> algo = dummy . Random ( ) <EOL> eq_ ( algo . identity , self . default_identity ) <EOL> eq_ ( algo . middlewares , [ ] ) <EOL> ok_ ( algo . buy_trigger > <NUM_LIT:0.5> and algo . buy_trigger < <NUM_LIT:1> ) <EOL> ok_ ( algo . sell_trigger > <NUM_LIT:0> and algo . sell_trigger < <NUM_LIT:0.5> ) <EOL> def test_initialize_custom_signal_triggers ( self ) : <EOL> algo = dummy . Random ( properties = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } ) <EOL> eq_ ( algo . buy_trigger , <NUM_LIT> ) <EOL> eq_ ( algo . sell_trigger , <NUM_LIT> ) <EOL> def test_initialize_custom_middlewares ( self ) : <EOL> algo = dummy . Random ( properties = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True <EOL> } ) <EOL> eq_ ( len ( algo . middlewares ) , <NUM_LIT:2> ) <EOL> def test_event_output ( self ) : <EOL> algo = dummy . Random ( ) <EOL> self . _check_event_output ( algo . event ( self . event_data ) ) <EOL> def test_deactivate_buy_and_sell ( self ) : <EOL> algo = dummy . Random ( properties = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : - <NUM_LIT> <EOL> } ) <EOL> signals = algo . event ( self . event_data ) <EOL> eq_ ( signals [ '<STR_LIT>' ] , { } ) <EOL> eq_ ( signals [ '<STR_LIT>' ] , { } ) <EOL> def test_always_buy_and_cannot_sell ( self ) : <EOL> algo = dummy . Random ( properties = { <EOL> '<STR_LIT>' : - <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> <EOL> } ) <EOL> signals = algo . event ( self . event_data ) <EOL> ok_ ( signals [ '<STR_LIT>' ] ) <EOL> eq_ ( signals [ '<STR_LIT>' ] , { } ) <EOL> def test_always_sell_and_cannot_buy ( self ) : <EOL> algo = dummy . Random ( properties = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> <EOL> } ) <EOL> signals = algo . event ( self . event_data ) <EOL> ok_ ( signals [ '<STR_LIT>' ] ) <EOL> eq_ ( signals [ '<STR_LIT>' ] , { } ) </s>
