Commit ed794b2e authored by wenwen.tang's avatar wenwen.tang 😕

https://www.tapd.cn/59187493/documents/show/1159187493001000730

增加分类资产下最小留存个数
parent da666688
...@@ -172,15 +172,19 @@ class FundDividendSortinoAssetOptimize(SortinoAssetOptimize): ...@@ -172,15 +172,19 @@ class FundDividendSortinoAssetOptimize(SortinoAssetOptimize):
customType = f.get('customType') customType = f.get('customType')
exclude = f.get('exclude') exclude = f.get('exclude')
volatility = f.get('volatility') volatility = f.get('volatility')
retain = f.get('min-retain')
records = [fund for fund in funds if fund['customType'] == customType and fund['id'] in annual.keys()] records = [fund for fund in funds if fund['customType'] == customType and fund['id'] in annual.keys()]
records = sorted(records, key=lambda x: annual[x['id']]) records = sorted(records, key=lambda x: annual[x['id']])
max_exclude = len(records) - retain
if exclude is not None: if exclude is not None:
exclude = exclude if len(records) > exclude else len(records) exclude = exclude if len(records) > exclude else len(records)
exclude = max_exclude if (len(records) - exclude) < retain else exclude
if exclude > 0: if exclude > 0:
filtered.extend(records[-exclude:]) filtered.extend(records[-exclude:])
records = records[:- exclude] records = records[:- exclude]
if volatility is not None: if volatility is not None and len(records) > retain:
records = [record for record in records if annual.get(record['id']) > volatility] max_exclude = max_exclude - len(records)
records = [record for record in records if annual.get(record['id']) > volatility][:max_exclude]
filtered.extend(records) filtered.extend(records)
for f in filtered: for f in filtered:
funds.remove(f) funds.remove(f)
......
...@@ -80,16 +80,15 @@ asset-pool: # 资产池模块 ...@@ -80,16 +80,15 @@ asset-pool: # 资产池模块
optimize-count: 3 #基金优选个数 optimize-count: 3 #基金优选个数
annual-volatility-filter: #1各资产年化波动率末exclude位 2各资产年化波动率大于volatility annual-volatility-filter: #1各资产年化波动率末exclude位 2各资产年化波动率大于volatility
- customType: 1 - customType: 1
exclude: 1
volatility: 0
- customType: 2
exclude: 3
volatility: 0.05
- customType: 3
exclude: 2 exclude: 2
volatility: 0.001 min-retain: 2
# volatility: 100
- customType: 4
exclude: 5
min-retain: 2
# volatility: 111
annual-volatility-section: # 波动率时间区间 annual-volatility-section: # 波动率时间区间
- years: 3 - years: 1
portfolios: # 投组模块 portfolios: # 投组模块
holder: # 持仓投组相关 holder: # 持仓投组相关
init-nav: 100 # 初始金额 init-nav: 100 # 初始金额
...@@ -252,8 +251,8 @@ robo-executor: # 执行器相关 ...@@ -252,8 +251,8 @@ robo-executor: # 执行器相关
use: ${ROBO_EXECUTOR:backtest} # 执行哪个执行器,优先取系统环境变量ROBO_EXECUTOR的值,默认backtest use: ${ROBO_EXECUTOR:backtest} # 执行哪个执行器,优先取系统环境变量ROBO_EXECUTOR的值,默认backtest
sync-data: ${SYNC_DATA:off} # 是否开启同步资料数据 sync-data: ${SYNC_DATA:off} # 是否开启同步资料数据
backtest: # 回测执行器相关 backtest: # 回测执行器相关
start-date: 2013-01-02 # 回测起始日期 start-date: 2024-03-02 # 回测起始日期
end-date: 2023-10-31 # 回测截止日期 end-date: 2024-04-11 # 回测截止日期
sealing-period: 10 #调仓封闭期 sealing-period: 10 #调仓封闭期
start-step: ${BACKTEST_START_STEP:1} # 回测从哪一步开始执行 1:计算资产池;2:计算最优投组:3:计算再平衡信号以及持仓投组 start-step: ${BACKTEST_START_STEP:1} # 回测从哪一步开始执行 1:计算资产池;2:计算最优投组:3:计算再平衡信号以及持仓投组
end-step: ${BACKTEST_END_STEP:3} # 回测从哪一步执行完成后结束执行 1:计算资产池;2:计算最优投组:3:计算再平衡信号以及持仓投组 end-step: ${BACKTEST_END_STEP:3} # 回测从哪一步执行完成后结束执行 1:计算资产池;2:计算最优投组:3:计算再平衡信号以及持仓投组
......
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