Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the api Interface of Financial data acquisition

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to achieve financial data acquisition of the api interface, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

Apple's share price has been soaring recently, reaching an intraday high on Friday and closing at a new high on mass entrepreneurship and innovation, after breaking through the trillion-dollar market capitalization on Thursday. The intraday high was $208.74, and the closing price was $207.99, up 0.29%, a record closing high with a market capitalization of $1.004576 trillion.

In the GGP ranking of the global economy, it has been steadily ranked in the top 20, and the real wealth is comparable to that of other countries.

In order to see the changes of Apple's stock price since its listing, we specially studied the financial data interface packages in R and Python. Although the tushare database in Python comprehensively contains the data of domestic Shanghai and Shenzhen stock markets, Hong Kong stocks and American stocks do not support it. Later, Apple's stock price data were obtained using an extension library in pandas. (pandas_datareader)

Import pandas_datareader.data as web

Import datetime

Import matplotlib.pyplot as plt

From matplotlib.pylab import date2num

From matplotlib.font_manager

Import FontProperties

Import mpl_finance as mpf

Import matplotlib

Import numpy as npmatplotlib.style.use ('ggplot')% matplotlib inline defines the time period for getting data start = datetime.datetime (1980, 1) end = datetime.datetime (2018 AAPL',start, end) prices = web.get_data_yahoo (' AAPL',start, end) # Preview stock price trend chart

Prices ['Close'] .plot () plt.show ()

Create stock price K chart def create_candles (data): fig Ax = plt.subplots (figsize= (162.10)) fig.subplots_adjust (bottom=0.2) ax.xaxis_date () plt.xticks (rotation=45) plt.yticks [) plt.rcParams ['font.sans-serif'] = [' SimHei'] plt.title ("stock symbol: APPL historical stock price") plt.xlabel ("time") plt.ylabel ("stock price (yuan)") mpf.candlestick_ohlc (ax,data,width=1.5) Colorup='r',colordown='green') plt.grid (True) execute drawing code if _ _ name__ = ='_ main__': prices = prices.reset_index () prices ['Date'] = prices [' Date'] .map (lambda x: date2num (x)) data = prices.iloc [:,: 5] .values create_candles (data)

Apple shares have been listed since December 12, 1980, with a share price of $22 per share on the day of listing. The latest share price is 207.99 (2018-08-03). The stock price has increased by about 57,403% since the date of listing (after several share splits during the period).

Tushare package is a very excellent financial information data interface package, although the method to cover Hong Kong stocks and US stocks, but for the domestic Shanghai and Shenzhen stock market data support is very perfect.

Ts.get_k_data ('000001 transactions, index=True) # transaction data:

Ts.get_hist_data ('600848') # get all daily k-line data at once

Ts.get_h_data () # get historical restoration data

Ts.get_today_all () # Real-time quotes

Df = ts.get_tick_data ('600848 dating dates 2014-01-09') # History transactions

In addition, the tushare package is well supported for large transactions, dragon and tiger lists, margin trading, macroeconomic data, as well as data related to various indices and money markets.

For more information, please refer to http://tushare.org/index.html.

Naturally, the interface in R language that supports financial data acquisition is the quantmood package.

Library ("quantmod")

# the api of yahoo Finance is barely available, and the api of google Finance has been discontinued.

# specify the name or code of the stock to be obtained, and the data source

SetSymbolLookup (JJKR=list (name= "AAPL", src= "yahoo")) getSymbols ("AAPL") chartSeries (AAPL,subset= "1980-2 theme=chartTheme (white"), TA= "addVo (); addBBands (); addATR (); addCMF ()")

Quantmood package provides a very complete stock price analysis function and other financial, dividend and a variety of technical analysis index data, is a very good securities analysis tool.

The above is all the contents of the article "how to achieve the api interface for financial data acquisition". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report