Wiki

📖 Torn Hub Wiki

Help and documentation for all features – no login required.

📈 Stocks Help & Information
What Is the Stocks Page?

The Stocks page gives you an overview of the Torn stock market and your personal portfolio.

  • All Stocks – a real‑time list of every stock on the Torn exchange, including price, market cap, number of shares, investors, and bonus information.
  • My Portfolio – your own holdings, showing how many shares you own, their current value, average cost, unrealised gain/loss, and bonus progress.

All data is now stored in MySQL – public stock data is cached globally, and your portfolio is cached per user.

How Data Is Collected

All Stocks – this data comes from the public Torn API endpoint /torn/stocks. It does not require any special scopes on your API key – the system uses your own key (or falls back to the admin key) and caches the result for 900 seconds. To prevent multiple simultaneous API calls, the system uses MySQL‑based locking so that only one user triggers a refresh at a time.

My Portfolio – this uses the /user/stocks endpoint and requires the stocks scope on your API key. If your key lacks this scope, you will see a warning and no portfolio data will be shown.

  • Portfolio data is cached per user for 1800 seconds (30 minutes) to reduce API calls.
  • You can manually refresh your portfolio at any time using the Refresh button (60‑second cooldown).
🔑 API Key Requirements – Be Exact

Here is exactly what each feature requires:

Feature Required Scope What Happens If Missing
View All Stocks (public list) none (public endpoint) Works as long as your key is valid (or admin key fallback).
View your portfolio (holdings, value, gain/loss) stocks A warning is shown and the portfolio tab is empty.
View bonus progress and availability stocks Same as above – not available without scope.

Recommended: A key with stocks scope enabled (or a Full Access key) for the best experience.

Need to update your key? Go to Torn API Settings and check the required boxes.

Log in to see whether your current key includes the stocks scope.

💹 Understanding Your Portfolio

The portfolio section shows several important metrics:

  • Shares – how many shares you currently hold.
  • Price – the current market price per share.
  • Value – total value of your holding (shares × price).
  • Avg Cost – the average price you paid per share, calculated from your transaction history.
  • Gain/Loss – your unrealised profit or loss (both in $ and as a percentage). This is computed as (current value − cost basis), where cost basis is your average cost multiplied by the number of shares.
  • Bonus – progress toward your next stock bonus (if any). The bar shows how far you are from the required number of shares, and “Ready” means you can claim the bonus.

The Total Gain/Loss at the top sums up all your holdings’ unrealised gains/losses.

Note: The gain/loss calculation relies on your transaction history, which is provided by the Torn API. If you have shares without any transaction records (e.g., from very old purchases), the average cost will default to the current price, giving a gain of $0 – this is a fallback to avoid misleading numbers.

🔄 Auto‑Refresh & Manual Refresh

Stock prices change every minute. The page offers two ways to keep data fresh:

  • Auto‑refresh – tick the checkbox “🔄 Auto‑refresh (60s)” at the top. The page will then reload automatically every 60 seconds, giving you a near‑live view of the market. The setting is saved in your browser and persists across sessions.
  • Manual refresh – click the Refresh button to force an immediate update. There is a 60‑second cooldown to prevent excessive API calls.

Both methods respect caching and locking – if multiple users are online, only one of them will trigger the actual API call for public stocks.

🔍 Sorting & Filtering

You can organise the tables to your liking:

  • Sorting – click any column header to sort ascending/descending. Your sort preference is saved in your browser’s local storage.
  • Search – use the search box to filter stocks by name or symbol in both tabs.
  • Filters (portfolio) – show only gainers, only losers, or only stocks whose bonus is ready to claim.
  • Filters (All Stocks) – filter by bonus description (e.g., “$50,000,000”) to find stocks with specific rewards.
📊 The Pie Chart

The doughnut chart in your portfolio shows the percentage of your total portfolio value allocated to each stock. It helps you visualise your diversification at a glance. Hover over a slice to see the exact value and percentage.

The chart legend is kept compact – only the stock symbol and percentage are shown – to save space.

🛡️ Privacy & Caching
  • Public stocks are cached globally in MySQL and shared among all users – your API key is not stored for this.
  • Your portfolio is cached per user in MySQL. The data is never shared with other users.
  • Your API key is used only in the current session; it is not permanently stored unless you opt in for background services (which is a separate setting).
  • All caches respect their TTLs; you can clear them using the admin panel if needed.
Still Need Help?