LoginSignup
17
8
生成AIに関する記事を書こう!
Qiita Engineer Festa20242024年7月17日まで開催中!

AIを活用して「米株の分析レポート提供サービス」を個人で作ってみた (crewAI & Ollama & OpenAI)

Last updated at Posted at 2024-07-08

この記事の内容にある意見は、個人の主観的意見を前提とします。
記事の内容は間違いがあり得ますので、ご了承いただけると幸いです。
内容の間違い、認識の違い、違う意見などありましたら、コメントいただけると幸いです。

0. 概要

今回、まだ実験段階ではありますが、AIを活用した個人サービス作りを試しましたので、その後書きを記事としてまとめておこうと思います。

テーマは「米株のAI分析と運用レコメンド生成」により作られたコンテンツをWebサービスとして提供することです。

前提としては、「最低限の予算で、週16時間を目安に、1ヶ月以内にリリース・運用する」が目標で、開発もスクラッチに行ったので、コンテンツの調整が不足している部分や不安定な機能もありますが、今後改善・機能追加などを試しながら学習と経験を得ようかなと思ってます。
(実際初めてから、3週くらいでデプロイが叶いました)

記事の構成は以下のとおりです。

  • 1. サービス紹介
    • サービスURLと代表的な機能・画面を簡単に紹介します
  • 2. サービス構想
    • サービス提供コンセプトとユーザーストーリー・提供価値ををもとに、どのようなユーザーにどのような価値を届けたいかについての構想を紹介します
  • 3. サービス提供基盤
    • どのような技術スタックでサービスが構成されているかを概略的に紹介します
  • 4. サービスのアプリケーションアーキテクチャ
    • サービス提供基盤のもと、どのようなアプリケーション構造と処理を行っているかを概略的に紹介します
  • 5. エピローグ
    • 開発動機、今後改善したいこと、感想など、気づきや思ったことを紹介します
  • 6. APPENDIX
    • OpenAIのgpt-3.5-turboとLocal LLMのmixtral 8x7bのq3, q4の米株分析について簡単に比較した内容を添付します

では、本格的に内容を紹介していきます。

1.サービス紹介

サービスURLと代表的な機能・画面を簡単に紹介します

1.1 作ったサービスURL

  • STOCKSMEAL
  • キャッチフレーズ
    • 美味しい食事のような株式情報とAIによるレポートをお届けします
    • ※適当につけたものなので、後で考え直そうと思ってます

1.2 サービス簡単紹介

1.2.1 米株市場での取引においてランク情報を提供

米株市場での取引においてランク情報を提供します。

※時価総額ランクは20個、その他は3つで今は制限しています。今後費用面を踏まえ増やしていこうと思ってます。

image.png

1.2.2 ランク情報にある米株において、AIによるデータ分析レポートと運用レコメンドを提供

「1ヶ月の株価変動推移」「ニュース情報」「財務状態」のデータと、そのデータに基づいた「投資家」「ファンドマネージャー」「ニュース情報分析家」「財務分析家」「技術分析家」の観点での分析コメントを提供します。

image.png

1.2.3 多国語サポート(英語、日本語、韓国語)

「英語、日本語、韓国語」の3つの言語をサポートします。英語をベースに、Local LLMを利用して日本語と韓国語に翻訳を行っています。

image.png

2. サービス構想

サービス提供コンセプトとユーザーストーリー・提供価値ををもとに、どのようなユーザーにどのような価値を届けたいかについての構想を紹介します。

2.1 サービスコンセプト

サービスコンセプトは以下のとおりです。

  • ①AIによる米株データ収集・分析
    • 外部サービスからデータ収集し分析を行います
    • 株ごとの詳細情報を収集、および分析はAIエージェントにより遂行されます
  • ②AIによる米株の運用戦略レコメンド
    • 収集・分析情報から運用戦略をAIを通して生成します
  • ③AI生成コンテンツをWebサービスで提供
    • ランキング情報と、該当する米株のAIデータ分析・運用レコメンドのコンテンツをWebサービスとして提供します

memo-CREWAI-SERVICE-FLOW.drawio.png

2.2 ユーザーストーリーと提供価値

かなり適当に縮約された形で、論理的に穴も多いかもですが、「ペルソナ」「モチベーション」「提供価値」の結びつきで表現しています。

ユーザーストーリーと提供価値

ユーザー的に私自身は、投資初心者にあたりますが、まずサービスが小さいうちは、主に狙うターゲットは「投資経験者」を想定しようと考えています。

なんとなくで適当で、根拠と実証は必要ではありますが、今考えている理由は以下です。

  • 「投資経験者」のターゲット層から期待したいと思ったこと
    • 最も多くのユーザー数が期待できる層と思った
    • 小規模のコンテンツの状態でも、興味をもって活用してくれる望みがあるユーザー層と思った
    • 最も一般的で初心者から専門家層にもつなげるフィードバックが取れる層とと思った

3. サービス提供基盤

どのような技術スタックでサービスが構成されているかを概略的に紹介します。
サービスを提供するために利用する基盤環境はシンプルです。

サービス提供基盤

3.1 外部サービス(データ収集)

データ収集には、以下の3つのサービスを利用しており、すべて無料利用の範囲で連携してます。

  • ALPHA VANTAGE
    • Gain,Loser,Activeランキングを取得します
    • REST APIを提供します
  • Companiesmarketcap.com
    • 時価総額ランキングを取得します
    • CSV DOWNLOADを提供します
  • Yahoo Finance
    • 株の価格情報と関連ニュース・企業財務データを取得します
    • Pythonライブラリのyfinanceを利用しています

3.2 データ処理・生成基盤

主に収集したデータに対してAI関連処理とデータのDB格納を遂行するための基盤です。予算の関係上自前PCで環境を構築しています。今後、無料でカバーできるクラウドサービスがあれば、一部をクラウドにしたいと思ってます。

3.2.1 crewAI

役割ベース設計のAIエージェントツールです。
Prompt EngineeringのRole-Play Promptingというものに基づいていそうです。
※開発の基本概念や実装方式については、「4.1 crewAIの処理方式」で簡単に後述します

米株データ収集・分析・運用レコメンド生成の目標に対して、AIと連携し作業設定・遂行・検証を自律的に行います

3.2.2 Ollama

OpenSource LLMをLocalで駆動してくれるプラットフォームです。

crewai & gpt-3.5turboが生成した結果を多国語に翻訳する用途で利用してます。
モデルはaya:8bを使っています。
ollama aya:8b

crewAIと連携するAIとして利用、データ分析・レコメンド生成・検証などの推論処理に使います。
ある程度の精度を出すために必要な時間&マシンパワー関係上、現段階のデータ量ではOpenAIのgpt-3.5-turboが効率的と判断しOpenAIにしています。

OpenAIのgpt-3.5-turboとLocal LLMのmixtral 8x7bのq3, q4の米株分析結果について簡単に比較した内容を「6. APPENDIX」セクションに添付し、そこで簡単に経緯を補足します。

Ollamaで精度が期待できるモデルとマシンパワーについて(Clickで見る)

精度が期待できるllama3 70b-q4の場合33GB、mixtral 8x7b-q4の場合でも27GBのVRAMが必要、q8の場合は2倍、量子化なし(float16,float32)の場合4倍・8倍が必要です。

mixtral 8x7b-q3が、ちょうどNVIDIA RTX3090の24GB VRAMで収まり、悪くない結果を出してはくれますが、gpt3.5turboがもう少しいい推論をしてくれて格安なので、gpt3.5turboにしています。

少しマシンパワーをアップしたら、gpt3.5とmixtral 8x7b q4のハイブリットでもやってみたいと思ってます。

3.2.3 OpenAI

OpenAIが提供しているChat APIでgpt-3.5turboモデルを利用します。

crewAIと連携するAIとして利用、データ分析・レコメンド生成・検証などの推論処理に使います。

約30個の米株をcrewaiを使ってデータ生成するのにあたって、約0.2ドルくらいの金額感です。(やすいですね)

3.3 Webサービス提供基盤

すべて無料で収まるシンプルな組み合わせで構成しています。

  • MongoDB Atlas (DB)
    • MongoDBのクラウドサービスを提供、一部制約はありますが、512MBまでは無料で使えます
    • 「データ処理・生成基盤」で作られたデータの保存とWebサービスでのデータ元として使います
  • Vercel(with Github, Next.js)
    • Next.jsのWebアプリケーションのクラウドホスティングを専門とするプラットフォーム、Hobby Planという無料枠で利用できます
    • WebのUIとAPI部分のサービスで利用します

4. サービスのアプリケーションアーキテクチャ

サービス提供基盤のもと、どのようなアプリケーション構造と処理を行っているかを概略的に紹介します。

全体的なアプリケーション構造を表したものはこうなります。

memo-CREWAI-SERVICE-ARCH.drawio.png

この記事ではAIに関わる部分を簡単な範囲で紹介します。

4.1 crewAIの処理方式

4.1.1 概要

今回の核となるAIエージェントツールの一つです。
OpenAIのようなSaas AIサービスはもちろん、OllamaなどでLocal LLMを利用した活用も可能です。

主な概念としては、「エージェント」「タスク」「ツール」という概念が中心となり、人が目標を指示、AIがその目標を達成するために必要な作業を推論・判断し遂行するイメージです。

「役割ベースのエージェント」設計を特徴としており、役割・ゴール・人物背景などを設定できます。そのエージェントが複数存在し、お互いに連携しあって目標達成をしていくところが印象的です。

プロンプトエンジニアリングのRole-Play Promptingに充実したコンセプトだと思います。

コンセプトや核心機能は、GitHubページのREADMEでよく整理されています。
https://github.com/joaomdmoura/crewai/

また、crewaiを活用に参考になるサンプルコードもあるので参考にするとよいと思います。
https://github.com/joaomdmoura/crewAI-examples

本サービスにおいても、上記の例を多く参考にしています。

4.1.2 実装概念解説

全体像の概念設計のあと、実装にあたって使われた概念を以下の段階で紹介します。

  • ①エージェント定義
  • ②ツール定義
  • ③タスク定義
  • ④AI処理モデル指定
  • ⑤エージェントを作成(コンテキスト引き継ぎ)
  • ⑥実行

①エージェント定義

crewAIで、とあるタスクを遂行する役者として、エージェントを定義します。
キーとなる指示パラメータとして「role」「goal」「backstory」があります。また外部データを参照にさせたい場合は「tools」パラメータを指定して行うことが可能です。

指示内容と結果については、使うモデルやデータ条件によって色々調整が必要な場合は多いです。今から紹介する例は、必ずしも求む結果を正確に出してくれるという保証はありません。

また、モデルと指定オプションによっても、結果の方向性は変化する場合も多いです。例えば、モデルのtemperatureをどう設定や、crewAIのDeligation許容有無などがその例です。

  • モデルのtemperature : 回答の一貫性と多様性の調整パラメータ
  • crewAIのDeligation許容 : 作業を他のエージェントに委任することの許容有無

toolsはcrewAIが提供するものもあれば、カスタムツールを作成して割り当てることも可能です。

image.png

コード化するとこうなります。

from crewai import Agent
...
technical_analyst = Agent(
    role="Technical Analyst",
    goal="First, Get Data. Next, Interpret it. Next, Analyze the {company} stock's movements of a stock and provide insights on trends, entry points, resistance and support levels.",
    backstory="An export in technical analysis, you are known for your ability to predict stock prices. You provide valuable insights to your customers.",
    tools=[
        stock_price,
    ],
    ...オプションは省略
)

②ツール定義

①で指定したツールを、カスタムツールとして指定を想定して作成します。
キーとなる要素は以下の2つです。

  • ツール説明
    • エージェントに「このツールの使い方」を示します
    • ツールの目的と結果、渡す引数などの説明をエージェントに示すことで、エージェントはこのツールをどう使うかの推論が可能となります
    • ツール説明の定義の仕方はいくつかあり、今回はコメント形式を使ってます
  • 処理
    • 実際のツールの処理を実装します
    • yfinanceライブラリを使って株価変動データを取得する処理を行います

image.png

コード化するとこうなります。

from crewai_tools import tool
...
@tool("Stock Price")
def stock_price(ticker):
    """
    Useful to get stock price data.
    The input should be a ticker, for example AAPL, NET.
    """
    ticker = yf.Ticker(ticker)
    dict = {}
    dict[f"{ticker}_stock_price"] = ticker.history(period="1mo")
    ticker.history(period="1mo").to_json("output/stock_price_data.json")
    return dict
...

technical_analyst = Agent(
    ...,
    tools=[
        stock_price,
    ],
    ...オプションは省略
)

③タスク定義

あとは、実際にエージェントに指示をするタスクを定義します。
キーとなる要素は以下の3つです

  • agent
    • タスクを遂行するエージェントを指定します
  • description
    • タスクの内容を指定します
  • expected_output
    • タスクのゴール(期待結果)を指定します

image.png

コード化するとこうなります。

from crewai import Task
...

@tool("Stock Price")
def stock_price(ticker):
   ...

technical_analyst = Agent(
    ...
)

technical_analysis_task = Task(
    description="Provide your insight to hedge fund manager that the {company} stock price movements and identify key support and resistance levels chart patterns.",
    agent=technical_analyst,
    expected_output="Your final answer MUST be the {company} stock's insight report with potential entry points, price targets and any other relevant information."
)

④AI処理モデル指定

crewAIに指示する命令の基本単位であるタスクまで定義ができたので、あとは推論に使うAI Modelを指定します。

基本、環境変数にOpenAIのAPIKEYを指定して利用することもできますが、OpenAIとOllamaなど違うAIプラットフォームの利用も見据えて、ChatOpenAIクラスからのAI Modelの指定を行います。

image.png

from langchain_openai import ChatOpenAI
...

llm_default = ChatOpenAI(
    "model": "gpt-3.5-turbo",
    "base_url" : "https://api.openai.com/v1",
    "api_key" : "input your key")

# ollamaの場合の例
# llm_ollama = ChatOpenAI(
#     model = "mixtral:8x7b-instruct-v0.1-q3_K_M",
#     temperature=0.8,
#     base_url = "http://localhost:11434/v1")

technical_analyst = Agent(
    ...,
    llm=llm_default
)

あと「ニュース分析」「財務分析」においても似た感じで作成します。

⑤エージェントを作成(コンテキスト引き継ぎ)

ファンドマネジャーが遂行するタスクは「株価分析」「ニュース分析」「財務分析」3つの結果を参考にし推論します。

image.png

その際に、タスクのパラメータのcontextに、結果を参照するタスクを指定することで可能です。

researcher = Agent(...)
technical_analyst = Agent(...)
financial_analyst = Agent(...)
+ fund_manager = Agent(...)

research_task = Task(agent=researcher)
technical_analysis_task = Task(agent=technical_analyst)
financial_analysis_task = Task(agent=financial_analyst)
+ fund_managing_recommendation_task = Task(
+    ...,
+    context=[
+        research_task,
+        technical_analysis_task,
+        financial_analysis_task,
+    ],
+)

⑥実行

実行は以下のようなコードでできます。

crew = Crew(
    agents=[
        researcher,
        technical_analyst,
        financial_analyst,
        fund_manager,
    ],
    tasks=[
        research_task,
        technical_analysis_task,
        financial_analysis_task,
        fund_managing_recommendation_task,
    ]
)

result = crew.kickoff(
    inputs={
        "company":"検索する株の会社名",
    }
)

4.2 Local LLMを利用した多国語翻訳

Local LLMの利用はOllamaとOpenSource LLMのaya:8bを利用しています。

少しテーマは違いますが、Ollamaのセットアップとモデルの活用は以下の記事で参考できます。

crewAIの結果はファイルとして出力するようにしています。その内容を読み取りOllamaのREST APIを呼び出して翻訳処理を行います。

OllamaのREST APIを利用して翻訳するイメージは、以下のcurl結果を参考ください。

curl -v http://{ollama host}/api/chat -d '{
  "model": "aya:8b",
  "messages": [
    {
      "role": "user",
      "content": "translate to japanese below text.\n\n-----\n have a nice day!\n-----\n"
    }
  ]
}'
...
{"model":"aya:8b","created_at":"2024-07-07T10:12:00.032009121Z","message":{"role":"assistant","content":"素"},"done":false}
{"model":"aya:8b","created_at":"2024-07-07T10:12:00.084700458Z","message":{"role":"assistant","content":"敵"},"done":false}
{"model":"aya:8b","created_at":"2024-07-07T10:12:00.099210243Z","message":{"role":"assistant","content":"な"},"done":false}
{"model":"aya:8b","created_at":"2024-07-07T10:12:00.11328748Z","message":{"role":"assistant","content":"一日"},"done":false}
{"model":"aya:8b","created_at":"2024-07-07T10:12:00.12789602Z","message":{"role":"assistant","content":"を"},"done":false}
{"model":"aya:8b","created_at":"2024-07-07T10:12:00.142332218Z","message":{"role":"assistant","content":"!"},"done":false}
{"model":"aya:8b","created_at":"2024-07-07T10:12:00.156791388Z","message":{"role":"assistant","content":""},"done_reason":"stop","done":true,"total_duration":524233845,"load_duration":944088,"prompt_eval_count":21,"prompt_eval_duration":249671000,"eval_count":7,"eval_duration":124800000}

5. エピローグ

まだ抽象的ではありますが、今後改善したいこと、開発動機・感想・気づきや思ったことなど、筆者の思いを最後に述べて記事を終えようと思います。

5.1 開発動機

5.1.1 作ろうと思ったきっかけ

  • 前からなにか個人サービスを作って出してみたかった
  • 最近米株投資を少しだけ始めたが、マイナスの状態で知らないことがいっぱい。一から勉強するのはハードルが高かったので、定期的に都合よくサマリーされた情報が欲しかった
  • Llamaを利用したローカルLLMの活用方法について、RAGの活用といくつかのツールを試しながら模索していた。(Ollama、pgvector、Dify、crewAIなど)
  • CrewAIの株式分析に関する例を見て、CrewAIを使ってサービスを作ってみようというアイデアが浮かんだ

5.1.2 筆者のモチベーション

  • 株式投資の初心者として、株の売買について多様なデータや専門家の観点からのアドバイスを聞いて参考にしたい
  • 株式市場で関心が高い株について、できるだけ簡単に動向を把握したい
  • とにかく毎日要約された情報を簡単に見たい
  • お金いっぱい儲けたい(重要)

5.1.3 サービスを通してやりたかったこと

  • 米株ごとの参考データを自動収集したい
  • AIでデータの分析・解釈を行い、米株の売買に関してどうするべきかの意見を生成し、運用の参考にしたい
  • 米株市場のランキングデータはほしい
  • 多言語対応をしたい(グローバル時代)

5.1.4 得たいこと

  • 初の個人サービスを作って出してみた経験を得る(特に実用まではいかなくて良い)
  • AIを活用したアプリケーション開発経験を得る
  • 米株についての知識を得る

5.1.5 サービスを作るうえで抑えたいと思ったこと

  • インフラ及びSaaS費用を最小限にしたい
    • 家計が厳しい
    • 実験的サービスに収益化の可能性がほぼないことから、AI利用コストを最小化したい(まだROIが絶望的)
    • Web、およびDBホスティングは無料範囲内で選びたい
    • AIによるデータ生成、及び更新費用も可能な限りゼロにしたい
  • 1か月以内に公開したい。週末を含めて週平均16時間程度の投資が可能である
  • 収益化などはまず考えない(あくまで実験・学習目的を重視する)

5.2 作って見て思ったこと

5.2.1 学んだこと・得たこと

  • もともと掲げた「個人サービスを出す」は得られた
  • 「AIを活用したアプリケーション開発経験」「米株についての知識を得る」も、少しではあるが得られた
  • OllamaとLocal LLMの活用について知見が広まった
  • AIについてもっと興味を持つようになった

5.2.2 良かったこと

  • AIがないと膨大な時間がかかる分量のコンテンツの生成を、AIによって定期的に自動生成して提供することが、本サービスである程度実現できた
  • 多国語のサポートのユーザーサービスが実現できた
  • 短期間、低予算でデリバリーができた

5.2.3 反省点

  • 実際にAIについては深い理解がないので勉強が必要(活用観点に偏っているためカスタマイズや高度な作業はハドルが高い)
  • 結果の精度についてはもっと高める必要がある(パラメータの調整など)
  • 米株の知識が不足している中、サービスとして出したので、これからはドメイン知識としてもっと深く理解する必要がある
  • 維持保守・運用を想定したコード構造・ミドルウェブ構造になっていないので改善必要(スクラッチな開発からの負債を残したまま)

