基金持仓数据分析,满仓干还是等风来?

人工智能34

前言

大家好。您有没有理财产品?不是推广HA,而是分享一篇关于基金数据分析的文章。为了照顾完全不懂基金的童鞋,文前特意做了一个小科普,帮助大家了解指数基金和股票型基金的概念。

[En]

Hello, everyone. Do you have any wealth management products? Not to promote ha, but to share an article on the analysis of fund data. In order to take care of children's shoes who do not understand funds at all, a small popular science has been specially done in front of the article to help you understand the concept of index funds and stock funds.

接着才用Python去爬取这些基金收益的数据,从6个维度全方面分析,最后得出相应的理财建议,当然了, 投资有风险,入市需谨慎,这篇文章的重点也只是在数据分析上, 大家千万不要过度迷信结论哦~

正文

本篇为系列文章的第四篇,是对 21年三季度的基金持仓披露数据进行分析

篇幅较长,阅读会花 5-10 分钟,读完本篇文章,你可能会收获以下几点:

  • 今年的股票型基金整体收益情况?
  • 今年的优秀基金经理有哪些?
  • 今年的优秀基金有哪些?
  • 后续看好的方向是什么?
  • *满仓干还是等风来?

1. 正文

ok,和往常几篇文章一样,本文分为三部分:

  • ① 4 种基金的大致介绍
  • ② 爬取基金收益数据及TOP300收益的基金最新持仓
  • ③ 从6个维度进行基金数据分析

鉴于本文的总体基调是围绕基金的分析,有必要对什么是基金做一个简单的介绍。

[En]

In view of the fact that the overall tone of this article is around the analysis of the fund, it is necessary to make a brief introduction to what the fund is.

当然,这只是一个简单的介绍。本文更多的是对近几年发行的基金收益和持仓数据进行爬行,以期做一个简单的分析。

[En]

Of course, it's just a simple introduction. This article is more about crawling the data of fund returns and positions issued in recent years, so as to make a simple analysis.

目前各基金公司披露的持仓数据都是截止 2021年第三季度,后续也会披露最新持仓数据,到时候 小一会继续跟踪分析,记得到时候回来看更新!

ok,直接开始,go

1.1 基金介绍

只想看分析的同学可以 直接滑到第三小节
只想看结论的同学可以 直接滑到文末

先来说说基金是什么?

首先,对于基金,大致可以分为: 货币型基金、债券型基金、混合型基金、股票型基金等等

主要说一下这几个各自是什么,后面我们针对性的用数据去分析。

货币型基金

只投资于货币市场,如银行存款、国家或企业发行的短期债券等,因为波动性低、风险低,可以等同于储蓄产品。

[En]

Only invest in the money market, such as bank deposits, short-term bonds issued by the state or enterprises, etc., because of low volatility and low risk, it can be equated with savings products.

与余额宝类似的是货币基金,对这只货币基金的评价主要取决于:七日年化收益率和万元收益率。

[En]

Similar to Yu'e Bao is a monetary fund, the evaluation of this monetary fund mainly depends on: seven-day annualized rate of return and ten thousand returns.

这个比较容易理解,风险也很低,个人要选择货币型基金就直接余额宝完事,T+0,简简单单。

债券型基金

与货币基金相比,债券基金投资于期限更长的债券。除了债券,他们还可以投资股票。

[En]

Compared with monetary funds, bond funds invest in bonds with a longer maturity. In addition to bonds, they can also invest in stocks.

债券基金相对于货币基金有一定的风险,但从长远来看,收益也会更高。

[En]

Bond funds have certain risks relative to money funds, but in the long run, returns will also be higher.

混合型基金

与债券型基金相比,混合型基金除了可以投资债券外,还可以投资不同风格的股票。

[En]

Compared with bond funds, hybrid funds can also invest in different styles of stocks in addition to bonds.

混合型基金根据股票和债券的占比,又细分为 偏股型基金 和配置型基金等等。

与前两者相比,混合型基金实现了投资多元化,无需购买风格迥异的股票型基金、债券型基金和货币基金。

[En]

Compared with the former two, hybrid funds achieve investment diversification, without the need to buy stock funds, bond funds and money funds with different styles.

股票型基金

股票型基金是指投资于股票市场的基金,其中股票仓位不能低于80%。

