<s> '''<STR_LIT>''' <EOL> import datetime as dt <EOL> import unittest <EOL> import pandas as pand <EOL> import numpy as np <EOL> import qstksim <EOL> import qstkutil . DataAccess as da <EOL> import qstkutil . qsdateutil as du <EOL> class Test ( unittest . TestCase ) : <EOL> df_close = None <EOL> df_alloc = None <EOL> i_open_result = None <EOL> def _generate_data ( self ) : <EOL> year = <NUM_LIT> <EOL> startday = dt . datetime ( year - <NUM_LIT:1> , <NUM_LIT:12> , <NUM_LIT:1> ) <EOL> endday = dt . datetime ( year + <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT> ) <EOL> l_symbols = [ '<STR_LIT>' ] <EOL> timeofday = dt . timedelta ( hours = <NUM_LIT:16> ) <EOL> ldt_timestamps = du . getNYSEdays ( startday , endday , timeofday ) <EOL> dataobj = da . DataAccess ( '<STR_LIT>' ) <EOL> self . df_close = dataobj . get_data ( ldt_timestamps , l_symbols , "<STR_LIT>" , verbose = True ) <EOL> self . df_alloc = pand . DataFrame ( index = [ dt . datetime ( year , <NUM_LIT:1> , <NUM_LIT:1> ) ] , data = [ <NUM_LIT:1> ] , columns = l_symbols ) <EOL> for i in range ( <NUM_LIT:11> ) : <EOL> self . df_alloc = self . df_alloc . append ( pand . DataFrame ( index = [ dt . datetime ( year , i + <NUM_LIT:2> , <NUM_LIT:1> ) ] , data = [ <NUM_LIT:1> ] , columns = l_symbols ) ) <EOL> self . df_alloc [ '<STR_LIT>' ] = <NUM_LIT:0.0> <EOL> self . i_open_result = <NUM_LIT> <EOL> def setUp ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . _generate_data ( ) <EOL> def test_buy_close ( self ) : <EOL> '''<STR_LIT>''' <EOL> ( df_funds , ts_leverage , f_commision , f_slippage , f_borrow ) = qstksim . tradesim ( self . df_alloc , self . df_close , <NUM_LIT> , <NUM_LIT:1> , True , <NUM_LIT> , <EOL> <NUM_LIT:5> , <NUM_LIT> ) <EOL> print '<STR_LIT>' + str ( f_commision ) <EOL> print '<STR_LIT>' + str ( f_slippage ) <EOL> print '<STR_LIT>' + str ( f_borrow ) <EOL> print '<STR_LIT>' <EOL> print ts_leverage <EOL> np . testing . assert_approx_equal ( df_funds [ - <NUM_LIT:1> ] , <NUM_LIT> * self . i_open_result , significant = <NUM_LIT:3> ) <EOL> self . assertTrue ( True ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
