test_doc
test_MM_FixedCount.cpp
浏览该文件的文档.
1 /*
2  * test_MM_FixedCount.cpp
3  *
4  * Created on: 2013-4-19
5  * Author: fasiondog
6  */
7 
8 #ifdef TEST_ALL_IN_ONE
9  #include <boost/test/unit_test.hpp>
10 #else
11  #define BOOST_TEST_MODULE test_hikyuu_trade_sys_suite
12  #include <boost/test/unit_test.hpp>
13 #endif
14 
15 #include <hikyuu/StockManager.h>
16 #include <hikyuu/trade_manage/crt/crtTM.h>
17 #include <hikyuu/trade_manage/crt/TC_FixedA.h>
18 #include <hikyuu/trade_sys/moneymanager/crt/MM_FixedCount.h>
19 
20 using namespace hku;
21 
29 BOOST_AUTO_TEST_CASE( test_MM_FixedCount ) {
30  StockManager& sm = StockManager::instance();
31  Stock stock = sm.getStock("sh600000");
32  TradeManagerPtr tm = crtTM(Datetime(199001010000LL), 0.0, TC_FixedA());
33 
35  MoneyManagerPtr mm = MM_FixedCount(0);
36  mm->setTM(tm);
37  int result = mm->getBuyNumber(Datetime(200101010000), stock, 10.0, 10.0, PART_SIGNAL);
38  BOOST_CHECK(result == 0);
39 
41  tm = crtTM(Datetime(199001010000LL), 0.0, TC_FixedA());
42  BOOST_CHECK(tm->initCash() == 0.0);
43  mm = MM_FixedCount(100);
44  mm->setTM(tm);
45  mm->setParam<bool>("auto-checkin", true);
46  mm->getBuyNumber(Datetime(200001200000), stock, 24.11, 24.11, PART_SIGNAL);
47  BOOST_CHECK(tm->cash(Datetime(200001200000)) == 2417.02);
48 }
49 
BOOST_AUTO_TEST_CASE(test_MM_FixedCount)