【Claude Investor】使い方を徹底解説!AIが株式銘柄を自動でピックアップ

みなさんは株で勝ちたいと思ったことはありますか。

2024年3月には日経平均が最高値を突破したり、アメリカのS&P500やNASDAQなども高値圏を維持しています。

そんな株価が上昇している今日ですが、つい私欲がでてしまい買うべき時に買えなかったり、売るべき時に売れなかったりすることがありますよね。

人間であれば誰もが持つ悩みです。

しかし、そんな悩みを消し去ってくれるようなAI(人工知能)のツールが誕生しました。

その名も「Claude Investor」です。(読み方は「クロード・インベスター」です。)

Claude Investorとは、GPT-4を超えた性能を持つAI「Claude」を活用した投資サポートツールです。

ユーザーが特定の業界を1つ入力すると、その業界から有名な銘柄を5つ選んでくれます。そして、最新のヤフーファイナンスの情報をもとに、各々の銘柄のターゲットプライスや投資リスクを教えてくれます。

Claude Investorは、数々のAIスタートアップを立ち上げたCEO マット・シュマー氏によって開発されました。

下の画像は、シュマー氏がツールを公開した時のXの投稿です。公開からわずか3日で50万インプレッションと2790いいねを集めており、X民からの期待が大きいことがわかります。

(引用元:Matt Shumer氏Xアカウント

それでは、Claude Investorの使い方と実際のどんなアメリカの株式銘柄をおすすめしてくれるのか見ていきましょう!

<Claude Investorの使い方の手順>

Claude Investorはプログラミングをしたことがない人でも使うことができるツールです。

今回は誰でも使い方・やり方がわかるように解説していきます!

大まかな手順としては以下の通りです。


Claude Investor 使い方手順

① Claude APIキーを公式サイトで取得する。

② Google コラボを開く。

③ Google コラボで「必要な文章」と「APIキー」をコピー&ペーストする。

④ Claude Investorが株式銘柄を選別する。


それでは、順番に見ていきましょう!

① Claude APIキーを公式サイトで取得する。

まず、Claude Investorを使うのに絶対に必要になるのがClaudeの「APIキー」です。

APIキーをまだ取得されていない方は下のURLからAPI取得方法をわかりやすく解説しているのでご覧ください。

3分でできる!「Claude APIキー」取得のやり方をわかりやすく解説

APIキーを取得したあとは、とても簡単です!

② Googleコラボを開く。

下のURLからGoogleコラボにアクセスします。

Googleコラボ

Googleコラボとは誰でもオンラインでPythonが使えるサイトです。もしGoogleでログインされていない方はログインしてください。無料で使えます!

すると下のような画面が表れるので、左下の青いボタン「ノートブックを新規作成」をクリックします。

(画像:Google Colabの使用画面より引用)

ノートブックの新規作成後は、下のような画面が出ます。(右側にたくさん文字があって、威圧的ですが関係ないので無視して構いません!)

(画像:Google Colabの使用画面より引用)

③ Google コラボで「必要な文章」と「APIキー」をコピー&ペーストする。

あとは、「コーディングを開始するか、AIで生成します。」というところに下の文章をコピー&ペーストするだけです。


\!pip install yfinance requests beautifulsoup4

文章がコピペできたら、左側にある▶ボタンをクリックします。すると必要なパッケージをダウンロードしてくれます。

下のような画面になってたらオッケーです🙆‍♀

(画像:Google Colabの使用画面より引用)

次に左上に「+コード」というボタンがあるのでそちらを押します。すると、コピペができる欄がまた表れます。

そしたら、先ほど取得したご自身のAPIキーを↓の”カッコ”の中に代入して、▶ボタンを押してください。


ANTHROPIC\_API\_KEY = "あなたのAPIキー"

この時点ではまだ何も起きません。「+コード」ボタンを押したら、最後に長い文章をコピペしましょう!本当に長いのでびっくりするかもしれませんが、このステップで最後です。

import yfinance as yf
from datetime import datetime, timedelta
import requests
from bs4 import BeautifulSoup
import ast
import json
 
 
def get_article_text(url):
    try:
        response = requests.get(url)
        soup = BeautifulSoup(response.content, 'html.parser')
        article_text = ' '.join([p.get_text() for p in soup.find_all('p')])
        return article_text
    except:
        return "Error retrieving article text."
 
def get_stock_data(ticker, years):
    end_date = datetime.now().date()
    start_date = end_date - timedelta(days=years*365)
 
    stock = yf.Ticker(ticker)
 
    # Retrieve historical price data
    hist_data = stock.history(start=start_date, end=end_date)
 
    # Retrieve balance sheet
    balance_sheet = stock.balance_sheet
 
    # Retrieve financial statements
    financials = stock.financials
 
    # Retrieve news articles
    news = stock.news
 
    return hist_data, balance_sheet, financials, news
 
def get_claude_comps_analysis(ticker, hist_data, balance_sheet, financials, news):
    system_prompt = f"You are a financial analyst assistant. Analyze the given data for {ticker} and suggest a few comparable companies to consider. Do so in a Python-parseable list."
 
    news = ""
 
    for article in news:
        article_text = get_article_text(article['link'])
        news = news + f"\n\n---\n\nTitle: {article['title']}\nText: {article_text}"
 
    messages = [
        {"role": "user", "content": f"Historical price data:\n{hist_data.tail().to_string()}\n\nBalance Sheet:\n{balance_sheet.to_string()}\n\nFinancial Statements:\n{financials.to_string()}\n\nNews articles:\n{news.strip()}\n\n----\n\nNow, suggest a few comparable companies to consider, in a Python-parseable list. Return nothing but the list. Make sure the companies are in the form of their tickers."},
    ]
 
 
    headers = {
        "x-api-key": ANTHROPIC_API_KEY,
        "anthropic-version": "2023-06-01",
        "content-type": "application/json"
    }
    data = {
        "model": 'claude-3-haiku-20240307',
        "max_tokens": 2000,
        "temperature": 0.5,
        "system": system_prompt,
        "messages": messages,
    }
    response = requests.post("[https://api.anthropic.com/v1/messages](https://api.anthropic.com/v1/messages)", headers=headers, json=data)
    response_text = response.json()['content'][0]['text']
 
    return ast.literal_eval(response_text)
 
def compare_companies(main_ticker, main_data, comp_ticker, comp_data):
    system_prompt = f"You are a financial analyst assistant. Compare the data of {main_ticker} against {comp_ticker} and provide a detailed comparison, like a world-class analyst would. Be measured and discerning. Truly think about the positives and negatives of each company. Be sure of your analysis. You are a skeptical investor."
 
    messages = [
        {"role": "user", "content": f"Data for {main_ticker}:\n\nHistorical price data:\n{main_data['hist_data'].tail().to_string()}\n\nBalance Sheet:\n{main_data['balance_sheet'].to_string()}\n\nFinancial Statements:\n{main_data['financials'].to_string()}\n\n----\n\nData for {comp_ticker}:\n\nHistorical price data:\n{comp_data['hist_data'].tail().to_string()}\n\nBalance Sheet:\n{comp_data['balance_sheet'].to_string()}\n\nFinancial Statements:\n{comp_data['financials'].to_string()}\n\n----\n\nNow, provide a detailed comparison of {main_ticker} against {comp_ticker}. Explain your thinking very clearly."},
    ]
 
    headers = {
        "x-api-key": ANTHROPIC_API_KEY,
        "anthropic-version": "2023-06-01",
        "content-type": "application/json"
    }
    data = {
        "model": 'claude-3-haiku-20240307',
        "max_tokens": 3000,
        "temperature": 0.5,
        "system": system_prompt,
        "messages": messages,
    }
    response = requests.post("[https://api.anthropic.com/v1/messages](https://api.anthropic.com/v1/messages)", headers=headers, json=data)
    response_text = response.json()['content'][0]['text']
 
    # return json.loads(response_text)
    return response_text
 
def get_sentiment_analysis(ticker, news):
    system_prompt = f"You are a sentiment analysis assistant. Analyze the sentiment of the given news articles for {ticker} and provide a summary of the overall sentiment and any notable changes over time. Be measured and discerning. You are a skeptical investor."
 
    news_text = ""
    for article in news:
        article_text = get_article_text(article['link'])
        timestamp = datetime.fromtimestamp(article['providerPublishTime']).strftime("%Y-%m-%d")
        news_text += f"\n\n---\n\nDate: {timestamp}\nTitle: {article['title']}\nText: {article_text}"
 
    messages = [
        {"role": "user", "content": f"News articles for {ticker}:\n{news_text}\n\n----\n\nProvide a summary of the overall sentiment and any notable changes over time."},
    ]
 
    headers = {
        "x-api-key": ANTHROPIC_API_KEY,
        "anthropic-version": "2023-06-01",
        "content-type": "application/json"
    }
    data = {
        "model": 'claude-3-haiku-20240307',
        "max_tokens": 2000,
        "temperature": 0.5,
        "system": system_prompt,
        "messages": messages,
    }
    response = requests.post("[https://api.anthropic.com/v1/messages](https://api.anthropic.com/v1/messages)", headers=headers, json=data)
    response_text = response.json()['content'][0]['text']
 
    return response_text
 
def get_analyst_ratings(ticker):
    stock = yf.Ticker(ticker)
    recommendations = stock.recommendations
    if recommendations is None or recommendations.empty:
        return "No analyst ratings available."
 
    latest_rating = recommendations.iloc[-1]
 
    firm = latest_rating.get('Firm', 'N/A')
    to_grade = latest_rating.get('To Grade', 'N/A')
    action = latest_rating.get('Action', 'N/A')
 
    rating_summary = f"Latest analyst rating for {ticker}:\nFirm: {firm}\nTo Grade: {to_grade}\nAction: {action}"
 
    return rating_summary
 
def get_industry_analysis(ticker):
 
    ### update to use search to find recent data!!
 
    stock = yf.Ticker(ticker)
    industry = stock.info['industry']
    sector = stock.info['sector']
 
    system_prompt = f"You are an industry analysis assistant. Provide an analysis of the {industry} industry and {sector} sector, including trends, growth prospects, regulatory changes, and competitive landscape. Be measured and discerning. Truly think about the positives and negatives of the stock. Be sure of your analysis. You are a skeptical investor."
 
    messages = [
        {"role": "user", "content": f"Provide an analysis of the {industry} industry and {sector} sector."},
    ]
 
    headers = {
        "x-api-key": ANTHROPIC_API_KEY,
        "anthropic-version": "2023-06-01",
        "content-type": "application/json"
    }
    data = {
        "model": 'claude-3-haiku-20240307',
        "max_tokens": 2000,
        "temperature": 0.5,
        "system": system_prompt,
        "messages": messages,
    }
    response = requests.post("[https://api.anthropic.com/v1/messages](https://api.anthropic.com/v1/messages)", headers=headers, json=data)
    response_text = response.json()['content'][0]['text']
 
    return response_text
 
 
def get_final_analysis(ticker, comparisons, sentiment_analysis, analyst_ratings, industry_analysis):
    system_prompt = f"You are a financial analyst providing a final investment recommendation for {ticker} based on the given data and analyses. Be measured and discerning. Truly think about the positives and negatives of the stock. Be sure of your analysis. You are a skeptical investor."
 
    messages = [
        {"role": "user", "content": f"Ticker: {ticker}\n\nComparative Analysis:\n{json.dumps(comparisons, indent=2)}\n\nSentiment Analysis:\n{sentiment_analysis}\n\nAnalyst Ratings:\n{analyst_ratings}\n\nIndustry Analysis:\n{industry_analysis}\n\nBased on the provided data and analyses, please provide a comprehensive investment analysis and recommendation for {ticker}. Consider the company's financial strength, growth prospects, competitive position, and potential risks. Provide a clear and concise recommendation on whether to buy, hold, or sell the stock, along with supporting rationale."},
    ]
 
    headers = {
        "x-api-key": ANTHROPIC_API_KEY,
        "anthropic-version": "2023-06-01",
        "content-type": "application/json"
    }
    data = {
        "model": 'claude-3-opus-20240229',
        "max_tokens": 3000,
        "temperature": 0.5,
        "system": system_prompt,
        "messages": messages,
    }
    response = requests.post("[https://api.anthropic.com/v1/messages](https://api.anthropic.com/v1/messages)", headers=headers, json=data)
    response_text = response.json()['content'][0]['text']
 
    return response_text
 
def generate_ticker_ideas(industry):
    system_prompt = f"You are a financial analyst assistant. Generate a list of 5 ticker symbols for major companies in the {industry} industry, as a Python-parseable list."
 
    messages = [
        {"role": "user", "content": f"Please provide a list of 5 ticker symbols for major companies in the {industry} industry as a Python-parseable list. Only respond with the list, no other text."},
    ]
 
    headers = {
        "x-api-key": ANTHROPIC_API_KEY,
        "anthropic-version": "2023-06-01",
        "content-type": "application/json"
    }
    data = {
        "model": 'claude-3-haiku-20240307',
        "max_tokens": 200,
        "temperature": 0.5,
        "system": system_prompt,
        "messages": messages,
    }
    response = requests.post("[https://api.anthropic.com/v1/messages](https://api.anthropic.com/v1/messages)", headers=headers, json=data)
    response_text = response.json()['content'][0]['text']
 
    ticker_list = ast.literal_eval(response_text)
    return [ticker.strip() for ticker in ticker_list]
 
def get_current_price(ticker):
    stock = yf.Ticker(ticker)
    data = stock.history(period='1d', interval='1m')
    return data['Close'][-1]
 
def rank_companies(industry, analyses, prices):
    system_prompt = f"You are a financial analyst providing a ranking of companies in the {industry} industry based on their investment potential. Be discerning and sharp. Truly think about whether a stock is valuable or not. You are a skeptical investor."
 
    analysis_text = "\n\n".join(
        f"Ticker: {ticker}\nCurrent Price: {prices.get(ticker, 'N/A')}\nAnalysis:\n{analysis}"
        for ticker, analysis in analyses.items()
    )
 
    messages = [
        {"role": "user", "content": f"Industry: {industry}\n\nCompany Analyses:\n{analysis_text}\n\nBased on the provided analyses, please rank the companies from most attractive to least attractive for investment. Provide a brief rationale for your ranking. In each rationale, include the current price (if available) and a price target."},
    ]
 
    headers = {
        "x-api-key": ANTHROPIC_API_KEY,
        "anthropic-version": "2023-06-01",
        "content-type": "application/json"
    }
    data = {
        "model": 'claude-3-opus-20240229',
        "max_tokens": 3000,
        "temperature": 0.5,
        "system": system_prompt,
        "messages": messages,
    }
    response = requests.post("[https://api.anthropic.com/v1/messages](https://api.anthropic.com/v1/messages)", headers=headers, json=data)
    response_text = response.json()['content'][0]['text']
 
    return response_text
 
# User input
industry = input("Enter the industry to analyze: ")
years = 1 # int(input("Enter the number of years for analysis: "))
 
# Generate ticker ideas for the industry
tickers = generate_ticker_ideas(industry)
print(f"\nTicker Ideas for {industry} Industry:")
print(", ".join(tickers))
 
# Perform analysis for each company
analyses = {}
prices = {}
for ticker in tickers:
    try:
        print(f"\nAnalyzing {ticker}...")
        hist_data, balance_sheet, financials, news = get_stock_data(ticker, years)
        main_data = {
            'hist_data': hist_data,
            'balance_sheet': balance_sheet,
            'financials': financials,
            'news': news
        }
        sentiment_analysis = get_sentiment_analysis(ticker, news)
        analyst_ratings = get_analyst_ratings(ticker)
        industry_analysis = get_industry_analysis(ticker)
        final_analysis = get_final_analysis(ticker, {}, sentiment_analysis, analyst_ratings, industry_analysis)
        analyses[ticker] = final_analysis
        prices[ticker] = get_current_price(ticker)
    except:
        pass
 
# Rank the companies based on their analyses
ranking = rank_companies(industry, analyses, prices)
print(f"\nRanking of Companies in the {industry} Industry:")
print(ranking)

↑めっちゃ長いです笑

④ Claude Investorが株式銘柄を選別する。

上記の長い文章をコピペすると、「Enter the industry to analyze(分析したい業界を入力してください)」という文字が表れます。

ご自身で好きな業界を選びましょう!私の場合は「Tech(テック)」業界を選びました。

「Tech」の他にも、「Energy(エネルギー業界)」、「Bank(銀行業界)」、「Entertainment(エンタメ業界)」、「Semiconductor(半導体業界)」などいろいろあるので試してみましょう。

するとその業界を代表する5つの米国銘柄をClaude AIが選出します。

具体的な銘柄はおすすめできないのですが、雰囲気だけお伝えするために偽物のティッカーでお伝えします。

AIのおすすめ順に並べた表を作るとこのようになりました。※銘柄は実在しません!

ティッカー 現在の株価 目標株価 説明
1. OCR(オークロ) $423.23 $450 強力な財務実績、クラウド コンピューティングのリーダーシップ、戦略的パートナーシップにより、オークロは最も魅力的な投資オプションとなっています。
2. MATG(マットジー) $178.13 $200 マットジーは電子商取引における圧倒的な地位、クラウド コンピューティングや広告などの高成長分野への多角化、業界の好調な傾向により、魅力的な投資となっています。
3. GODL(グードル) $149.23 $160 グードルは長期的な投資として魅力的です。 しかし、特に EU からの規制監視が強化されており、短期的には明確な前向きの触媒が欠如しているため、慎重なアプローチが必要です。
4. Pear(ペアー) $169.83 $175 ペアーの強力なブランドは強みです。 しかし、EUの規制リスク、明確な前向きの触媒の欠如、サプライチェーンの問題や競争に関連した業界の逆風により、魅力が落ちてきています。
5. PESL(ペースル) $173.80 $150 ペースルの EV 市場における強力なブランド認知は、注目に値する利点です。 しかし、競争の激化、需要への懸念により、検討対象企業の中で最も魅力の低い投資オプションとなっている。

シュマー氏はClaude Investorを使って投資をすることについておすすめしていないそうなので、投資をする際は自己責任でお願いします!

*掲載している情報は、投資の勧誘や売買推奨を目的としたものではありません。投資のご判断はご自身の責任でお願いします。

参考文献 ・Matt Shumer X AccountGoogle Colabmshumer / gpt-investor

Read more

リアルタイム投票アプリ5選【ライブ配信やイベントで】

リアルタイム投票アプリ5選【ライブ配信やイベントで】

ウェビナーやセミナー、社内研修を実施する際、「参加者が受け身になってしまう」「質問がなかなか出てこない」といった課題を感じたことはないでしょうか。 オンラインでの情報発信が当たり前になった今、一方的な配信だけでは参加者の満足度を高めることが難しくなっています。そこで注目されているのが、リアルタイムで参加者の意見を集約し、その場で結果を共有できる投票・質問ツールです。 本記事では、ライブ配信やイベント、研修などで活用できるリアルタイム投票アプリを5つ厳選してご紹介します。 リアルタイム投票でつながる参加者とイベント リアルタイム投票やQ&A機能を使うと、視聴者や参加者の意見を即座に集計・表示できます。講義や会議の進行を妨げず、参加者全員が自分の意見を簡単に表明できる仕組みです。 従来の挙手による質疑応答では、発言しづらいと感じる参加者も少なくありません。特にオンラインイベントでは、カメラがオンになっていることへの抵抗感や、大人数の前で質問することへのハードルが存在します。 しかし、スマートフォンから匿名で投票やコメントができる仕組みがあれば、参加者は気軽に自分の意見を伝えら

By 阿部 隼也
質問受付ツールの選び方とおすすめ5選を紹介

質問受付ツールの選び方とおすすめ5選を紹介

セミナーや講演会、社内研修などで「質問はありませんか?」と投げかけても、なかなか手が挙がらない経験はないでしょうか。参加者に有益な情報を提供しても、疑問や意見が共有されないまま終わってしまうのは、主催者にとっても参加者にとっても大きな機会損失です。 こうした課題を解決するために注目されているのが「質問受付ツール」です。参加者がスマートフォンから匿名で質問を投稿できるため、発言への抵抗感が下がり、活発なコミュニケーションが生まれます。 本記事では、質問受付ツールの基本機能から、実際に役立つおすすめツール5選、そして選定時に押さえておきたいポイントまで、実務に活かせる情報をまとめて解説します。 質問受付の現場課題 イベントやセミナーの運営で最も頭を悩ませる問題の一つが、参加者からの質問をいかに引き出すかという点です。質問タイムを設けても、会場がシーンと静まり返ってしまい、仕方なく「それでは時間になりましたので」と締めくくる光景は珍しくありません。 この背景には、日本特有の文化的要因も関係しています。大勢の前で発言することへの恥ずかしさ、自分の質問が的外れではないかという不安、他

By 阿部 隼也
オンラインセミナーアプリの選び方。参加者エンゲージメントを高めるポイント

オンラインセミナーアプリの選び方。参加者エンゲージメントを高めるポイント

近年、オンラインセミナーの活用が急速に広がっています。会場のコストや移動時間を気にすることなく、全国・世界中から参加者を集められる点は大きな魅力です。 しかし、せっかく開催しても 「参加者が途中で離脱してしまう」 「ただ見ているだけで反応が薄い」 といった課題を抱えている企業も少なくありません。 本記事では、参加者のエンゲージメントを高め、成果につながるオンラインセミナーアプリの選び方と、実務に役立つ具体的なポイントを解説します。 参加者とのつながりを生むオンライン環境の設計 オンラインセミナーにおける最大の課題は、画面越しの距離感です。会場で直接顔を合わせる機会がないからこそ、参加者が「ただ見ているだけ」にならないような仕組みが求められます。適切なツールと機能選びが、参加者のエンゲージメントを左右します。 従来のオフラインセミナーでは、会場の雰囲気や参加者同士の反応が自然と生まれましたが、オンラインではそうした「空気感」が伝わりにくくなります。だからこそ、双方向のコミュニケーション機能や、参加者の行動データを活用した設計が重要になるのです。 エンゲージメントを高

By 阿部 隼也
参加者の質問を効率的に管理!ZoomウェビナーQ&A機能の使い方を徹底解説

参加者の質問を効率的に管理!ZoomウェビナーQ&A機能の使い方を徹底解説

オンラインでのセミナーやイベントが日常化する中で、Zoomウェビナーを活用している企業が増えています。しかし、ウェビナーの開催で意外と頭を悩ませるのが「参加者からの質問をどう管理するか」という点ではないでしょうか。 セミナーが盛り上がり、次々と質問が寄せられるのは嬉しいことです。一方で、質問が多すぎて整理しきれない、どの質問に優先的に答えるべきか判断に迷う、といった課題も生じます。こうした問題を解決するために役立つのが、ZoomウェビナーのQ&A機能です。 本記事では、ZoomウェビナーのQ&A機能の基本的な使い方から、参加者の質問を効率的に管理する実践的なテクニックまで、詳しく解説していきます。 ZoomウェビナーのQ&A機能とは ZoomウェビナーのQ&A機能は、ウェビナー開催中に参加者が質問を投稿し、主催者側が回答を行うための専用機能です。この機能を使うことで、質問と回答がスレッド形式で整理され、効率的なコミュニケーションが可能になります。 チャット機能との違い Zoomには「チャット機能」もあるため、「Q&A機能とチャット機能の違いは何か」と疑問に思う方も多いで

By 阿部 隼也