股票基金可细分为主动型和被动型(指数基金)。与主动型基金相比,指数基金更稳健,跟踪大盘指数的波动。

[En]

Stock funds can be subdivided into active and passive (index funds). Compared with active funds, index funds are more robust and follow the fluctuations of the market index.

相比前三者,股票基金属于 高风险高收益类 的基金。

下面来看今天的核心: 爬虫+分析

2. 基金数据爬取

爬虫部分的核心代码比较简单,比起上次的租房数据爬取简单了x倍,今天主要 说一下流程就行

想了解爬虫的学生回顾一下租房数据:爬行动物--获取最完整的租房数据|所附源代码

[En]

Students who want to learn about crawlers look back at the rental data: reptiles-get the most full rental data | attached source code

基金数据的爬取小一选择了天天基金网,首页长这样的:

基金持仓数据分析,满仓干还是等风来?

如你所见,对于基金的类型:股票、混合、债券和指数都是明确的,请在收集字段时记下每只基金的所有回报。

[En]

As you can see, for the types of funds: stocks, hybrids, bonds and indices are all clear, please take down all the returns of each fund when collecting fields.

ok,那就直接用官网定的标签去爬,采集上图圈出的数据字段。

第二步就是每个基金的详细持仓情况,看图:

基金持仓数据分析,满仓干还是等风来?

主要包括各季度的成立时间、规模、基金管理人及明细头寸。

[En]

It mainly includes the establishment time, scale, fund manager and detailed position of each quarter.

爬虫大致思路

  1. 爬取每个基金标签下的所有基金以及收益率情况
  2. 根据基金代码爬取每个基金得到详细指标
  3. 根据基金代码爬取每个基金的季度持仓情况

需要说明一下,第 2 步和第 3 步的数据不在一个页面下,第 2 步的数据通过页面解析可以拿到,第 3 步的数据是动态加载后呈现在页面上的,可以通过接口拿到数据。

限于篇幅,主要代码如下:

# 爬取每个基金的数据
rank_detail_data = []
position_data = []
error_funds_list = []
for row_index, data_row in data_rank.iterrows():
    fund_code = str(data_row['基金代码'])
    try:
        '''爬取页面,获得该基金的详细数据'''
        position_title_url = "http://fundf10.eastmoney.com/ccmx_" + str(fund_code[1:]) + ".html"
        print('正在爬取第 {0}/{1} 个基金 {2} 的详细数据中...'.format(row_index+1, len(data_rank), fund_code[1:]))
        response_title = requests.get(url=position_title_url, headers={'User-Agent': get_ua()}, timeout=10)
        # 解析基金的详细数据
        rank_detail_info = resolve_rank_detail_info(fund_code[1:], response_title)

        """爬取页面,获取该基金的持仓数据"""
        position_data_url = "http://fundf10.eastmoney.com/FundArchivesDatas.aspx?type=jjcc&code=" + \
        str(fund_code[1:]) + "&topline=10&year=&month=&rt=" + str(random.uniform(0, 1))
        print('正在爬取第 {0}/{1} 个基金 {2} 的持仓情况中...'.format(row_index + 1, len(data_rank), fund_code[1:]))
        # 解析基金的持仓情况
        response_data = requests.get(url=position_data_url, headers={'User-Agent': get_ua()}, timeout=10)
        fund_positions_data = resolve_position_info(fund_code[1:], response_data.text)

        # 保存数据
        rank_detail_data.append(rank_detail_info)
        position_data.extend(fund_position_data for fund_position_data in fund_positions_data)
 except:
  error_funds_list.append(fund_code)
        print("{0} 数据爬取失败,稍后会进行重试,请注意!".format(str(fund_code[1:])))
 # 随机休眠2-4 秒
 time.sleep(random.randint(2, 4))

爬取完成后,数据是这样的:

基金持仓数据分析,满仓干还是等风来?

基金持仓数据分析,满仓干还是等风来?

基金持仓数据分析,满仓干还是等风来?

3. 基金数据分析

对于4种类型的基金数据,下面主要对 股票型基金进行分析

首先,股票型基金共 1417 个,后面分析和排序的依据均是针对 今年来收益率 这个指标进行的,大家注意下

1. 基本:收益率分布

1417个股票型基金中 1410 个今年来收益率不为空,针对其进行分析:

股票型基金今年来 收益率>0 的有 840 个,占比 59.57%;整体今年来平均收益率为 5.89%

