Main Content

このページは機械翻訳を使用して翻訳されました。元の英語を参照するには、ここをクリックします。

Datafeed Toolboxを使用して現在の財務データを取得する

この例では、Federal Reserve Economic Data (FRED) に接続し、現在の金融データを取得する方法を説明します。

FRED への接続

fred関数を使用して、 <a href="https://research.stlouisfed.org/fred2/">https://research.stlouisfed.org/fred2/</a>にある FRED データ サーバーに接続します。

c = fred('https://research.stlouisfed.org/fred2/');

現在の財務データの取得

関数 fetch を使用して、S&P 500 シリーズの現在の金融データを取得します。

series = 'SP500';
d = fetch(c,series)
d = 

  struct with fields:

                 Title: ' S&P 500'
              SeriesID: ' SP500'
                Source: ' S&P Dow Jones Indices LLC'
               Release: ' Standard & Poors (Not a Press Release)'
    SeasonalAdjustment: ' Not Seasonally Adjusted'
             Frequency: ' Daily'
                 Units: ' Index'
             DateRange: ' 2009-01-12 to 2019-01-09'
           LastUpdated: ' 2019-01-09 7:10 PM CST'
                 Notes: ' The Federal Reserve Bank of St. Louis and S&P Dow Jones Indices LLC have reached a new agreement on the use of Standard & Poors and Dow Jones Averages series in FRED. FRED and its associated services will include 10 years of daily history for Standard & Poors and Dow Jones Averages series.  The S&P 500 is regarded as a gauge of the large cap U.S. equities market. The index includes 500 leading companies in leading industries of the U.S. economy, which are publicly held on either the NYSE or NASDAQ, and covers 75% of U.S. equities. Since this is a price index and not a total return index, the S&P 500 index here does not contain dividends.  Copyright © 2016, S&P Dow Jones Indices LLC. All rights reserved. Reproduction of S&P 500 in any form is prohibited except with the prior written permission of S&P Dow Jones Indices LLC (“S&P”). S&P does not guarantee the accuracy, adequacy, completeness or availability of any information and is not responsible for any errors or omissions, regardless of the cause or for the results obtained from the use of such information. S&P DISCLAIMS ANY AND ALL EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE. In no event shall S&P be liable for any direct, indirect, special or consequential damages, costs, expenses, legal fees, or losses (including lost income or lost profit and opportunity costs) in connection with subscriber’s or others’ use of S&P 500.  Permission to reproduce S&P 500 can be requested from index_services@spdji.com. More contact details are available from https://us.spindices.com/contact-us/ including phone numbers for all of its regional offices.'
                  Data: [2608×2 double]

日付と外国為替レートの数値表現を表示します。

d.Data(1:5,1:2)
ans =

   1.0e+05 *

    7.3379    0.0087
    7.3379    0.0087
    7.3379    0.0084
    7.3379    0.0084
    7.3379    0.0085

FRED 接続を閉じる

close(c);

ThingSpeak™にデータを送信する

thingSpeakWrite関数を使用して、最後の価格データをThingSpeakチャネルに送信します。データをチャネルに送信するには、channelIDwriteAPIKeyを変更します。

channelID=17504;
writeAPIKey='23ZLGOBBU9TWHG2H';
thingSpeakWrite(channelID,d.Data(end, 2),'WriteKey',writeAPIKey);

参考

関数

外部の Web サイト