第 25 章

要自己申請的金鑰

不填任何金鑰也能完整記帳。下面這幾項是讓某些功能更好用的選填項目,都填在 管理 → 設定 → 資料來源。雲端備份用的 Google 連結不用自己申請,安裝版已經內建(第 21 章)。

項目用在哪裡要申請嗎費用誰填
Tiingo 的金鑰美股報價、日 K、配息與分割(比 Yahoo 穩定,商用模式也能用)免費註冊免費方案夠用每個帳號自己
AI 摘要的金鑰個股資訊的 AI 摘要寫成一段話(第 18 章)三家選一家申請;本機模型不用按用量付費每個帳號自己
SEC 聯絡信箱美股的本益比、殖利率、淨值比不用,填自己的 email免費每個帳號自己
Open Exchange Rates 的 app_id商用模式「今天的匯率」每小時更新免費註冊免費方案夠用只有擁有者

Tiingo(美股行情)

填了以後,美股的報價、日 K、配息與分割先從 Tiingo 抓;沒填的話照舊用 Yahoo Finance。

  1. 到 https://www.tiingo.com,按右上角的 「Sign Up」,填 email、使用者名稱、密碼,照畫面完成註冊(免費方案不用信用卡)。

    Tiingo 的註冊頁
    Tiingo 的註冊頁
  2. 登入後到 https://www.tiingo.com/account/api/token(左邊選單的 API → Token;瀏覽器翻成中文時是「令牌」),按 token 右邊的複製按鈕,複製那一串 40 個英文字母和數字。不小心外洩了,按同一頁的 「Rotate API Token」 換一把新的,舊的馬上失效。

    Tiingo 的 API Token 頁
    Tiingo 的 API Token 頁
  3. 回到 STOCKings 的 設定 → 資料來源,貼到「Tiingo 的金鑰」,按「儲存變更」。

    貼在「Tiingo 的金鑰」
    貼在「Tiingo 的金鑰」
  4. 存好後欄位顯示「已設定(…末四碼)」,展開下面的「來源與資料」,表裡「即時報價(美股)」「日 K 線(美股)」的來源變成 Tiingo。

    已設定,只顯示末四碼
    已設定,只顯示末四碼
    美股的來源變成 Tiingo
    美股的來源變成 Tiingo

AI 摘要:Anthropic Claude、OpenAI、Google Gemini

三家選一家就好。ChatGPT、Claude、Gemini 的訂閱方案不包含 API 額度,要另外到下面的網站開 API 金鑰;Anthropic 與 OpenAI 按用量付費(Anthropic 沒加值前是有用量限制的試用方案 Evaluation access),Google Gemini 有免費方案。STOCKings 只送公開的市場資料,不送你的持股與交易。

