亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Python的凈值數據接口調用示例分享

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

代碼描述:基于Python的凈值數據接口調用代碼實例
關聯數據:凈值數據
接口地址:https://www.juhe.cn/docs/api/id/25

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

#----------------------------------
# 凈值數據調用示例代碼 - 聚合數據
# 在線接口文檔:http://www.juhe.cn/docs/25
#----------------------------------

def main():

  #配置您申請的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:
      #成功請求
      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:
      #成功請求
      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:
      #成功請求
      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:
      #成功請求
      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:
      #成功請求
      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:
      #成功請求
      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:
      #成功請求
      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:
      #成功請求
      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:
      #成功請求
      print res["result"]
    else:
      print "%s:%s" % (res["error_code"],res["reason"])
  else:
    print "request api error"

if __name__ == '__main__':
  main()

相關文章

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

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

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

    python爬蟲之自動登錄與驗證碼識別

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

    python深度學習tensorflow1.0參數初始化initializer

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

    對pycharm代碼整體左移和右移縮進快捷鍵的介紹

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

    pandas 使用merge實現百倍加速的操作

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

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

    這篇文章主要介紹了用Python下載抖音無水印視頻的方法,本文通過圖文實例代碼相結合給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-12-12
  • Python標準庫之數據庫 sqlite3

    Python標準庫之數據庫 sqlite3

    這篇文章主要介紹了Python標準庫的數據庫 sqlite3的相關資料,SQLite是一個輕量級、跨平臺的關系型數據庫。它的核心引擎本身不依賴第三方的軟件,使用它也不需要“安裝”。下面文字將對其簡單介紹,需要的小伙伴可以參考下面文章內容
    2021-09-09
  • Python 快速實現CLI 應用程序的腳手架

    Python 快速實現CLI 應用程序的腳手架

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

    python游戲實戰(zhàn)項目之智能五子棋

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

    python用plotly實現繪制局部放大圖

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

最新評論