Commit 9bb86b11 authored by Dr.李's avatar Dr.李

fixed bug

parent 552b014c
......@@ -12,12 +12,30 @@ from alphamind.execution.naiveexecutor import NaiveExecutor
class TestNaiveExecutor(unittest.TestCase):
@staticmethod
def test_naive_executor():
def test_naive_executor(self):
target_pos = pd.DataFrame({'code': [1, 2, 3],
'weight': [0.2, 0.3, 0.5],
'industry': ['a', 'b', 'c']})
# 1st round
executor = NaiveExecutor()
turn_over, executed_pos = executor.execute(target_pos)
self.assertAlmostEqual(turn_over, 1.0)
# 2nd round
target_pos = pd.DataFrame({'code': [1, 2, 4],
'weight': [0.3, 0.2, 0.5],
'industry': ['a', 'b', 'd']})
turn_over, executed_pos = executor.execute(target_pos)
self.assertAlmostEqual(turn_over, 1.2)
# 3rd round
target_pos = pd.DataFrame({'code': [1, 3, 4],
'weight': [0.3, 0.2, 0.5],
'industry': ['a', 'c', 'd']})
turn_over, executed_pos = executor.execute(target_pos)
if __name__ == '__main__':
unittest.main()
\ No newline at end of file
......@@ -12,7 +12,6 @@ from alphamind.execution.thresholdexecutor import ThresholdExecutor
class TestThresholdExecutor(unittest.TestCase):
@staticmethod
def test_threshold_executor(self):
target_pos = pd.DataFrame({'code': [1, 2, 3],
'weight': [0.2, 0.3, 0.5],
......@@ -35,7 +34,7 @@ class TestThresholdExecutor(unittest.TestCase):
self.assertTrue(executed_pos.equals(executor.current_pos))
self.assertAlmostEqual(turn_over, 1.2)
# 3nd round
# 3rd round
target_pos = pd.DataFrame({'code': [1, 3, 4],
'weight': [0.3, 0.2, 0.5],
'industry': ['a', 'c', 'd']})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment