Commit ea7ee695 authored by stephen.wang's avatar stephen.wang

Merge remote-tracking branch 'origin/dev-dividend' into dev-dividend

parents 97a3a779 da666688
...@@ -173,13 +173,15 @@ class FundDividendSortinoAssetOptimize(SortinoAssetOptimize): ...@@ -173,13 +173,15 @@ class FundDividendSortinoAssetOptimize(SortinoAssetOptimize):
exclude = f.get('exclude') exclude = f.get('exclude')
volatility = f.get('volatility') volatility = f.get('volatility')
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']])
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)
if exclude > 0: if exclude > 0:
records = records[:len(records) - exclude] filtered.extend(records[-exclude:])
records = records[:- exclude]
if volatility is not None: if volatility is not None:
records = [record for record in records if annual.get(record['id']) > volatility] records = [record for record in records if annual.get(record['id']) > volatility]
filtered.extend(records) filtered.extend(records)
for f in filtered: for f in filtered:
funds.remove(f) funds.remove(f)
return funds return funds
......
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