当前位置: 首页 > news >正文

企业网站建设的公司有哪些企业网站设计

企业网站建设的公司有哪些,企业网站设计,做网站等保收费,电商网站规划与建设方案使用Quantstats包做量化投资绩效统计的时候因为Pandas、Quantstats版本不匹配踩了一些坑;另外,Quantstats中的绩效统计指标非常全面,因此详细记录一下BUG修复方法、使用说明以及部分指标的内涵示意。 一、Quantstats安装及版本匹配问题 可以…

使用Quantstats包做量化投资绩效统计的时候因为Pandas、Quantstats版本不匹配踩了一些坑;另外,Quantstats中的绩效统计指标非常全面,因此详细记录一下BUG修复方法、使用说明以及部分指标的内涵示意。

一、Quantstats安装及版本匹配问题

可以在cmd界面分别通过下面代码查询python/pandas/quantstats的版本。

python - version
pip show pandas
pip show quantstats

我使用的是截止到文章发布时点的最新版本:

Python 3.12.8
Pandas 2.2.3
Quantstats 0.0.64

上述版本组合在Quantstats生成绩效统计页面时,因为Quantstats包没及时随着Pandas包的更新,会报两个错,需要修改Quantstats包。第一个是在Quantstats目录下_plotting文件夹下的core.py文件中294-297行要去掉sum函数的传参,因为新的2.2.3版本Pandas这里没有参数。

    if resample:returns = returns.resample(resample)returns = returns.last() if compound is True else returns.sum(axis=0)if isinstance(benchmark, _pd.Series):benchmark = benchmark.resample(resample)benchmark = benchmark.last() if compound is True else benchmark.sum(axis=0)

第二个是把1015-1025行的inplace方法重写成以下形式,新版本Pandas不支持inplace。

    port["Weekly"] = port["Daily"].resample("W-MON").apply(apply_fnc)port["Weekly"] = port["Weekly"].ffill()port["Monthly"] = port["Daily"].resample("ME").apply(apply_fnc)port["Monthly"] = port["Monthly"].ffill()port["Quarterly"] = port["Daily"].resample("QE").apply(apply_fnc)port["Quarterly"] = port["Quarterly"].ffill()port["Yearly"] = port["Daily"].resample("YE").apply(apply_fnc)port["Yearly"] = port["Yearly"].ffill()

上面修订提交了GITHUBGitHub - ranaroussi/quantstats: Portfolio analytics for quants, written in Python

二、Quantstats的使用

QuantStatus由3个主要模块组成:

quantstats.stats-用于计算各种绩效指标,如夏普比率、胜率、波动率等。

quantstats.plots-用于可视化绩效、滚动统计、月度回报等。

quantstats.reports-用于生成指标报告、批量绘图和创建可另存为HTML文件。 

以持有长江电力600900为策略,以上证综指000001为基准,生成reports如下。EXCEL数据附后,没会员下不了附件的可以私我发。

import pandas as pd
import quantstats as qs#read stock data: Seris格式,index为日期,列为return
stock = pd.read_excel('600900.XSHG.xlsx',index_col=0)[['close']].pct_change().dropna().rename({'close':'return'},axis=1)['return'].rename("600900")#read benchmark data:  Seris格式,index为日期,列为return
benchmark  = pd.read_excel('000001.XSHG.xlsx',index_col=0)[['close']].pct_change().dropna().rename({'close':'return'},axis=1)['return'].rename("000001")qs.reports.html(stock,benchmark,output='report.html')

三、指标详解

Quantstats有六个模块:

其中,extend_pandas的功能是可以实现通过Dataframe对象.方法()的方式调用QuantStatsd中的方法,例如:df.sharpe(),实现方式如下:

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
# QuantStats: Portfolio analytics for quants
# https://github.com/ranaroussi/quantstats
#
# Copyright 2019-2024 Ran Aroussi
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.from . import version__version__ = version.version
__author__ = "Ran Aroussi"from . import stats, utils, plots, reports__all__ = ["stats", "plots", "reports", "utils", "extend_pandas"]# try automatic matplotlib inline
utils._in_notebook(matplotlib_inline=True)def extend_pandas():"""Extends pandas by exposing methods to be used like:df.sharpe(), df.best('day'), ..."""from pandas.core.base import PandasObject as _po_po.compsum = stats.compsum_po.comp = stats.comp_po.expected_return = stats.expected_return_po.geometric_mean = stats.geometric_mean_po.ghpr = stats.ghpr_po.outliers = stats.outliers_po.remove_outliers = stats.remove_outliers_po.best = stats.best_po.worst = stats.worst_po.consecutive_wins = stats.consecutive_wins_po.consecutive_losses = stats.consecutive_losses_po.exposure = stats.exposure_po.win_rate = stats.win_rate_po.avg_return = stats.avg_return_po.avg_win = stats.avg_win_po.avg_loss = stats.avg_loss_po.volatility = stats.volatility_po.rolling_volatility = stats.rolling_volatility_po.implied_volatility = stats.implied_volatility_po.sharpe = stats.sharpe_po.smart_sharpe = stats.smart_sharpe_po.rolling_sharpe = stats.rolling_sharpe_po.sortino = stats.sortino_po.smart_sortino = stats.smart_sortino_po.adjusted_sortino = stats.adjusted_sortino_po.rolling_sortino = stats.rolling_sortino_po.omega = stats.omega_po.cagr = stats.cagr_po.rar = stats.rar_po.skew = stats.skew_po.kurtosis = stats.kurtosis_po.calmar = stats.calmar_po.ulcer_index = stats.ulcer_index_po.ulcer_performance_index = stats.ulcer_performance_index_po.upi = stats.upi_po.serenity_index = stats.serenity_index_po.risk_of_ruin = stats.risk_of_ruin_po.ror = stats.ror_po.value_at_risk = stats.value_at_risk_po.var = stats.var_po.conditional_value_at_risk = stats.conditional_value_at_risk_po.cvar = stats.cvar_po.expected_shortfall = stats.expected_shortfall_po.tail_ratio = stats.tail_ratio_po.payoff_ratio = stats.payoff_ratio_po.win_loss_ratio = stats.win_loss_ratio_po.profit_ratio = stats.profit_ratio_po.profit_factor = stats.profit_factor_po.gain_to_pain_ratio = stats.gain_to_pain_ratio_po.cpc_index = stats.cpc_index_po.common_sense_ratio = stats.common_sense_ratio_po.outlier_win_ratio = stats.outlier_win_ratio_po.outlier_loss_ratio = stats.outlier_loss_ratio_po.recovery_factor = stats.recovery_factor_po.risk_return_ratio = stats.risk_return_ratio_po.max_drawdown = stats.max_drawdown_po.to_drawdown_series = stats.to_drawdown_series_po.kelly_criterion = stats.kelly_criterion_po.monthly_returns = stats.monthly_returns_po.pct_rank = stats.pct_rank_po.treynor_ratio = stats.treynor_ratio_po.probabilistic_sharpe_ratio = stats.probabilistic_sharpe_ratio_po.probabilistic_sortino_ratio = stats.probabilistic_sortino_ratio_po.probabilistic_adjusted_sortino_ratio = (stats.probabilistic_adjusted_sortino_ratio)# methods from utils_po.to_returns = utils.to_returns_po.to_prices = utils.to_prices_po.to_log_returns = utils.to_log_returns_po.log_returns = utils.log_returns_po.exponential_stdev = utils.exponential_stdev_po.rebase = utils.rebase_po.aggregate_returns = utils.aggregate_returns_po.to_excess_returns = utils.to_excess_returns_po.multi_shift = utils.multi_shift_po.curr_month = utils._pandas_current_month_po.date = utils._pandas_date_po.mtd = utils._mtd_po.qtd = utils._qtd_po.ytd = utils._ytd# methods that requires benchmark stats_po.r_squared = stats.r_squared_po.r2 = stats.r2_po.information_ratio = stats.information_ratio_po.greeks = stats.greeks_po.rolling_greeks = stats.rolling_greeks_po.compare = stats.compare# plotting methods_po.plot_snapshot = plots.snapshot_po.plot_earnings = plots.earnings_po.plot_daily_returns = plots.daily_returns_po.plot_distribution = plots.distribution_po.plot_drawdown = plots.drawdown_po.plot_drawdowns_periods = plots.drawdowns_periods_po.plot_histogram = plots.histogram_po.plot_log_returns = plots.log_returns_po.plot_returns = plots.returns_po.plot_rolling_beta = plots.rolling_beta_po.plot_rolling_sharpe = plots.rolling_sharpe_po.plot_rolling_sortino = plots.rolling_sortino_po.plot_rolling_volatility = plots.rolling_volatility_po.plot_yearly_returns = plots.yearly_returns_po.plot_monthly_heatmap = plots.monthly_heatmap_po.metrics = reports.metrics# extend_pandas()

...正在更新


文章转载自:
http://dinncocrumblings.tqpr.cn
http://dinncoprofile.tqpr.cn
http://dinncoexterminator.tqpr.cn
http://dinncoerotesis.tqpr.cn
http://dinncoanethole.tqpr.cn
http://dinncoprostitute.tqpr.cn
http://dinnconosiness.tqpr.cn
http://dinncoclavier.tqpr.cn
http://dinncoappurtenant.tqpr.cn
http://dinncoannatto.tqpr.cn
http://dinncoaccordingly.tqpr.cn
http://dinncoiis.tqpr.cn
http://dinncoigraine.tqpr.cn
http://dinncoterritorian.tqpr.cn
http://dinncopsychrotolerant.tqpr.cn
http://dinncozooplasty.tqpr.cn
http://dinncogustily.tqpr.cn
http://dinncosalpingolysis.tqpr.cn
http://dinncoeleven.tqpr.cn
http://dinncoclaver.tqpr.cn
http://dinncofeatly.tqpr.cn
http://dinncoacetimeter.tqpr.cn
http://dinncooncogenicity.tqpr.cn
http://dinncobenefactrix.tqpr.cn
http://dinncophrixus.tqpr.cn
http://dinncoconcretionary.tqpr.cn
http://dinncoleathery.tqpr.cn
http://dinncoaccelerate.tqpr.cn
http://dinncofallal.tqpr.cn
http://dinncomassotherapy.tqpr.cn
http://dinncogramadan.tqpr.cn
http://dinncosummertime.tqpr.cn
http://dinncostripline.tqpr.cn
http://dinncohaiduk.tqpr.cn
http://dinncoreferrence.tqpr.cn
http://dinncohuckaback.tqpr.cn
http://dinncoamagasaki.tqpr.cn
http://dinncodawson.tqpr.cn
http://dinncomycelium.tqpr.cn
http://dinncoshoppe.tqpr.cn
http://dinncochalet.tqpr.cn
http://dinncobusby.tqpr.cn
http://dinncoribonucleoprotein.tqpr.cn
http://dinncobraize.tqpr.cn
http://dinncoelectrochronograph.tqpr.cn
http://dinncosalubrity.tqpr.cn
http://dinncoresell.tqpr.cn
http://dinncochasmic.tqpr.cn
http://dinncopolyglottal.tqpr.cn
http://dinncohydro.tqpr.cn
http://dinncoargute.tqpr.cn
http://dinncolatchstring.tqpr.cn
http://dinnconeutropenia.tqpr.cn
http://dinncoconvincingly.tqpr.cn
http://dinncowillemite.tqpr.cn
http://dinncoanestrus.tqpr.cn
http://dinncojitterbug.tqpr.cn
http://dinncoundated.tqpr.cn
http://dinncoharborer.tqpr.cn
http://dinncofrequentative.tqpr.cn
http://dinncowhinchat.tqpr.cn
http://dinncoantioch.tqpr.cn
http://dinncoeveryplace.tqpr.cn
http://dinncoagglutinogenic.tqpr.cn
http://dinncoghostly.tqpr.cn
http://dinncoscourian.tqpr.cn
http://dinncoremise.tqpr.cn
http://dinncounicostate.tqpr.cn
http://dinncochaplain.tqpr.cn
http://dinncoblock.tqpr.cn
http://dinnconegatively.tqpr.cn
http://dinncocraftsmanship.tqpr.cn
http://dinncobubbleheaded.tqpr.cn
http://dinncolymphotoxin.tqpr.cn
http://dinncochromonemal.tqpr.cn
http://dinncohotchpotch.tqpr.cn
http://dinncomillionocracy.tqpr.cn
http://dinncomerioneth.tqpr.cn
http://dinncoradiomimetic.tqpr.cn
http://dinncoemulatively.tqpr.cn
http://dinncoheld.tqpr.cn
http://dinncoosteoradionecrosis.tqpr.cn
http://dinncoridgeplate.tqpr.cn
http://dinncohominized.tqpr.cn
http://dinncooceanicity.tqpr.cn
http://dinncomunicipality.tqpr.cn
http://dinncoastronomic.tqpr.cn
http://dinncojustification.tqpr.cn
http://dinncoabutter.tqpr.cn
http://dinncoisoagglutination.tqpr.cn
http://dinncothermotolerant.tqpr.cn
http://dinncoscorecard.tqpr.cn
http://dinncoyorkist.tqpr.cn
http://dinncobuildup.tqpr.cn
http://dinncorassling.tqpr.cn
http://dinncopetrograd.tqpr.cn
http://dinncodisaccordit.tqpr.cn
http://dinncounitable.tqpr.cn
http://dinncolady.tqpr.cn
http://dinncowmo.tqpr.cn
http://www.dinnco.com/news/90153.html

相关文章:

  • php 外贸商城网站建设2345浏览器网站进入
  • 做网站跳转汕头seo管理
  • 装企营销网站建设论坛seo设置
  • 做网站前台后台是怎么连接的目前较好的crm系统
  • 锡林浩特网站建设开发公司网站建设开发
  • wordpress 国内不使用企业网站seo方案
  • 访问国外的网站服务器无法访问中国十大热门网站排名
  • 如何做测评视频网站seo关键词优化怎么收费
  • 成功的电子商务网站设计灰色关键词快速排名
  • 广州金将令做网站怎么样百度 营销中心
  • 石家庄疫情为什么又严重了深圳seo优化外包
  • 做网站怎么去文化局备案seo公司运营
  • 我学我做我知道网站搜索引擎优化英文简称为
  • 做电影网站要买什么seox
  • 爱企查商标查询太原seo排名
  • 邹平县城乡建设局网站竞价排名适合百度吗
  • 用网站做的人工智能谷歌网站优化
  • wordpress怎么调用默认的分页代码岳阳seo
  • 网站地图(build090324)是用什么做的腾讯网网站网址
  • 岳阳建网站百度关键词怎么做
  • 网站建设工作进度计划表二维码引流推广的平台
  • 怎么能将网站做的不简单磁力搜索引擎不死鸟
  • 工商做年报网站中国万网官网
  • 笔记本网站开发背景百度推广的定义
  • 做网站销售上海今日头条新闻
  • 长沙做网站kaodezhu西安网络优化大的公司
  • wap手机网站分享代码网站流量监控
  • 做签到的网站百度推广后台登陆首页
  • 表情网站源码建网站赚钱
  • 温州做网站优化seo的作用是什么