如下图:

基金持仓数据分析,满仓干还是等风来?

再来看下整体的收益率分布情况:

基金持仓数据分析,满仓干还是等风来?

股票型基金的收益率小于0的占比 40%,而且随着收益率的上升基金个数逐渐下降,和上上季度正态分布的图像形成了鲜明的对比

另外,收益率 大于50%只有 13只基金,真的是凤毛麟角般的存在

2. 基本:资产规模分布

对于资产规模,小易是这样理解的:资产规模大的基金收益稳定的同时,也很难掉头。小规模资金回报波动较大,但也能及时避险

[En]

As for the size of assets, Xiaoyi understands it like this: while the returns of funds with large assets are stable, it will also be difficult to make a U-turn. * small-scale capital returns will fluctuate greatly, but they can also avoid risks in time.*

因为基金较多,以下只选取今年来收益率 Top300 的基金分析其资产规模。另外,资产规模均是截止到 2021-09-30 日的资金资产规模。

一起看图:

基金持仓数据分析,满仓干还是等风来?

股票型基金的资产规模集中在 0-10亿元 区间,其中, 大于70亿元 的基金有 10个,占比为 3.33%

可以看到,在20 亿元以下规模的基金占比 80以上,相比上上季度的78%上升了2PP

3. 重点:收益率前10!

基本面看完了, 下面来点干货

股票型基金今年来收益率的最高是 113.98%Top10 的平均收益是 62.98%

基金持仓数据分析,满仓干还是等风来?

可以看到,前10收益率的基金差距比较明显,尤其是基金『前海开源公用事业股票』收益率一骑绝尘,拉开第二名 51.2个百分点,大牛中的大牛

除了第一名之外,其他2-10的基金收益率比较平稳,特别是2-5名之间,差距较小。

从图中看,资产规模与近两年的收益率不是强相关,另外, 排名前5 的基金似乎是个不错的选择

供参考:

基金持仓数据分析,满仓干还是等风来?

4. 干货:基金经理选谁?

买基金要看对基金经理,所以这一步是分析基金经理

同样的,我们取收益率较高的 前50名基金进行分析,根据基金经理 持有基金的平均收益率 为标准,选取排名 前15 的经理,如下图:

基金持仓数据分析,满仓干还是等风来?

平均收益率前5的股票型基金经理都是各持有一只股票型基金,而对应的股票型基金我们在上一步已经看到了

可以看出,这次的业绩与上一季度完全不同,尤其是在头部基金经理领域,基本上进行了洗牌。

[En]

It can be seen that the results this time are completely different from those of the quarter before last, especially in the area of head fund managers, which is basically reshuffled.

当然,有一部分的原因是我将时间粒度由近2年缩小到今年来有一定的关系

崔玉龙在股票型基金经理中持有的基金涨幅惊人,在今年的市场上能够实现收益翻倍,确实令人印象深刻。

[En]

The fund held by Cui Yulong among equity fund managers has risen astonishingly and has been able to double its income in this year's market, which is really impressive.

另外,崔宸龙经理还管理一个混合型基金『 前海开源新经济混合A』,今年的收益率 110.01%,在今年涨幅排行榜排第二。好奇的话可以去看看这两个基金的最新持仓,你应该能明白为什么会有这么高的收益

小结:

两极分化相当严重,特别是在今年这个特殊的市场,抓住主线应该能赚很多钱,否则可能干一整年都白干。

[En]

Polarization is quite serious, especially in this year's special market, grasping the main line should be able to make a lot of money, otherwise you may work for a whole year in vain.

5. 干货:重仓买哪个?

再来说一个大家更感兴趣的内容: 基金持仓情况

每一个基金的前 10 大持仓股都可以作为该基金的代表,这个毋庸置疑,所以在爬虫部分我们也就直接爬了前十大持仓数据。

这一节我们同样选取收益率较高的 前50名 股票型基金和混合型基金进行分析

每个基金都有前 10 大持仓股,所以对应的就有 500 个持仓股代表,筛选 持仓股累计占比排名前 30 个 持仓股作为重点观察对象,如图:

基金持仓数据分析,满仓干还是等风来?

需要说明的是:加粗表示同时出现在股票型基金和混合型基金中。

