Skip to content

Commit 247a12c

Browse files
authored
Add files via upload
1 parent deaa9fa commit 247a12c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+14748
-228
lines changed

Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM python:3.8.5
2+
3+
RUN apt-get update
4+
5+
RUN apt-get install --assume-yes apt-utils
6+
7+
RUN apt-get install -y alien
8+
9+
COPY . /root
10+
11+
RUN /bin/bash -c "source /etc/profile"
12+
13+
ENV TZ=Asia/Shanghai
14+
15+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
16+
17+
RUN apt-get update
18+
19+
ENV DEBIAN_FRONTEND noninteractive
20+
21+
RUN apt-get install -y vim locales
22+
23+
RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
24+
25+
ENV LANG=en_US.UTF-8
26+
27+
WORKDIR /usr/orca/app
28+
29+
COPY pip.conf /etc
30+
31+
COPY requirements.txt .
32+
33+
RUN pip install --upgrade pip
34+
35+
ENV DOCKER_SCAN_SUGGEST=false
36+
37+
RUN pip install -r requirements.txt

config.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,25 @@
1010

1111
class ConfData:
1212
config = {'zhijunfund': {'host': '10.56.36.145', 'port': 3306, 'user': 'zhijunfund', 'passwd': 'zsfdcd82sf2dmd6a', 'database': 'zhijunfund'},
13+
'funddata': {'host': 'localdev.zhijuninvest.com', 'port': 3306, 'user': 'devuser', 'passwd':'hcy6YJF123', 'database': 'funddata'},
1314
'zdj': ('zdj', 'xtKFE8k3ctqbYDOz', '10.55.57.53:1521/fundrate'),
1415
'jydb': ('jydb', 'xtKFE8k3ctqbYDOz', '10.55.57.53:1521/fundrate'),
1516
'edw': {'host': '10.52.40.222', 'port': 21050, 'username': 'fundrating', 'password': '6B2O02sP1OhYoLlX12OR',
16-
'database': 'edw', 'auth': 'LDAP'},
17+
'database': 'edw', 'auth': 'LDAP'},
1718
'bizdm': {'host': '10.52.40.222', 'port': 21050, 'username': 'fundrating', 'password': '6B2O02sP1OhYoLlX12OR',
18-
'database': 'bizdm', 'auth': 'LDAP'}}
19+
'database': 'bizdm', 'auth': 'LDAP'},
20+
'simuwang': {'host': '120.24.90.158', 'port': 3306, 'user': 'data_user_zheshangzq', 'passwd': 'zszq@2022', 'database': 'rz_hfdb_core'}}
1921

2022
@classmethod
2123
def get_conn(cls, schema):
2224
if schema == 'zhijunfund':
2325
conn = pymysql.connect(**(cls.config['zhijunfund']))
24-
elif schema == 'oracle':
25-
conn = cx.connect(*(cls.config['oracle']))
26+
elif schema == 'simuwang':
27+
conn = pymysql.connect(**(cls.config['simuwang']))
28+
elif schema == 'funddata':
29+
conn = pymysql.connect(**(cls.config['funddata']))
30+
elif schema == 'zdj':
31+
conn = cx.connect(*(cls.config['zdj']))
2632
elif schema == 'bizdm':
2733
conn = hive.Connection(**(cls.config['bizdm']))
2834
elif schema == 'edw':

const.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,35 @@ class NameConst:
2424
hold_mv_name = 'holding_mv'
2525
count_name = 'count'
2626
codes_nm = ['fund', 'code']
27+
fund_date_nm = ['fund', 'date']
2728
realized_nm = ['gx', 'rn', 'dx', 'hg', 'pg', 'qz', 'pt']
2829
realize_nm = ['pt_realize', 'hg_realize', 'dx_realize', 'qz_realize', 'pg_realize']
2930
hold_nm = ['holding', 'duration']
3031
turn_nm = ['buy_turn', 'sell_turn', 'turnover']
3132

33+
style_name = 'style'
34+
style_type_name = 'style_type'
35+
weight_name = 'weight'
36+
ret_name = 'ret'
37+
va_name = 'va'
38+
nv_name = 'nv'
39+
cum_nv_name = 'cum_nv'
40+
complex_nv_name = 'complex_nv'
41+
label_name = 'label'
42+
mul_name = 'mul'
43+
44+
today = pd.to_datetime('today').normalize()
45+
date_dict = {'since_found': '1970-01-01',
46+
'five_years': (today - pd.DateOffset(years=5)).strftime('%Y-%m-%d'),
47+
'three_years': (today - pd.DateOffset(years=3)).strftime('%Y-%m-%d'),
48+
'two_years': (today - pd.DateOffset(years=2)).strftime('%Y-%m-%d'),
49+
'one_year': (today - pd.DateOffset(years=1)).strftime('%Y-%m-%d'),
50+
'year_start': str(today.year - 1) + '-12-31'}
51+
date_label = list(date_dict.keys())
52+
3253

3354
nc = NameConst()
55+
style_type = {'asset': 'asset', 'ind': 'stock', 'bond': 'bond', 'future': 'future', 'ms': 'stock'}
3456
columns = [x for x in NameConst.__dict__.keys() if x.find('name') >= 0]
3557
columns_string = ['fund', 'code', 'flag', 'hold_type']
3658
columns_double1 = ['date', 'time', 'price', 'volume', 'close', 'preclose', 'type', 'count']

create_sql/fund_label.sql

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
create table fund_port_interval_style(
2+
id bigint(20) NOT NULL AUTO_INCREMENT comment 'ID',
3+
fund int(11) NOT NULL comment '内部编码',
4+
end_date datetime NOT NULL comment '交易日/持仓公布日',
5+
code varchar(20) NOT NULL comment '资产代码',
6+
style_type varchar(20) NOT NULL comment '风格类型',
7+
style varchar(20) NOT NULL comment '风格名称',
8+
weight decimal(18, 6) NOT NULL comment '风格权重',
9+
update_time timestamp NOT NULL comment '更新时间' DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
10+
jsid bigint(20) NOT NULL,
11+
UNIQUE KEY jsid_ (jsid),
12+
UNIQUE KEY fund_code_date_type_name (fund, end_date, code, style_type, style),
13+
KEY fund_ (fund),
14+
KEY fund_code (fund, code),
15+
KEY fund_code_type (fund, code, style_type),
16+
PRIMARY KEY (id)
17+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
18+
19+
INSERT INTO `zhijunfund_analysis`.`t_sys_seq`(`name`, `value`, `begin`, `step`, `version`, `update_time`, `remark`) VALUES ('fund_style_allocation', 1, 1, 1000, 0, now(), NULL);
20+
21+
22+
create table client_port_interval_style(
23+
id bigint(20) NOT NULL AUTO_INCREMENT comment 'ID',
24+
client_id int(11) NOT NULL comment '内部编码',
25+
end_date datetime NOT NULL comment '交易日/持仓公布日',
26+
code varchar(20) NOT NULL comment '资产代码',
27+
style_type varchar(20) NOT NULL comment '风格类型',
28+
style varchar(20) NOT NULL comment '风格名称',
29+
weight decimal(18, 6) NOT NULL comment '风格权重',
30+
update_time timestamp NOT NULL comment '更新时间' DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
31+
jsid bigint(20) NOT NULL,
32+
UNIQUE KEY jsid_ (jsid),
33+
UNIQUE KEY fund_code_date_type_name (client_id, end_date, code, style_type, style),
34+
KEY fund_ (client_id),
35+
KEY fund_code (client_id, code),
36+
KEY fund_code_type (client_id, code, style_type),
37+
PRIMARY KEY (id)
38+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
39+
40+
INSERT INTO `zhijunfund_analysis`.`t_sys_seq`(`name`, `value`, `begin`, `step`, `version`, `update_time`, `remark`) VALUES ('fund_style_allocation', 1, 1, 1000, 0, now(), NULL);

create_sql/fund_style_allocation.sql

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
create table fund_style_allocation(
2+
id bigint(20) NOT NULL AUTO_INCREMENT comment 'ID',
3+
fund int(11) NOT NULL comment '内部编码',
4+
end_date datetime NOT NULL comment '交易日/持仓公布日',
5+
style_type varchar(20) NOT NULL comment '风格类型',
6+
style varchar(20) NOT NULL comment '风格名称',
7+
weight decimal(18, 6) NOT NULL comment '风格权重',
8+
va decimal(18, 6) NOT NULL comment '风格归因',
9+
update_time timestamp NOT NULL comment '更新时间' DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
10+
jsid bigint(20) NOT NULL,
11+
UNIQUE KEY jsid_ (jsid),
12+
UNIQUE KEY code_date_type_name (fund, end_date, style_type, style),
13+
KEY code_ (fund),
14+
KEY code_date (fund, end_date),
15+
KEY code_date_type (fund, end_date, style_type),
16+
PRIMARY KEY (id)
17+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
18+
19+
INSERT INTO `zhijunfund_analysis`.`t_sys_seq`(`name`, `value`, `begin`, `step`, `version`, `update_time`, `remark`) VALUES ('fund_style_allocation', 1, 1, 1000, 0, now(), NULL);
20+
21+
22+
create table client_style_allocation(
23+
id bigint(20) NOT NULL AUTO_INCREMENT comment 'ID',
24+
client_id int(11) NOT NULL comment '内部编码',
25+
end_date datetime NOT NULL comment '交易日/持仓公布日',
26+
style_type varchar(20) NOT NULL comment '风格类型',
27+
style varchar(20) NOT NULL comment '风格名称',
28+
weight decimal(18, 6) NOT NULL comment '风格权重',
29+
va decimal(18, 6) NOT NULL comment '风格归因',
30+
update_time timestamp NOT NULL comment '更新时间' DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
31+
jsid bigint(20) NOT NULL,
32+
UNIQUE KEY jsid_ (jsid),
33+
UNIQUE KEY code_date_type_name (client_id, end_date, style_type, style),
34+
KEY code_ (client_id),
35+
KEY code_date (client_id, end_date),
36+
KEY code_date_type (client_id, end_date, style_type),
37+
PRIMARY KEY (id)
38+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
39+
40+
INSERT INTO `zhijunfund_analysis`.`t_sys_seq`(`name`, `value`, `begin`, `step`, `version`, `update_time`, `remark`) VALUES ('client_style_allocation', 1, 1, 1000, 0, now(), NULL);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
create table fund_style_port_interval(
2+
id bigint(20) NOT NULL AUTO_INCREMENT comment 'ID',
3+
fund int(11) NOT NULL comment '内部编码',
4+
end_date datetime NOT NULL comment '交易日/持仓公布日',
5+
code varchar(20) NOT NULL comment '资产代码',
6+
style_type varchar(20) NOT NULL comment '风格类型',
7+
style varchar(20) NOT NULL comment '风格名称',
8+
weight decimal(18, 6) NOT NULL comment '风格权重',
9+
update_time timestamp NOT NULL comment '更新时间' DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
10+
jsid bigint(20) NOT NULL,
11+
UNIQUE KEY jsid_ (jsid),
12+
UNIQUE KEY code_date_type_name (fund, end_date, style_type, style),
13+
KEY code_ (fund),
14+
KEY code_date (fund, end_date),
15+
KEY code_date_type (fund, end_date, style_type),
16+
PRIMARY KEY (id)
17+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
18+
19+
INSERT INTO `zhijunfund_analysis`.`t_sys_seq`(`name`, `value`, `begin`, `step`, `version`, `update_time`, `remark`) VALUES ('fund_style_port_interval', 1, 1, 1000, 0, now(), NULL);
20+
21+
22+
create table client_style_port_interval(
23+
id bigint(20) NOT NULL AUTO_INCREMENT comment 'ID',
24+
client_id int(11) NOT NULL comment '内部编码',
25+
end_date datetime NOT NULL comment '交易日/持仓公布日',
26+
code varchar(20) NOT NULL comment '资产代码',
27+
style_type varchar(20) NOT NULL comment '风格类型',
28+
style varchar(20) NOT NULL comment '风格名称',
29+
weight decimal(18, 6) NOT NULL comment '风格权重',
30+
update_time timestamp NOT NULL comment '更新时间' DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
31+
jsid bigint(20) NOT NULL,
32+
UNIQUE KEY jsid_ (jsid),
33+
UNIQUE KEY code_date_type_name (client_id, end_date, style_type, style),
34+
KEY code_ (client_id),
35+
KEY code_date (client_id, end_date),
36+
KEY code_date_type (client_id, end_date, style_type),
37+
PRIMARY KEY (id)
38+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
39+
40+
INSERT INTO `zhijunfund_analysis`.`t_sys_seq`(`name`, `value`, `begin`, `step`, `version`, `update_time`, `remark`) VALUES ('client_style_port_interval', 1, 1, 1000, 0, now(), NULL);

create_sql/fund_style_ts.sql

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
create table fund_style_ts(
2+
id bigint(20) NOT NULL AUTO_INCREMENT comment 'ID',
3+
fund int(11) NOT NULL comment '内部编码',
4+
end_date datetime NOT NULL comment '交易日/持仓公布日',
5+
style_type varchar(20) NOT NULL comment '风格类型',
6+
style varchar(20) NOT NULL comment '风格名称',
7+
weight decimal(18, 6) NOT NULL comment '风格权重',
8+
update_time timestamp NOT NULL comment '更新时间' DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
9+
jsid bigint(20) NOT NULL,
10+
UNIQUE KEY jsid_ (jsid),
11+
UNIQUE KEY code_date_type_name (fund, end_date, style_type, style),
12+
KEY code_ (fund),
13+
KEY code_date (fund, end_date),
14+
KEY code_date_type (fund, end_date, style_type),
15+
PRIMARY KEY (id)
16+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
17+
18+
INSERT INTO `zhijunfund_analysis`.`t_sys_seq`(`name`, `value`, `begin`, `step`, `version`, `update_time`, `remark`) VALUES ('fund_style_ts', 1, 1, 1000, 0, now(), NULL);
19+
20+
21+
create table client_style_ts(
22+
id bigint(20) NOT NULL AUTO_INCREMENT comment 'ID',
23+
client_id int(11) NOT NULL comment '内部编码',
24+
end_date datetime NOT NULL comment '交易日/持仓公布日',
25+
style_type varchar(20) NOT NULL comment '风格类型',
26+
style varchar(20) NOT NULL comment '风格名称',
27+
weight decimal(18, 6) NOT NULL comment '风格权重',
28+
update_time timestamp NOT NULL comment '更新时间' DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
29+
jsid bigint(20) NOT NULL,
30+
UNIQUE KEY jsid_ (jsid),
31+
UNIQUE KEY code_date_type_name (client_id, end_date, style_type, style),
32+
KEY code_ (client_id),
33+
KEY code_date (client_id, end_date),
34+
KEY code_date_type (client_id, end_date, style_type),
35+
PRIMARY KEY (id)
36+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
37+
38+
INSERT INTO `zhijunfund_analysis`.`t_sys_seq`(`name`, `value`, `begin`, `step`, `version`, `update_time`, `remark`) VALUES ('client_style_ts', 1, 1, 1000, 0, now(), NULL);

0 commit comments

Comments
 (0)