# FT Quant Rebalance API # Version 1.3 ## Quick Start for Developing ### Developing 1. 為你的再平衡模型取一個簡稱(vender),Ex: `sample` ( mpt, tv 已使用) 2. 複製 vender/sample_quant_api.py 到 vender/`sample`_quant_api.py 3. 打開 vender/`sample`_quant_api.py 實作 _rebalance(), 與 _dividend() (如果有需要) _rebalance(), 與 _dividend() 開發請參考 vender/sample_quant_api.py 測試方式分述如下: #### _Rebalance() 測試說明 1. Testing: ``` python reb_test.py vender mode portfiolio_file [recommand_file [ class_file [record_recomm_file [YYYYMMDD]]]] ex: python reb_test.py sample test test_data\reb.json test_data\portfolio.json test_data\class.json test_data\record_portfolio.json 20180401 ``` 2. 參數格式說明 1. vender = 再平衡模型取一個簡稱 (sample 會執行 sample code ) 2. mode = test or pord. **`計量團隊`請固定用test**, prod 會取實際資料,且不需後續參數 3. portfiolio_file = 客戶持股比例檔(請參考quant_api.pdf: Q00003), Prod mode: 資料由中台系統傳入 4. recommand_file = 從推薦系統取得資料之格式,Prod mode: 資料由本RecommSystem提供 5. class_file = 資產分類檔。 **需由`計量團隊`提供** 6. record_recomm_file = 歷史推薦檔 ( for testing: default: "") 7. YYYYMMDD 模擬測試日期(default: Today) ##### About Test Case 為了測試各種情況,請參考 src\test_case_gen\Sample 下建立相關用測試用例所需 json檔 ``` cd src\test_case_gen\sample python gentestcase.py testcase_example.xlsx ``` 步驟: 1. 建立目錄 src/test_case_gen/`vendor` 2. copy gentestcase.py, testcase_example.xlsx 到 src/test_case_gen/`vendor` 3. 編輯 test_case.xlsx (與相關人員確認test case正確性) 4. 執行 gentestcase.py (可自行調整程式,確保正確 parse test_case.xlsx) 系統UAT時,會根據測試用例,做產出所有測試結果,提供`計量團隊`與相關專案人員審視,是否與白皮書相符。 通過所有測試,方可上線 ##### Troubleshooting 1. 為了測試Prod mode(RecommSystem 與 prod_api_agent.py ) ``` SET PYTHONPATH=. python lib\prod_api_agent.py ``` #### _Dividend() 測試說明 1. Testing: ``` python div_test.py vender portfiolio_file [YYYYMMDD] ex: python div_test.py sample test_data\test_case_01.json or python div_test.py sample test_data_div\test_case_01.json 20230301 ``` 2. 參數格式說明 1. vender = 再平衡模型取一個簡稱 (sample 會執行 sample code ) 2. portfiolio_file = 客戶持股詳細資料 (請參考quant_api.pdf: Q00003) 3. YYYYMMDD 模擬測試日期(default: Today) ##### About Test Case TBD