可以看到,前15持仓股基本以光伏产业链、新能源为主,包括:宁德时代为龙头的光伏产业链、以比亚迪为龙头的新能源产业链

但是需要注意的是,15-30持仓股发生了很大的分歧,从分歧个股的分布来看,对应的板块集中在能源、有色、钢铁石油等

如果大家感兴趣,可以翻到文章开头看看1季度的文章中这个位置的图长什么样,再看看现在的图,做个对比

想必就算你不懂板块和个股,也能看出点端倪来。

小结:

这是今年以来收益率前50的基金的持仓情况,很明显,光伏+新能源是主线,拿住就能赚

对应的白酒、医药,在上面的图中看不到影子

但是但是但是,出现了很大的分歧,继续往下看!

6. 重磅干货:跟着明星经理买?

最后,我们继续抄作业, 抄优等生的优秀作业

以上分析了明星基金经理,也分析了收益率较高的基金的仓位,下面将两者结合起来进行综合

[En]

The above analysis of the star fund managers, but also analyzed the position of higher-yielding funds, the following combination of the two to a comprehensive

选择股票型明星基金经理5人和他们持有的5只基金,如下图:

基金持仓数据分析,满仓干还是等风来?

选取这5个股票型基金的前10大持仓再次分析:

这里的分析思路和第6小节一样

基金持仓数据分析,满仓干还是等风来?

如果说,第6小节上面那幅图你看不清分歧在哪,那现在这张图想必能看清了吧

同样,股票型基金和混合型基金一致持有光伏产业链相关个股,但是一致性比重已经降低到16.7%,而1季度的一致性当时是达到40%的

当然,这也和今年的行情有关,尤其是下半年过后,板块轮动频繁,很难有一个总能上冲当先锋的板块。

[En]

Of course, this also has something to do with this year's market, especially after the second half of the year, the frequent rotation of the plate, making it difficult to have a plate that can always go up to take the vanguard.

因此,这将导致基金经理职位的多元化。由于都是旋转,所以我选择了一些低位,既可以避免高位板块的回调,又可以在旋转时蹲守一波春风。

[En]

Therefore, it will lead to the diversification of fund managers' positions. Since they all rotate, I choose some low positions, which can not only avoid the pullback of the high plate, but also squat for a wave of spring breeze during rotation.

妙啊!

小结:

产生分歧是好事,这意味着下一次就会出现新的更好的机会

当然,现在机会可能并不明显,也不可能看到明星基金经理将头寸从上述头寸转移到了哪个板块。

[En]

Of course, the opportunity may not be obvious now, and it is not possible to see which sector the star fund managers have shifted their positions to from the above positions.

但,总归是会有机会的,等着就行, 四季度持仓披露的时候,这个答案应该就会揭晓

尤其是近期白酒板块的异动、基金经理转仓的传闻等等,都是分歧的开始。

[En]

In particular, the recent changes in the liquor sector, rumors that fund managers have changed their positions, and so on, are the beginning of differences.

我们,也等一个春风来!

Original: https://blog.csdn.net/Python_xiaowu/article/details/122142707
Author: Python_xiaowu
Title: 基金持仓数据分析,满仓干还是等风来?



相关阅读

Title: Tensorflow学习之tf.layers.dense()

1. tf.layers.dense()

首先,TensorFlow中封装了全连接层函数 tf.layers.dense(),方便了开发者自己手动构造权重矩阵W W W和偏移矩阵 b b b,利用矩阵乘法实现全连接层。

1.1 原理

tf.layers.dense( input, units=k )会在内部自动生成一个权矩阵:kernel 和偏移项:bias,
例如:

  • 对于尺寸为[m, n]的二维张量input, tf.layers.dense()会生成:尺寸为[n, k]的权矩阵:kernel,和尺寸为[m, k] 的偏移项:bias。内部的计算过程为y = input * kernel + bias,输出值y的维度为[m, k]。

