欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python的凈值數(shù)據(jù)接口調(diào)用示例分享

 更新時(shí)間:2016年03月15日 11:25:20   投稿:hebedich  
這篇文章主要介紹了Python的凈值數(shù)據(jù)接口調(diào)用示例分享的相關(guān)資料,需要的朋友可以參考下

代碼描述:基于Python的凈值數(shù)據(jù)接口調(diào)用代碼實(shí)例
關(guān)聯(lián)數(shù)據(jù):凈值數(shù)據(jù)
接口地址:https://www.juhe.cn/docs/api/id/25

#!/usr/bin/python
# -*- coding: utf-8 -*-
import json, urllib
from urllib import urlencode

#----------------------------------
# 凈值數(shù)據(jù)調(diào)用示例代碼 - 聚合數(shù)據(jù)
# 在線接口文檔:http://www.juhe.cn/docs/25
#----------------------------------

def main():

  #配置您申請(qǐng)的APPKey
  appkey = "*********************"

  #1.全部開放基金
  request1(appkey,"GET")

  #2.股票型基金
  request2(appkey,"GET")

  #3.普通債券型基金
  request3(appkey,"GET")

  #4.貨幣型基金
  request4(appkey,"GET")

  #5.封閉型基金
  request5(appkey,"GET")
 
  #6.創(chuàng)新封基
  request6(appkey,"GET")

  #7.LOF
  request7(appkey,"GET")

  #8.ETF
  request8(appkey,"GET")

  #9.QDII
  request9(appkey,"GET")

#全部開放基金
def request1(appkey, m="GET"):
  url = "http://web.juhe.cn:8080/fund/netdata/all"
  params = {
    "key" : appkey, #APPKEY值

  }
  params = urlencode(params)
  if m =="GET":
    f = urllib.urlopen("%s?%s" % (url, params))
  else:
    f = urllib.urlopen(url, params)
 
  content = f.read()
  res = json.loads(content)
  if res:
    error_code = res["error_code"]
    if error_code == 0:
      #成功請(qǐng)求
      print res["result"]
    else:
      print "%s:%s" % (res["error_code"],res["reason"])
  else:
    print "request api error"
 
#股票型基金
def request2(appkey, m="GET"):
  url = "http://web.juhe.cn:8080/fund/netdata/stock"
  params = {
    "key" : appkey, #APPKEY值
 
  }
  params = urlencode(params)
  if m =="GET":
    f = urllib.urlopen("%s?%s" % (url, params))
  else:
    f = urllib.urlopen(url, params)
 
  content = f.read()
  res = json.loads(content)
  if res:
    error_code = res["error_code"]
    if error_code == 0:
      #成功請(qǐng)求
      print res["result"]
    else:
      print "%s:%s" % (res["error_code"],res["reason"])
  else:
    print "request api error"
 
#普通債券型基金
def request3(appkey, m="GET"):
  url = "http://web.juhe.cn:8080/fund/netdata/bond"
  params = {
    "key" : appkey, #APPKEY值
 
  }
  params = urlencode(params)
  if m =="GET":
    f = urllib.urlopen("%s?%s" % (url, params))
  else:
    f = urllib.urlopen(url, params)
 
  content = f.read()
  res = json.loads(content)
  if res:
    error_code = res["error_code"]
    if error_code == 0:
      #成功請(qǐng)求
      print res["result"]
    else:
      print "%s:%s" % (res["error_code"],res["reason"])
  else:
    print "request api error"
 
#貨幣型基金
def request4(appkey, m="GET"):
  url = "http://web.juhe.cn:8080/fund/netdata/monet"
  params = {
    "key" : appkey, #APPKEY值
 
  }
  params = urlencode(params)
  if m =="GET":
    f = urllib.urlopen("%s?%s" % (url, params))
  else:
    f = urllib.urlopen(url, params)
 
  content = f.read()
  res = json.loads(content)
  if res:
    error_code = res["error_code"]
    if error_code == 0:
      #成功請(qǐng)求
      print res["result"]
    else:
      print "%s:%s" % (res["error_code"],res["reason"])
  else:
    print "request api error"
 
#封閉型基金
def request5(appkey, m="GET"):
  url = "http://web.juhe.cn:8080/fund/netdata/close"
  params = {
    "key" : appkey, #APPKEY值
 
  }
  params = urlencode(params)
  if m =="GET":
    f = urllib.urlopen("%s?%s" % (url, params))
  else:
    f = urllib.urlopen(url, params)
 
  content = f.read()
  res = json.loads(content)
  if res:
    error_code = res["error_code"]
    if error_code == 0:
      #成功請(qǐng)求
      print res["result"]
    else:
      print "%s:%s" % (res["error_code"],res["reason"])
  else:
    print "request api error"
 
#創(chuàng)新封基
def request6(appkey, m="GET"):
  url = "http://web.juhe.cn:8080/fund/netdata/innov"
  params = {
    "key" : appkey, #APPKEY值
 
  }
  params = urlencode(params)
  if m =="GET":
    f = urllib.urlopen("%s?%s" % (url, params))
  else:
    f = urllib.urlopen(url, params)
 
  content = f.read()
  res = json.loads(content)
  if res:
    error_code = res["error_code"]
    if error_code == 0:
      #成功請(qǐng)求
      print res["result"]
    else:
      print "%s:%s" % (res["error_code"],res["reason"])
  else:
    print "request api error"
 
#LOF
def request7(appkey, m="GET"):
  url = "http://web.juhe.cn:8080/fund/netdata/lof"
  params = {
    "key" : appkey, #APPKEY值
 
  }
  params = urlencode(params)
  if m =="GET":
    f = urllib.urlopen("%s?%s" % (url, params))
  else:
    f = urllib.urlopen(url, params)
 
  content = f.read()
  res = json.loads(content)
  if res:
    error_code = res["error_code"]
    if error_code == 0:
      #成功請(qǐng)求
      print res["result"]
    else:
      print "%s:%s" % (res["error_code"],res["reason"])
  else:
    print "request api error"
 
#ETF
def request8(appkey, m="GET"):
  url = "http://web.juhe.cn:8080/fund/netdata/etf"
  params = {
    "key" : appkey, #APPKEY值
 
  }
  params = urlencode(params)
  if m =="GET":
    f = urllib.urlopen("%s?%s" % (url, params))
  else:
    f = urllib.urlopen(url, params)
 
  content = f.read()
  res = json.loads(content)
  if res:
    error_code = res["error_code"]
    if error_code == 0:
      #成功請(qǐng)求
      print res["result"]
    else:
      print "%s:%s" % (res["error_code"],res["reason"])
  else:
    print "request api error"
 
#QDII
def request9(appkey, m="GET"):
  url = "http://web.juhe.cn:8080/fund/netdata/qdii"
  params = {
    "key" : appkey, #APPKEY值
 
  }
  params = urlencode(params)
  if m =="GET":
    f = urllib.urlopen("%s?%s" % (url, params))
  else:
    f = urllib.urlopen(url, params)
 
  content = f.read()
  res = json.loads(content)
  if res:
    error_code = res["error_code"]
    if error_code == 0:
      #成功請(qǐng)求
      print res["result"]
    else:
      print "%s:%s" % (res["error_code"],res["reason"])
  else:
    print "request api error"

if __name__ == '__main__':
  main()

相關(guān)文章

  • Python Matplotlib繪制箱型圖(箱線圖)boxplot的方法詳解

    Python Matplotlib繪制箱型圖(箱線圖)boxplot的方法詳解

    箱線圖(箱型圖)主要作用是發(fā)現(xiàn)數(shù)據(jù)內(nèi)部整體的分布分散情況,包括上下限、各分位數(shù)、異常值等,本文為大家整理了Matplotlib繪制箱型圖的所以方法,希望對(duì)大家有所幫助
    2023-05-05
  • python爬蟲之自動(dòng)登錄與驗(yàn)證碼識(shí)別

    python爬蟲之自動(dòng)登錄與驗(yàn)證碼識(shí)別

    這篇文章主要為大家詳細(xì)介紹了python爬蟲之自動(dòng)登錄與驗(yàn)證碼識(shí)別,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-09-09
  • python深度學(xué)習(xí)tensorflow1.0參數(shù)初始化initializer

    python深度學(xué)習(xí)tensorflow1.0參數(shù)初始化initializer

    這篇文章主要為大家介紹了python深度學(xué)習(xí)tensorflow1.0參數(shù)初始化initializer示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-06-06
  • 對(duì)pycharm代碼整體左移和右移縮進(jìn)快捷鍵的介紹

    對(duì)pycharm代碼整體左移和右移縮進(jìn)快捷鍵的介紹

    今天小編就為大家分享一篇對(duì)pycharm代碼整體左移和右移縮進(jìn)快捷鍵的介紹,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-07-07
  • pandas 使用merge實(shí)現(xiàn)百倍加速的操作

    pandas 使用merge實(shí)現(xiàn)百倍加速的操作

    這篇文章主要介紹了pandas 使用merge實(shí)現(xiàn)百倍加速的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2021-04-04
  • Python抖音無水印視頻下載方法

    Python抖音無水印視頻下載方法

    這篇文章主要介紹了用Python下載抖音無水印視頻的方法,本文通過圖文實(shí)例代碼相結(jié)合給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-12-12
  • Python標(biāo)準(zhǔn)庫之?dāng)?shù)據(jù)庫 sqlite3

    Python標(biāo)準(zhǔn)庫之?dāng)?shù)據(jù)庫 sqlite3

    這篇文章主要介紹了Python標(biāo)準(zhǔn)庫的數(shù)據(jù)庫 sqlite3的相關(guān)資料,SQLite是一個(gè)輕量級(jí)、跨平臺(tái)的關(guān)系型數(shù)據(jù)庫。它的核心引擎本身不依賴第三方的軟件,使用它也不需要“安裝”。下面文字將對(duì)其簡單介紹,需要的小伙伴可以參考下面文章內(nèi)容
    2021-09-09
  • Python 快速實(shí)現(xiàn)CLI 應(yīng)用程序的腳手架

    Python 快速實(shí)現(xiàn)CLI 應(yīng)用程序的腳手架

    本篇文章主要介紹了Python 快速實(shí)現(xiàn)CLI 應(yīng)用程序的腳手架,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-12-12
  • python游戲?qū)崙?zhàn)項(xiàng)目之智能五子棋

    python游戲?qū)崙?zhàn)項(xiàng)目之智能五子棋

    下五子棋嗎?信不信我讓你幾步你也贏不了?本篇為你帶來用python編寫的五子棋小游戲,文中給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值
    2021-09-09
  • python用plotly實(shí)現(xiàn)繪制局部放大圖

    python用plotly實(shí)現(xiàn)繪制局部放大圖

    大家好,本篇文章主要講的是python用plotly實(shí)現(xiàn)繪制局部放大圖,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下
    2022-02-02

最新評(píng)論