智能财务机器人是2024-2025学年第二学期 厦门大学管理学院的新开课程,由财务系和管理科学系共同教授。课程以实训为主,要求同学以组队形式完成一个指定功能的智能产品。

    本人所在队伍以“识别债券违约风险”为主要功能研发了出了一代产品,略显简陋,所以我决定参考我们的已有产品并利用已有的数据,独自重建v2版本,这可能是由我的强迫心理所催动的想法,但是当我建立这个帖子的时候,我就已经开始着手开发了,good luck.

旧版展示

image

2024.6.19

    首先,为了像一个产品,我们得有一个logo,要体现出产品的特点,要表现出独特的所在。在我的直男审美下,我设计出了第一版logo(希望就最后一版吧hh)

Alt text

    整体是一个盾牌的形象,体现了守护,盾牌中的XM和盾牌下沿的U形构成了“XMU”,两条绶带则对应了财务系和管理科学系,蓝色的设计给人以精准和优雅的感觉。

    以上内容是我瞎编的,反正我觉得这个logo还算是能入眼吧,就决定是这个了!

    接下来,是整体设计部分咯。本产品分为三层结构:数据库(存储所有可获得的债券信息数据,包括债券的券面信息和发型公司信息,以及登录所用的用户信息数据库)、前端页面(负责展示数据,接收用户的输入)、后端程序(连接前端和数据库,实现指定数据库数据的展示和前端与数据库的传输)。

    数据库采取MySQL,将数据分为“user_data”,“bond_information”,“trading_information”,“income_statement”,“balance_sheet”,“cash_statement”,“macro_info”。

    前端采用Vue3+Element组件。

    后端采用python的flask架构。

    第一天完成登录页面以及登录系统。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
@app.route('/login', methods=['POST'])
def login():
data = request.json
user = data.get('user')
password = data.get('pass')
...

@app.route('/register', methods=['POST'])
def register():
data = request.json
user = data.get('user')
password = data.get('pass')
...

Alt text

2024.6.20

    今天的工作是数据库的搭建以及初步在前端页面上展示财务数据,使用el-table一步到位,省的调样式了。配套的还需要写好输入债券代码的查询功能,和后端读取、处理从数据库提出来的数据的代码。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 单独写获取具体表的函数,便于调试

def get_balance_sheet_record(code):
connection = mysql.connector.connect(**config)
cursor = connection.cursor(dictionary=True)

try:
query = "SELECT * FROM balance_sheet WHERE `债券代码` = %s"
cursor.execute(query, (code,))


result = cursor.fetchall()
finally:
cursor.close()
connection.close()
return result

def get_name_record(code):
connection = mysql.connector.connect(**config)
cursor = connection.cursor(dictionary=True)

try:
query = "SELECT 债券代码, 债券简称, 债券全称 FROM ai_finance.bond_information WHERE 债券代码 = %s"
cursor.execute(query, (code,))

result = cursor.fetchone()
finally:
cursor.close()
connection.close()
return result

# 接口部分
@app.route('/get_balance', methods=['GET'])
def get_balance():
code = request.args.get('code')

if not code:
return jsonify({"error": "code parameter is required"}), 400

# 获取数据库记录
record = get_balance_sheet_record(code)
print(record)
if record:
return jsonify(record)
else:
return jsonify({"error": "Record not found"}), 404
return

@app.route('/get_name', methods=['GET'])
def get_name():
code = request.args.get('code')

if not code:
return jsonify({"error": "code parameter is required"}), 400
# 获取数据库记录
record = get_name_record(code)

if record:
return jsonify(record)
else:
return jsonify({"error": "Record not found"}), 404
return

    数据库上的每个表也都插入了数据,并删除了部分缺失值过多的列。

2024.6.26

    由于归家拖了几天进度,今天就匆匆把所有财务数据的展示部分的前后端都写好了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<h3>资产负债表</h3>
<el-table :data="balance_data" style="width: 90%" max-height="500px" table-layout="auto">
<el-table-column v-for="(value, key, index) in balance_data[0]" :width="index < 2 ? 80 : 130" :key="key" :prop="key.toString()" :label="key.toString()" :fixed="index < 3 ? 'left' : false"></el-table-column>
</el-table>
<h3>现金流量表</h3>
<el-table :data="cash_data" style="width: 90%" max-height="500px" table-layout="auto">
<el-table-column v-for="(value, key, index) in cash_data[0]" :width="index < 2 ? 80 : 130" :key="key" :prop="key.toString()" :label="key.toString()" :fixed="index < 3 ? 'left' : false"></el-table-column>
</el-table>
<h3>利润表</h3>
<el-table :data="income_data" style="width: 90%" max-height="500px" table-layout="auto">
<el-table-column v-for="(value, key, index) in income_data[0]" :width="index < 2 ? 80 : 130" :key="key" :prop="key.toString()" :label="key.toString()" :fixed="index < 3 ? 'left' : false"></el-table-column>
</el-table>
<h3>交易信息</h3>
<el-table :data="trading_data" style="width: 90%" max-height="500px" table-layout="auto">
<el-table-column v-for="(value, key, index) in trading_data[0]" :width="index < 2 ? 80 : 130" :key="key" :prop="key.toString()" :label="key.toString()" :fixed="index < 3 ? 'left' : false"></el-table-column>
</el-table>