Anthropic Claude

  1. 到 https://platform.claude.com 註冊、登入。這是 Claude Console,跟 claude.ai 的帳號與付費是分開的(Claude Pro、Max 訂閱不含 API 額度)。 第一次會出現 「Buy usage credits」:選金額(US$5 就夠試用)按 「Buy credits」;想先不付可以按 「Skip for now」,之後到 「Billing」 再加值。 下面的 「Auto-reload」 預設是開的,餘額低於設定的金額就會自動刷卡,不想自動扣款就把它關掉。

    Claude Console 的加值畫面(姓名已遮住)
    Claude Console 的加值畫面(姓名已遮住)
  2. 左邊選單按 「API keys」(或直接開 https://platform.claude.com/settings/keys),再按右上角的 「Create key」。

    Claude Console 的 API keys 頁
    Claude Console 的 API keys 頁
  3. 跳出「With identity federation…」的說明時,按 「Continue with an API key」(identity federation 是給雲端、CI 用的,STOCKings 要的是 API 金鑰)。 取個名字(例如 STOCKings),複製開頭是 sk-ant- 的金鑰。它只顯示這一次。

    選 Continue with an API key
    選 Continue with an API key

OpenAI

  1. 到 https://platform.openai.com 登入(API 的額度跟 ChatGPT 訂閱分開)。左邊選單按 「Billing」,再按 「Add payment details」 填信用卡、加值。

    OpenAI Platform 的 Billing
    OpenAI Platform 的 Billing
  2. 左邊選單按 「API keys」(或直接開 https://platform.openai.com/api-keys),再按右上角的 「Create new secret key」。

    OpenAI Platform 的 API keys 頁
    OpenAI Platform 的 API keys 頁
  3. 取個名字(例如 STOCKings),「Project」 選你的專案(通常是 Default project), 「有效期限」(Expiration)選多久後失效:過期後 AI 摘要會改回條列重點,要再建一把新的貼回 STOCKings。其他維持預設,按 「Create secret key」。

    建立金鑰:名字、專案、有效期限
    建立金鑰:名字、專案、有效期限
  4. 按 「Copy」 複製開頭是 sk- 的金鑰(現在多半是 sk-proj-),它只顯示這一次,再按 「Done」。

    複製金鑰(金鑰與帳號已遮住)
    複製金鑰(金鑰與帳號已遮住)

Google Gemini

  1. 到 https://aistudio.google.com/apikey,用 Google 帳號登入、同意服務條款。左邊選單是 「API Keys」,按右上角的 「Create API key」。 免費方案送出的內容可能被 Google 拿去改進產品(這裡只送公開的市場資料)。

    Google AI Studio 的 API Keys 頁
    Google AI Studio 的 API Keys 頁
  2. 名字可以改成 STOCKings,專案用預設的 「Default Gemini Project」 就好,按 「Create key」。

    建立金鑰:名字與專案
    建立金鑰:名字與專案
  3. 在 「API key details」 按 「Copy key」 複製金鑰(開頭可能是 AQ. 或 AIza)。 Gemini 的金鑰之後回到 API Keys 頁還看得到,不像 Anthropic、OpenAI 只顯示一次;外洩了就在這裡按 「Delete key」 刪掉再建一把。

    複製金鑰(金鑰與專案編號已遮住)
    複製金鑰(金鑰與專案編號已遮住)

填進 STOCKings

  1. 設定 → 資料來源 的「AI 摘要用哪一家」選你申請的那一家,把金鑰貼到下面的「API 金鑰」,按「儲存變更」。

    選服務、貼上 API 金鑰
    選服務、貼上 API 金鑰
  2. 模型可以留白(用預設的),或按「查詢可用的模型」從清單挑。到任一檔股票的「個股資訊 → AI 摘要」就能用了。

本機模型(Ollama、LM Studio)不用金鑰:選「本機模型/OpenAI 相容」,網址填 http://localhost:11434/v1(Ollama)或http://localhost:1234/v1(LM Studio),再按「查詢可用的模型」挑一個。免費、資料不離開電腦,但電腦要夠力。

SEC 聯絡信箱(美股本益比)

不用申請。美國 SEC 規定查詢財報資料要附上查詢者的 email,STOCKings 只會把它放在送給 SEC 的請求裡。

  1. 設定 → 資料來源 的「SEC 聯絡信箱」填你自己的 email,按「儲存變更」。

    填自己的 email
    填自己的 email
  2. 美股的「個股分析 → 基本面」副圖就會顯示本益比、殖利率、淨值比。

Open Exchange Rates(只有商用模式、擁有者)

一般使用不用填。只有商用模式(部署的人開的)才會用到:填了,「今天的匯率」每小時更新;沒填就用每天更新的官方來源。匯率對每個人都一樣,所以整台電腦一份,只有擁有者能填。

  1. 到 https://openexchangerates.org/signup/free,左邊要是 The Forever Free Plan(不用信用卡,每月 1,000 次)。 填 email、密碼、姓名(Website 可以空著),勾「我不是機器人」與同意條款,按 「Continue」。

    Open Exchange Rates 免費方案註冊
    Open Exchange Rates 免費方案註冊
  2. 到信箱收確認信、點裡面的連結(Dashboard 的 Next steps 第 1 項;沒收到可以按 「Re-send verification email」)。

    註冊後的 Dashboard
    註冊後的 Dashboard
  3. 左邊選單按 「App IDs」(或直接開 https://openexchangerates.org/account/app-ids),按 App ID 右邊的複製圖示。 外洩了可以按 「Generate New App ID」 建一個新的,再按舊的那一列的紅色叉叉停用。

    Open Exchange Rates 的 App IDs 頁(App ID 已遮住)
    Open Exchange Rates 的 App IDs 頁(App ID 已遮住)
  4. 擁有者在 設定 → 資料來源 貼到「Open Exchange Rates 的 app_id」,按「儲存變更」。STOCKings 一小時最多查一次。

    擁有者才看得到的輸入欄
    擁有者才看得到的輸入欄
Chapter 25

Keys you apply for yourself

You can keep complete records without any key. The items below are optional extras that make some features better; they all go in Settings → Data sources. The Google link for cloud backup needs no key of your own: the installed version has it built in (chapter 21).

ItemUsed forApply?CostWho
Tiingo keyUS quotes, daily candles, dividends and splits (steadier than Yahoo, also works in commercial mode)Free sign-upFree plan is enoughEach account
AI summary keyAI summaries written as a paragraph (chapter 18)Pick one of three; local models need nonePay as you goEach account
SEC contact emailUS P/E, yield and price-to-bookNo, use your own emailFreeEach account
Open Exchange Rates app_idHourly “today’s rate” in commercial modeFree sign-upFree plan is enoughOwner only

Tiingo (US market data)

With it, US quotes, daily candles, dividends and splits come from Tiingo first; without it, Yahoo Finance is used as before.

  1. Go to https://www.tiingo.com, click “Sign Up” at the top right, enter an email, username and password, and follow the steps (no credit card for the free plan).

    Tiingo sign-up
    Tiingo sign-up
  2. After signing in, open https://www.tiingo.com/account/api/token (API → Token in the left menu) and click the copy button next to the token to copy the 40 letters and digits. If it ever leaks, click “Rotate API Token” on the same page for a new one; the old one stops working at once.

    Tiingo API Token page
    Tiingo API Token page
  3. Back in STOCKings, open Settings → Data sources, paste it into “Tiingo key” and click “Save changes”.

    Paste it into “Tiingo key”
    Paste it into “Tiingo key”
  4. Once saved, the field shows “Set (…last four)”, and after you expand “Where each kind of data comes from” below, “Live quotes (US)” and “Daily candles (US)” now come from Tiingo.

    Saved; only the last four characters are shown
    Saved; only the last four characters are shown
    US data now comes from Tiingo
    US data now comes from Tiingo

AI summaries: Anthropic Claude, OpenAI, Google Gemini

One provider is enough. ChatGPT, Claude and Gemini subscriptions don’t include API credit; create an API key on the sites below. Anthropic and OpenAI are pay as you go (before you add credit, Anthropic gives a limited trial plan called Evaluation access); Google Gemini has a free tier. STOCKings sends only public market data, never your holdings or trades.

Anthropic Claude

  1. Sign up and sign in at https://platform.claude.com. This is the Claude Console; its account and billing are separate from claude.ai (Claude Pro and Max subscriptions don’t include API credit). The first time you see “Buy usage credits”: pick an amount (US$5 is enough to try it) and click “Buy credits”, or click “Skip for now” and add credit later under “Billing”. “Auto-reload” below is on by default and charges your card whenever the balance drops below the amount set; turn it off if you don’t want automatic charges.

    Buying credits in the Claude Console (name covered)
    Buying credits in the Claude Console (name covered)
  2. Click “API keys” in the left menu (or open https://platform.claude.com/settings/keys), then “Create key” at the top right.

    The API keys page in the Claude Console
    The API keys page in the Claude Console
  3. When the “With identity federation…” box appears, click “Continue with an API key” (identity federation is for cloud and CI setups; STOCKings needs an API key). Give the key a name (for example STOCKings) and copy the key starting with sk-ant-. It is shown only once.

    Choosing Continue with an API key
    Choosing Continue with an API key

OpenAI

  1. Sign in at https://platform.openai.com (API credit is separate from a ChatGPT subscription). Click “Billing” in the left menu, then “Add payment details” to add a card and credit.

    OpenAI Platform Billing
    OpenAI Platform Billing
  2. Click “API keys” in the left menu (or open https://platform.openai.com/api-keys), then “Create new secret key” at the top right.

    The API keys page in the OpenAI Platform
    The API keys page in the OpenAI Platform
  3. Give it a name (for example STOCKings), pick your “Project” (usually Default project), and choose when it expires under “Expiration”: after that, AI summaries go back to bullet points until you create a new key and paste it into STOCKings. Leave the rest as is and click “Create secret key”.

    Creating the key: name, project, expiration
    Creating the key: name, project, expiration
  4. Click “Copy” to copy the key starting with sk- (usually sk-proj- now). It is shown only once. Then click “Done”.

    Copying the key (key and account covered)
    Copying the key (key and account covered)

Google Gemini

  1. Open https://aistudio.google.com/apikey, sign in with a Google account and accept the terms. With “API Keys” selected in the left menu, click “Create API key” at the top right. On the free tier, what you send may be used to improve Google’s products (STOCKings sends only public market data).

    The API Keys page in Google AI Studio
    The API Keys page in Google AI Studio
  2. You can rename the key to STOCKings; the default project “Default Gemini Project” is fine. Click “Create key”.

    Creating the key: name and project
    Creating the key: name and project
  3. In “API key details”, click “Copy key” (the key may start with AQ. or AIza). Unlike Anthropic and OpenAI, a Gemini key stays visible on the API Keys page; if it leaks, click “Delete key” there and create a new one.

    Copying the key (key and project number covered)
    Copying the key (key and project number covered)

Entering it in STOCKings

  1. In Settings → Data sources, choose your provider under “AI service for summaries”, paste the key into the API key field below and click “Save changes”.

    Choose the service and paste the API key
    Choose the service and paste the API key
  2. Leave the model blank (the default) or click “List available models” to pick one. Then open any stock’s “Company info → AI summary”.

Local models (Ollama, LM Studio) need no key: choose “Local model / OpenAI-compatible”, enter http://localhost:11434/v1 (Ollama) or http://localhost:1234/v1 (LM Studio) as the address, then click “List available models” and pick one. Free, and the data stays on your computer, but it needs a capable machine.

SEC contact email (US P/E)

Nothing to apply for. The US SEC requires an email address with requests for filings data; STOCKings puts it only in requests sent to the SEC.

  1. In Settings → Data sources, enter your own email under “SEC contact email” and click “Save changes”.

    Enter your own email
    Enter your own email
  2. The “Fundamentals” sub-chart in US stock analysis then shows P/E, yield and price-to-book.

Open Exchange Rates (commercial mode, owner only)

Not needed for normal use. It matters only in commercial mode (set up by whoever deploys the app): with it, “today’s rate” updates hourly; without it, the daily official sources are used. Exchange rates are the same for everyone, so there is one per computer and only the owner can enter it.

  1. Go to https://openexchangerates.org/signup/free; the left side should say The Forever Free Plan (no card, 1,000 requests a month). Enter an email, password and name (Website can stay empty), tick the reCAPTCHA and the terms, and click “Continue”.

    Open Exchange Rates free plan sign-up
    Open Exchange Rates free plan sign-up
  2. Open the confirmation email and click its link (step 1 of Next steps on the Dashboard; “Re-send verification email” if it didn’t arrive).

    The Dashboard after signing up
    The Dashboard after signing up
  3. Click “App IDs” in the left menu (or open https://openexchangerates.org/account/app-ids) and click the copy icon next to the App ID. If it leaks, click “Generate New App ID”, then the red cross on the old row to deactivate it.

    Open Exchange Rates App IDs page (App ID covered)
    Open Exchange Rates App IDs page (App ID covered)
  4. The owner pastes it into “Open Exchange Rates app_id” in Settings → Data sources and clicks “Save changes”. STOCKings checks at most once an hour.

    Only the owner sees this field
    Only the owner sees this field