股票在某时间段上涨跌幅及年募化进款的函数

发布时间:2019-09-29 05:50 编辑: 点击:

空间日志 — 股票在某时间段上涨跌幅及年募化进款的函数


  原文:https://www.joinquant.com/community/post/detailMobile?postId=15438&page=&limit=20&replyId=&tag=

  上涨跌幅函数为rangeChange(stockSymbol, startDate, endDate)

  年募化进款函数为annualizedReturn(stockSymbol, startDate, endDate)

  from jqdatasdk import *

  import pandas as pd

  from datetime import datetime, timedelta # 带入datetime模块

  auth(‘username’,‘code’) #输入用户名稠密码

  def rangeChange(stockSymbol, startDate, endDate):

  #前往区间内股票的进款比值

  def annualizedReturn(stockSymbol, startDate, endDate):

  performance=rangeChange(stockSymbol, startDate, endDate)

  startDateF=datetime.strptime(startDate, “%Y-%m-%d”)

  endDateF=datetime.strptime(endDate, “%Y-%m-%d”)

  calDays=(endDateF-startDateF).days

  annualReturn=(1+performance)**(1/(calDays/365))-1

  return annualReturn

  #############

  #用户输入

  startDate=“2015-01-01”#输入初始日

  endDate=“2018-02-01” #输入届期日

  stockSymbol=‘000001.XSHE’ #输入股票代码

  ##############

  performance=rangeChange(stockSymbol, startDate, endDate)

  print(performance)

  annualReturn=annualizedReturn(stockSymbol, startDate, endDate)

  print(annualReturn)

  原文: https://www.joinquant.com/community/post/detailMobile?postId=15438&page=&limit=20&replyId=&tag=

    送鲜花
    (0)
    0%
    打酱油
    (0)
    0%