tf.layers.dense()省略了下述过程(省略部分代码),拿简单神经网络手写数字识别案例举例

  • 每一张照片28 × 28 28\times28 2 8 ×2 8 像素, 即特征值为28 × 28 = 784 个 28\times28=784个2 8 ×2 8 =7 8 4 个
  • 假设我们有[None,]个样本。那么input:[None,784]
  • bias可以确定为一个 = [1,10]的数据。
  • 那么,kernel = [784, 10]的二维张量。

    mnist = input_data.read_data_sets("./data/mnist/input_data/", one_hot=True)

    with tf.compat.v1.variable_scope("data"):
        x = tf.compat.v1.placeholder(tf.compat.v1.float32, [None, 784])

        y_true = tf.compat.v1.placeholder(tf.compat.v1.int32, [None, 10])

    with tf.compat.v1.variable_scope("fc_model"):

        weight = tf.compat.v1.Variable(tf.compat.v1.random.normal([784, 10], mean=0.0, stddev=1.0), name="w")

        bias = tf.compat.v1.Variable(tf.compat.v1.constant(0.0, shape=[10]))

        y_predict = tf.compat.v1.matmul(x, weight) + bias

1.2 相关参数

tf.layers.dense(inputs, units, activation=None, use_bias=True, kernel_initializer=None,
                bias_initializer=tf.zeros_initializer(), kernel_regularizer=None, bias_regularizer=None,
                activity_regularizer=None, trainable=True, name=None, reuse=None
                )

  • inputs:tf.layers.dense 的Tensor输入。【样本数量,特征值】
  • units:神经元的个数,【输出空间的维数,改变inputs的最后一维】。【手写数字识别中 lable的个数为:10】
  • activation:激活函数,例如:relu函数。None:以默认为保持线性激活。
  • use_bias:Boolean,表示该层是否使用偏差。
  • kernel_initializer:权重矩阵的初始化函数;默认None,则使用tf.get_variable使用的默认初始化程序初始化权重。
  • bias_initializer:偏置的初始化函数。
  • kernel_regularizer:权重矩阵的正则化函数。
  • bias_regularizer:正规函数的偏差。
  • activity_regularizer:输出的正则化函数。
  • kernel_constraint:默认:None
  • bias_constraint:默认:None
  • trainable:Boolean,如果为True,还将变量添加到图集合GraphKeys.TRAINABLE_VARIABLES中(请参阅参考资料tf.Variable)。
  • name:String,图层的名称;具有相同名称的图层将共享权重,但为了避免错误,在这种情况下,我们需要reuse=True。
  • reuse:是否以同一名称重用前一层的权重。

1.3对比:


input = tf.compat.v1.reshape(tf.constant([[1., 2.], [2., 3.]]), shape=[4, 1])
b1 = tf.compat.v1.layers.dense(input,
                               units=2,
                               kernel_initializer=tf.constant_initializer(value=2),
                               bias_initializer=tf.constant_initializer(value=1))

kernel = tf.compat.v1.reshape(tf.constant([2., 2.]), shape=[1, 2])
bias = tf.compat.v1.reshape(tf.constant([1., 1., 1., 1., 1., 1., 1., 1.]), shape=[4, 2])
b2 = tf.compat.v1.add(tf.matmul(input, kernel), bias)

with tf.compat.v1.Session()as sess:
    sess.run(tf.compat.v1.global_variables_initializer())
    print(sess.run(b1))
    print(sess.run(b2))
输出:
[[3. 3.]
 [5. 5.]
 [5. 5.]
[7. 7.]]
[[3. 3.]
[5. 5.]
[5. 5.]
[7. 7.]]
inputs = tf.compat.v1.ones([4, 10])
inputs2 = tf.compat.v1.ones([3, 30])
a = tf.compat.v1.layers.dense(inputs, 6)
b = tf.compat.v1.layers.dense(inputs2, 7)
print(inputs)
print(inputs2)
print("*"*10)
print(a)
print(b)
输出:
Tensor("ones:0", shape=(4, 10), dtype=float32)
Tensor("ones_1:0", shape=(3, 30), dtype=float32)
**********
Tensor("dense/BiasAdd:0", shape=(4, 6), dtype=float32)
Tensor("dense_1/BiasAdd:0", shape=(3, 7), dtype=float32)

Original: https://blog.csdn.net/qq_40926887/article/details/123527963
Author: 捌椒
Title: Tensorflow学习之tf.layers.dense()

相关文章
即将步入大四,开始我最真情的告白 人工智能

即将步入大四,开始我最真情的告白

活动地址:毕业季·进击的技术er 1.目前是大几?学习的专业是?本专业让你Get到哪些新技能? 暑假结束就大四了,不知不觉大学生活已度过0.75。 本人网络工程专业 大一下学期加入机器人实验室,开始接...