python基金估值 利用python实时刷新基金估值效果(摸鱼小工具)

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

python基金估值 利用python实时刷新基金估值效果(摸鱼小工具)

奔跑的鸡大腿92   2021-09-14 我要评论
想了解利用python实时刷新基金估值效果(摸鱼小工具)的相关内容吗,奔跑的鸡大腿92在本文为您仔细讲解python基金估值的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:python基金估值,python实时基金估值,下面大家一起来学习吧。

摸鱼小工具_利用python实时刷新基金估值 效果预览

在这里插入图片描述

上源码

import requests
import json
import os
from prettytable import PrettyTable
import time

fundlist = ['163817','161017','003860']

def GetFundJsonInfo(fundcode):
    url = "http://fundgz.1234567.com.cn/js/"+fundcode+".js"
    response = requests.get(url)
    fundDataInfo = response.text.split('({')[1]
    fundDataInfo = '{'+ fundDataInfo.split('})')[0] + '}'
    fundDataInfo = json.loads(fundDataInfo)
    return fundDataInfo
    
os.system("cls")
while True:
    table = PrettyTable(["名称","昨日净值","实时估值","增长率"])
    for fund in fundlist:
        myfund = GetFundJsonInfo(fund)
        table.add_row([myfund['name'],myfund['dwjz'],myfund['gsz'],myfund['gszzl']])
    print(table)
    time.sleep(5)
    os.system("cls")

说明

  • prettytable 通过表格格式化打印基金数据便于浏览数据
  • os.system(“cls”) 用于清屏刷新
  • 原始的响应内容
jsonpgz({"fundcode":"163817","name":"中银转债增强债券B","jzrq":"2021-09-10","dwjz":"3.1120","gsz":"3.1127","gszzl":"0.02","gztime":"2021-09-13 14:54"});

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们