5.3 今後改善したいこと

大体、ユーザーが増える&リターンが見合う前提のものが多くある気もしますが、思いつくことを軽く記載します。

5.3.1 サービス面で改善したいこと

  • 米株のドメイン知識が深まったうえでの良質のコンテンツの提供
  • AIにおいてモデル強化、パラメータ調整、RAGなどを通したコンテンツ生成の精度を強化
  • 会員機能と個別化の強化(お気に入り登録、AIレポートに対してのユーザー評価機能など、ユーザーに合わせた機能など)
  • デザイン・UI・UXの改善
  • マーケティング戦略の検討

5.3.2 システム面

  • データ更新プロセスの完全自動化
  • 提供する米株データ・レポート範囲の拡大
  • 改善の元になるユーザー行動計測基盤の取り組み
  • サービスの安定性と拡張性を考慮した中長期運用のための機能追加、リファクタリング検討

5.4 今回の経験をどう活かして行きたいか

今回のサービスは、あくまで実験的なサービスとして作った思いが強いです。
米株というテーマにおいて、私自身、知見が深いわけでもなく、またすでに大手のサービスが多いので、長期運用と収益化は難しいかなと思っているところから、今後サービスが大きくなっていくことは難しいかなと思います。

しかし、AIとAIエージェントを活用したサービスモデルは、様々な領域において取り入れることが可能と思います。

なので、今のAIとAIエージェントを活用したサービス開発経験をもっと活かして、次は自分が好きな分野と領域のサービスを作って、同じ思いを持つユーザーに価値を届けることができるサービスを出して見たいと思ってます。

6. Appendix

6.1 OpenAIのgpt-3.5-turboとLocal LLMのmixtral 8x7bのq3, q4の米株分析について簡単に比較

6.1.1 比較結果概要

適当ではありますが、少し比較してみた内容を記載します。
(ガッチリしたモデル比較の知見がなく根拠が不足していることはご理解いただけると幸いです)

モデル パラメータ数 量子化(1パラメータごとのbyte) 必要VRAM 実行時間※1 費用予測 ※2 正確度(感覚値) ※3 エラー頻度(感覚値)※4
gpt-3.5-turbo 非公開 - - 24 1~2円 良い 見当たらない
mixtral-8x7b-q3 560億 q3(0.375byte) 20GB 182 0.546円 注意必要 見当たる
mixtral-8x7b-q4 560億 q4(0.5byte) 27GB 529 ※5 1.587円  ※6 良い ※7 稀に見当たる
  • ※1
    • RTX 3090 環境。VRAM24GBのうち23GB利用可能
  • ※2
    • 実行時の費用のみとする。gpt-3.5-turboの場合OpenAIの利用費用、mixtralの場合は消費電力からの電気料金計算とする
    • 推測値 GPU 400w 1秒で0.003円の計算とする、1watt-1hour-0.027円 x 400w / 3600秒 = 1秒あたり0.003円
  • ※3
    • 注意必要は、かなり外れた結果のハルシネーションが発生することを実際に見たことを基準にしてます
    • (ただし、良いでも人の目のチェックが不要という意味ではありません)
  • ※4
    • 推論の間違いでToolのパラメータが間違えて指定されたりなどのエラーです
  • ※5
    • Offload発生なしだとq3の実行結果と近いと予想されます
  • ※6
    • ただ、Offloadの発生によってGPUの消費出力は常にFULLなわけではないので、実際はもっと低い見込みです
  • ※7
    • ただし、実際検証ケースが足りないので、精度の低さやハルシネーションが発生しない保証はできません

6.1.2 OpenAI gpt-3.5-turboの生成結果

精度については、すでに多くのケースで使われた事例があるので、ご存知の方も多いと思います。

最近は、ある程度の高い精度に加えて、早い速度と安い価格で、最善の選択な気もします。

株価分析
Based on the analysis of NVIDIA Corporation (NVDA) stock price movements, here are the key insights and potential entry points:

1. Trend Analysis:
   - The stock price has shown a mix of bullish and bearish movements over the analyzed period.
   - There was a significant increase in price from June 12 to June 14, followed by a decrease until June 20.
   - The stock price has been fluctuating within a certain range, indicating consolidation.

2. Support and Resistance Levels:
   - Key support levels can be identified around $118.00, $120.00, and $122.00 based on historical price movements.
   - Key resistance levels can be identified around $126.00, $128.00, and $130.00.

3. Entry Points:
   - Potential entry points for investors looking to buy the stock could be around $120.00 and $122.00, considering the historical support levels.
   - Investors may also consider waiting for a breakout above the $126.00 resistance level for a bullish entry opportunity.

4. Price Targets:
   - The price targets for NVDA stock could be set at $128.00 and $130.00 based on the identified resistance levels.
   - If the stock breaks above $130.00, it could indicate a further bullish trend with potential for higher price targets.

Overall, investors should closely monitor the support and resistance levels mentioned above and consider their risk tolerance before making any investment decisions in NVIDIA Corporation (NVDA) stock.
ニュース分析
Based on the latest news surrounding NVIDIA Corporation (NVDA), here are some key insights:

1. Stock Funds Slipped in Second Quarter, but Don’t Blame Tech - The Wall Street Journal reports on the performance of stock funds in the second quarter and mentions NVIDIA Corporation (NVDA) in relation to tech sector performance.
   Source: [Read more](https://finance.yahoo.com/m/ad849bac-80f2-3a75-b117-051c568c8591/stock-funds-slipped-in-second.html)

2. Better Megacap Stock: Nvidia vs. Microsoft - Motley Fool compares the performance of NVIDIA Corporation (NVDA) with Microsoft, discussing investment prospects for these megacap stocks.
   Source: [Read more](https://finance.yahoo.com/m/ff4b3f38-eb47-3357-91e3-614e9eea8267/better-megacap-stock%3A-nvidia.html)

3. Nvidia and Broadcom Announced 10-for-1 Stock Splits. This Nasdaq-100 Stock Is Most Likely to Split Next. - Motley Fool discusses the recent stock split announcements by NVIDIA Corporation (NVDA) and Broadcom, speculating on potential future stock splits in the Nasdaq-100.
   Source: [Read more](https://finance.yahoo.com/m/a26f62eb-206e-3eb1-aac9-cf6d7d251419/nvidia-and-broadcom-announced.html)

4. 1 Phenomenal Stock That Could Join Microsoft, Apple, Nvidia, Alphabet, Amazon, and Meta in the $1 Trillion Club - Motley Fool highlights NVIDIA Corporation (NVDA) as a potential candidate to join the $1 trillion market cap club along with other tech giants.
   Source: [Read more](https://finance.yahoo.com/m/dd289b4f-873f-3c93-aa4d-91531161bc5e/1-phenomenal-stock-that-could.html)

These news articles provide a mix of comparative analysis, stock split announcements, and future growth potential for NVIDIA Corporation (NVDA). Investors and analysts are closely monitoring the company's performance and market positioning in the tech sector.
財務分析
Here is an overview of NVIDIA Corporation (NVDA)'s financial health and performance based on the gathered data:

Revenue:
- Total Revenue has shown consistent growth over the analyzed period, with significant increases year over year.
- Gross Profit margins have also increased, indicating efficient revenue generation.

Earnings:
- Net Income has experienced substantial growth, reflecting the company's profitability and operational efficiency.
- Earnings per Share (EPS) have shown a positive trend, demonstrating strong financial performance.

Cash Flow:
- Cash and Cash Equivalents have increased steadily, providing liquidity for potential investments and operations.
- Net Debt has decreased, indicating improved financial stability and reduced financial risk.

Other Key Financial Metrics:
- Operating Income has shown a positive trend, indicating effective cost management and operational performance.
- Total Debt has decreased, reducing the company's financial leverage and improving its financial flexibility.

Insider Trading Data:
- Recent insider transactions indicate a mix of selling and buying activities, suggesting a varied sentiment among insiders.
- The transaction details and ownership changes provide insights into insider sentiment and potential future actions.

Overall, NVIDIA Corporation (NVDA) demonstrates strong financial performance with consistent revenue growth, profitability, and improved financial stability. Investors should consider the positive earnings trajectory, cash flow, and key financial metrics to make informed investment decisions. Additionally, monitoring insider trading data can provide valuable insights into the sentiment and actions of company insiders.
総合分析・レコメンデーション
Based on the comprehensive assessment of NVIDIA Corporation (NVDA) stock, I recommend a BUY rating for investors. The rationale behind this recommendation is supported by the following key factors:

1. Financial Health:
NVIDIA Corporation (NVDA) exhibits strong financial performance with consistent revenue growth, profitability, and improved financial stability. The company has shown significant increases in total revenue, gross profit margins, net income, earnings per share, and cash and cash equivalents. Moreover, the decrease in net debt, total debt, and positive trend in operating income indicate effective cost management and operational performance. These financial metrics highlight the company's robust financial health and potential for further growth.

2. Technical Analysis:
The stock price of NVIDIA Corporation (NVDA) has displayed a mix of bullish and bearish movements over the analyzed period, with key support and resistance levels identified around $118.00, $120.00, $122.00, $126.00, $128.00, and $130.00. Potential entry points for investors lie around $120.00 and $122.00, considering historical support levels, while a breakout above the $126.00 resistance level could provide a bullish entry opportunity. The price targets for the stock are set at $128.00 and $130.00 based on the identified resistance levels. Overall, technical analysis suggests a favorable outlook for the stock.

3. Latest News Insights:
Recent news articles highlight NVIDIA Corporation (NVDA) as a top performer in the tech sector, with comparisons to other megacap stocks like Microsoft, stock split announcements, and growth potential. The positive sentiment surrounding the company in the news articles further supports the BUY recommendation.

In conclusion, considering the strong financial health, technical analysis insights, and positive news sentiments, I recommend investors to BUY NVIDIA Corporation (NVDA) stock. It presents a promising investment opportunity with the potential for growth and profitability in the future. Investors should closely monitor the stock's performance and market positioning to capitalize on the potential upside.

6.1.3 Local LLMのmixtral 8x7b q3の生成結果

Geforce RTX 3090のVRAM 24GBでMemory OffLoadがなく実行できるギリギリの高性能モデルとなります。
感覚値ではありますが、q4より下の量子化は、かなりの精度の劣化が感じられます。(実際に、ハルシネーションやcrewAIの実行で間違った判断をしたりすることが、稀ではありますが見られます)

しかし、一般の人が手に入れられるGPU1個で、これだけの推論が可能ということは、また驚きのポイントではあります。

株価分析
Based on the provided historical stock price data for this company, the market reached its peak around July 3, 2024, with a closing price of 128.279999. The period between June 14 and July 3 saw downward trends in high prices while maintaining significant volatility, particularly near June 24 and June 30 when trading volumes were significantly higher than other days.
ニュース分析
Based on my analysis of various financial news articles and expert opinions, I would estimate NVIDIA Corporation's stock price prediction for 2023 to be in the range of $350-$400 per share, assuming conservative growth and effective management of potential supply chain risks. However, it is important to note that stock prices are subject to significant fluctuation and should be considered as a rough guide rather than a precise prediction.
財務分析
Balance Sheet Analysis:

1. Share Issued: Nvidia has steadily increased its issued shares from 24,640,000,000 in 2018 to 38,600,000,000 in 2021. This could be due to various reasons such as stock offerings, dividend reinvestments, or acquisitions. It is essential to look at other financial statements to understand the primary reason for this increase.
2. Net Debt: Nvidia's net debt decreased from $7,564,000,000 in 2019 to $6,116,000,000 in 2020 but then increased slightly to $8,232,000,000 in 2021. This suggests that Nvidia has been managing its debt relatively well but may need to focus on reducing it further in the future.
3. Cash and Cash Equivalents: Nvidia had $7,280,000,000 in cash and cash equivalents in 2018, which increased significantly to $45,429,000,000 by 2021. This indicates that the company has been successful in generating substantial liquidity.
4. Total Debt: Nvidia's total debt decreased between 2019 and 2020 but then increased slightly in 2021. The decrease from $12,031,000,000 in 2019 to $7,597,000,000 in 2020 shows the company managed its debt well during the pandemic, but a renewed focus on paying down debt is essential in light of the increase to $8,232,000,000 in 2021.

Insider Transactions Analysis:

1. Trends in Insider Selling and Buying: Upon analyzing Nvidia's insider transactions, we can observe a mixed picture with some insiders buying shares while others sell. However, overall insider selling activity appears more frequent than buying. It is essential to keep monitoring these trends to understand whether insiders are confident about the company's future or anticipate potential challenges ahead.
2. Large Transactions: Some significant insider sales occurred in 2023, with executives like Jensen Huang (CEO) selling millions of dollars worth of shares. This could be due to various factors such as diversifying personal assets or taking profits on vested shares, but it is still noteworthy for investors and should be kept under observation.
3. Increase in Ownership: On the other hand, there were some instances where insiders increased their ownership stakes in Nvidia. This could indicate confidence in the company's future prospects and potential for growth. For instance, an officer named Robert A. Burgess increased his stake in Nvidia by purchasing shares worth $1,549,039 in 2023.

In conclusion, while Nvidia's balance sheet appears relatively strong, there are some areas of concern such as rising debt levels and insiders selling shares. Monitoring these trends going forward will be crucial for assessing Nvidia's future performance and identifying potential risks or opportunities.
総合分析・レコメンデーション
Based on my analysis, I would recommend a cautious BUY-OR-HOLD stance on Nvidia's stock. Here are the key factors supporting this recommendation:

1. Financial Health: Nvidia has significantly increased its cash reserves and has maintained reasonable control over its net debt levels, which indicates overall financial strength. The company also decreased its total debt between 2019 and 2020, although it saw a slight increase in 2021, necessitating continued attention to debt management.

2. Insider Transactions: While some insiders are selling shares, others have been increasing their ownership stakes in Nvidia. This mixed trend calls for monitoring potential shifts in insider confidence and the company's future performance. The significant insider sales in 2023 are concerning; however, they can be attributed to various factors and should not be considered as definitive signals of pessimism toward the stock.

3. Market Conditions: Given that Nvidia reached its peak around July 3, 2024, a cautious approach would be advisable in light of recent downward trends and significant volatility in the market. Moreover, the trading volume spikes on June 24 and June 30 indicate heightened investor interest, potentially due to expectations surrounding the company's performance or market reactions.

Considering these factors and the estimated stock price prediction of $350-$400 per share in 2023, potential investors may find entry points that balance the rewards and risks associated with investing in Nvidia stock. Existing investors might consider holding onto their shares for the time being while staying vigilant about ongoing trends in the company's financial health, insider behavior, and market conditions. This recommendation aligns with a BUY-OR-HOLD stance to ensure that returns are maximized while potential risks are minimized during periods of uncertainty and transition in Nvidia's stock price.

6.1.4 Local LLMのmixtral 8x7b q4(標準)の生成結果

q4の量子化が、精度と軽量のバランスが良く取れた元の感じられます。
q3に比べて精度が上がって、もう少しで実用も検討できるレベルと感じました。

ただ、計算上27GBのVRAMが必要となり、Nvidia RTX 3090 24GBの1枚ではMemory Off Loadが発生して、実行速度がかなり落ちますので、それなりのマシンパワーが求められるようになります。

株価分析
Based on the given data, here are some insights:

1. The data seems to be sorted by timestamp, with two numeric columns followed by a volume column, and then two more numeric columns. It is possible that this represents stock prices (first two columns) and volumes (third column), along with additional features (last two columns).
2. There are no explicit timestamps in the given data, so I cannot provide temporal context or trends beyond what's within the data itself.
3. The minimum price is approximately 118.04, which occurs on June 24, 2024, and the maximum price is around 140.76, which happens on June 20, 2024. This indicates a considerable range of prices within the given time period.
4. There is one significant increase in price from approximately 129.61 to 139.80 (June 17, 2024 - June 20, 2024), which might be of interest for an investor or analyst. Similarly, there are notable drops in price from around 136.33 to 130.78 and then to approximately 126.5 (June 18, 2024 - June 21, 2024).
5. The minimum volume is roughly 0, and the maximum volume reaches over 655,000 (occurring on June 21, 2024), suggesting that there was a substantial increase in trading activity during that time.
6. To provide more context or perform further analysis, additional information such as the name of the stock, the industry it belongs to, and other market conditions would be helpful. Additionally, a larger dataset, especially one that includes timestamps, would allow for more comprehensive insights.
ニュース分析
Based on the analysis of the provided data, here are some insights regarding the mentioned stock tickers:

1. Nvidia (NVDA): There has been a recent announcement about Nvidia and Broadcom that might have caused a shift in the market sentiment. Given Nvidia's growth potential in sectors like AI, autonomous vehicles, and data centers, it could still be an attractive investment opportunity. However, investors should remain cautious and monitor any further updates regarding this partnership or other news related to Nvidia.

2. MercadoLibre (MELI): With the growing e-commerce industry in Latin America and MercadoLibre's leading position, it is a stock that could provide significant returns for investors. Although there might be regional challenges or competition, its solid financial performance and market share make MELI an attractive long-term investment option.

3. SMCI (SMCI): This stock has shown a considerable increase in price, possibly due to some favorable news or earnings report. While the short-term outlook appears promising, potential investors should be aware that smaller tech companies like SMCI may have higher volatility and risks compared to established players in the market.

4. Microsoft (MSFT), Alphabet (GOOG), Amazon (AMZN), and Meta Platforms (FB): These large-cap tech stocks continue to demonstrate solid growth and are likely to maintain their dominant positions within their respective markets. Their vast financial resources, innovative product offerings, and robust business models position them well for further expansion in the foreseeable future.

5. Intel (INTC) and Advanced Micro Devices (AMD): These companies operate in a highly competitive landscape with Nvidia being one of their main rivals. Investors should analyze each company's strengths, weaknesses, financial performance, and strategic initiatives before making any investment decisions.

In conclusion, investors must consider the overall market trends, risks, and specific growth drivers for each stock mentioned above before committing to a position. It is essential to conduct further research and analysis and possibly consult with financial professionals before making any significant investment choices.
財務分析
1. Based on the balance sheet data of NVIDIA Corporation (NVDA), we can observe the following trends and values for the latest period (2023-01-31):
   - Total Revenue: 60,922,000,000
   - Gross Profit: 17,475,000,000
   - Selling General and Administration expenses: 24,400,000,000
   - Net Debt: 7,564,000,000
   - Total Debt: 12,031,000,000

2. There have been several insider transactions for NVIDIA in the past few months. For instance (most recent first):
   - On 2024-03-07, an insider purchased 50,000 shares
   - On 2024-03-02, an insider sold 116,176 shares
   - On 2024-03-02, an insider sold 9,144 shares, among other transactions. It is essential to analyze this information to understand the company's insider behavior better.

Please note that the data provided was only up to a certain date, and further research might be needed for more up-to-date insights.
総合分析・レコメンデーション
Based on my analysis of NVIDIA Corporation (NVDA), I would recommend a BUY-OR-HOLD position for the following reasons. The company has displayed strong Total Revenue of 60,922,000,000 and Gross Profit of 17,475,000,000 in its latest balance sheet data (2023-01-31), indicating solid financial performance. Additionally, the Net Debt is relatively low at 7,564,000,000, and Total Debt amounts to 12,031,000,000, which are both manageable for a large corporation like NVIDIA.

Insider transactions suggest a positive outlook as well, with recent insider purchases (2024-03-07) of 50,000 shares, indicating confidence in the company's future prospects. However, there have been some recent sales, but it is essential to consider that these may be part of diversification strategies or other non-bearish factors.

Regarding market context, a recent announcement about NVIDIA and Broadcom has potentially impacted investor sentiment; however, the company still has significant growth potential in AI, autonomous vehicles, and data centers. Therefore, it is an attractive investment opportunity with cautious monitoring of any further updates related to this partnership or other news affecting NVIDIA.

To maximize returns, consider dollar-cost averaging or positioning stop losses while staying informed about industry trends and company-specific news. Always consult with financial professionals before making any significant investment choices, as the decision ultimately depends on your personal risk tolerance, time horizon, and investment goals.

6.1.5 株の分析においてLocal LLMからgpt-3.5-turboに変更した経緯について

本サービスで、最初はLocal LLMのみのサービス構成をしようと思っていましたが、gpt-3.5-turboと比較してみて、精度・時間・費用面でgpt-3.5-turboが最適とおもい、株のデータ分析はこちらにしています。

ただし、閉鎖性を担保したい場合や、もっと処理するデータ量が増えると、改めてLocal LLMの検討も選択肢としてありだと今も考えています。

17
8
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
8