-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support multiple manager when outputing high-score-fund
- Loading branch information
Showing
5 changed files
with
114 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
''' | ||
Desc: | ||
File: /query.py | ||
Project: crud | ||
File Created: Wednesday, 21st September 2022 10:54:27 pm | ||
Author: [email protected] | ||
----- | ||
Copyright (c) 2022 Camel Lu | ||
''' | ||
|
||
import sys | ||
sys.path.append('./src') | ||
from sqlalchemy.orm import Session | ||
from sqlalchemy import and_ | ||
from models.fund import FundBase, FundQuarter | ||
from models.manager import ManagerAssoc | ||
from models.var import engine | ||
|
||
session = Session(engine) | ||
|
||
def query_high_score_funds(quarter_index): | ||
words = ['%指数%', '%C', '%E', '%H%'] | ||
rule = and_(*[FundBase.fund_name.notlike(w) for w in words]) | ||
res = session.query(FundQuarter,ManagerAssoc,FundBase).where(FundQuarter.fund_code == ManagerAssoc.fund_code).where(FundQuarter.fund_code == FundBase.fund_code).filter(FundQuarter.quarter_index == quarter_index, \ | ||
FundQuarter.morning_star_rating_5 >= 3, # 5年评级大于等于3 | ||
FundQuarter.morning_star_rating_3 == 5, # 3年评级等于5 | ||
FundQuarter.stock_position_total >= 50, # 股票仓位大于50 | ||
FundQuarter.stock_position_ten <= 60, # 十大股票仓位小于60 | ||
FundQuarter.risk_assessment_sharpby > 1, # 夏普比例大于1 | ||
FundQuarter.risk_rating_2 > 1, # 2年风险评级大于1 | ||
FundQuarter.risk_rating_3 > 1, # 3年风险评级大于1 | ||
FundQuarter.risk_rating_5 > 1, # 5年风险评级大于1 | ||
# ManagerAssoc.manager_start_date < last_year_date, # 至少任职该基金一年 | ||
FundQuarter.total_asset < 100, # 总规模资金小于100亿 | ||
).filter(rule).all() | ||
return res | ||
|
||
|
||
if __name__ == '__main__': | ||
quarter_index = '2022-Q2' | ||
fund_list = query_high_score_funds(quarter_index) | ||
# print("fund_list",fund_list) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters