# 创建实体(概念、股票、股东、股通)
sz = Node('深股通',名字='深股通')
graph.create(sz)
sh = Node('沪股通',名字='沪股通')
graph.create(sh)for i in concept_num.values:
a = Node('概念',概念代码=i[1],概念名称=i[2])# print('概念代码:'+str(i[1]),'概念名称:'+str(i[2]))
graph.create(a)for i in stock.values:
a = Node('股票',TS代码=i[1],股票名称=i[3],行业=i[4])# print('TS代码:'+str(i[1]),'股票名称:'+str(i[3]),'行业:'+str(i[4]))
graph.create(a)for i in holder.values:
a = Node('股东',TS代码=i[0],股东名称=i[1],持股数量=i[2],持股比例=i[3])# print('TS代码:'+str(i[0]),'股东名称:'+str(i[1]),'持股数量:'+str(i[2]))
graph.create(a)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 创建关系(股票-股东、股票-概念、股票-公告、股票-股通)
matcher = NodeMatcher(graph)for i in holder.values:
a = matcher.match("股票",TS代码=i[0]).first()
b = matcher.match("股东",TS代码=i[0])for j in b:
r = Relationship(j,'参股',a)
graph.create(r)print('TS',str(i[0]))for i in concept.values:
a = matcher.match("股票",TS代码=i[3]).first()
b = matcher.match("概念",概念代码=i[1]).first()if a ==Noneor b ==None:continue
r = Relationship(a,'概念属于',b)
graph.create(r)