Skip to content
LAST GUARD
Donate

Personal API and exports

API

Personal API

Get your own portfolios, stats, P&L positions, watchlists, cards and charts into a script, a spreadsheet or another app. Make a key (signed in with Discord), then send it with every request:

Authorization: Bearer lgf_…

X-API-Key: lgf_… works too. For spreadsheets, which can't send headers, add key=lgf_… to the address (it can end up in browser history and logs, so use a key just for that). Answers are JSON unless noted; errors are { error } with a 4xx status, plus choices when a name didn't match. Prices are delayed, as on the site.

  • GET /api/v1/me
    /api/v1/me
    Whose key it is, what you've saved, and your limits. Use it to check a key works.
  • GET /api/v1/portfolios
    /api/v1/portfolios
    Every portfolio with its totals at the latest prices: value, cost, P&L, today's change, realized gains.
  • GET /api/v1/portfolios/<name or number>
    /api/v1/portfolios/1
    One portfolio: totals; every holding with value, weight, today's change and P&L; weight by sector; realized gains (with each sale's purchase date when recorded); earnings and ex-dividend dates in the next 30 days.
    format=csv for the holdings as CSV
  • GET /api/v1/portfolios/<name or number>/performance
    /api/v1/portfolios/1/performance
    The past year against SPY, as on the Portfolio page: your record (from each holding's opened date, sales counted until sold, time-weighted) or today's mix. Return, volatility, beta, max drawdown, Sharpe ratio, best and worst day, and the daily series.
    view = record (default) or mix; format=csv for the daily series
  • GET /api/v1/pnl
    /api/v1/pnl
    Your saved P&L positions valued now: strategy, cost to open, model value, P&L.
  • GET /api/v1/pnl/<symbol>
    /api/v1/pnl/TSLA
    One P&L position with its legs (strikes, expiries, prices) and value now.
  • GET /api/v1/watchlists
    /api/v1/watchlists
    Your watchlists and their symbols.
  • GET /api/v1/watchlists/<name or number>
    /api/v1/watchlists/1
    One watchlist with each symbol's latest price, change, volume, market cap, P/E and 52-week range.
    format=csv
  • GET /api/v1/cards/<kind>
    /api/v1/cards/portfolio?q=1
    The PNG card, as in the Share menu and the bot.
    kind = portfolio, performance, pnl, positions or watchlist; q = name or symbol; hide=1 for percentages only
  • GET /api/v1/charts
    /api/v1/charts
    Your chart setups (type, indicators, lengths, colours), the settings your charts start from, and which symbols have drawings.
  • GET /api/v1/charts/<symbol>
    /api/v1/charts/NVDA
    Your drawings on a symbol: kind, points (unix seconds and price), style and notes.
  • GET /api/v1/charts/<symbol>/image
    /api/v1/charts/NVDA/image?range=6M
    Your chart as a PNG: your chart type, overlays, colours, drawings and volume profile, with up to five indicator panes (RSI, MACD…) underneath.
    range = 1D … MAX (default 1Y); interval; setup = a setup's name, or default; drawings=0 to leave yours off
  • GET /api/v1/calendar.ics
    /api/v1/calendar.ics?key=lgf_…
    A calendar of the next earnings report and ex-dividend date of every stock in your portfolios and watchlists. Subscribe to it from Google Calendar (Other calendars, From URL), Outlook or Apple Calendar and it stays up to date.
    key = your key, in the URL (calendar apps can't send headers)
Python
import requests

KEY = "lgf_…"  # from Your API Keys
api = requests.Session()
api.headers["Authorization"] = f"Bearer {KEY}"

for p in api.get("https://finance.lastguardbot.com/api/v1/portfolios").json()["portfolios"]:
    print(p["name"], p["value"], f'{p["day_pct"]:+.2f}%')

png = api.get("https://finance.lastguardbot.com/api/v1/charts/NVDA/image",
              params={"range": "6M", "setup": "default"}).content
open("nvda.png", "wb").write(png)
curl and Google Sheets
curl -H "Authorization: Bearer lgf_…" \
  https://finance.lastguardbot.com/api/v1/portfolios/1

curl -H "Authorization: Bearer lgf_…" -o card.png \
  "https://finance.lastguardbot.com/api/v1/cards/portfolio?q=1&hide=1"

=IMPORTDATA("https://finance.lastguardbot.com/api/v1/portfolios/1?format=csv&key=lgf_…")

Only your own saved data is available. Market data for other symbols (quotes, charts, search, news) is served to this site's own pages and isn't part of the API.

API

Your API Keys

Checking sign-in…

BOT

Use It in Discord

Your portfolio

  • lgf portfolioYour portfolios, P&L positions and watchlists, with today's values
  • lgf portfolio generate "My portfolio"Post a portfolio card (add --private for % only, --dm for your DMs)
  • lgf portfolio add AAPL 10 182.50Add shares (current price if you leave the cost off; to <name> for another portfolio)
  • lgf portfolio sell AAPL 5 at 190Sell shares; the sale goes into Realized Gains
  • lgf portfolio performanceYour record against SPY over the past year, as a card
  • lgf portfolio smartmoneyWhat House members, insiders and famous investors did in your holdings
  • lgf portfolio eventsEarnings and ex-dividend dates for your holdings
  • lgf pnl TSLAA saved P&L position with its payoff chart (lgf pnl for all of them)
  • lgf watchlist cardYour watchlist as a card; add a name for a list saved here
  • lgf chart NVDA 6MYour chart as an image: your chart type, indicators and drawings (add a setup's name, or --clean)
  • lgf leaderboardThis server's portfolio leaderboard (opt in from a portfolio's Share menu)

Alerts

  • lgf alertsettingsHow your alerts, daily card, move alerts, followed members and webhooks reach you

Who's trading

  • lgf smartmoney NVDAHouse members, insiders and famous investors in one stock
  • lgf insidersInsider buying across the market: cluster buys and the largest buys
  • lgf funds buffettA famous investor's holdings from their 13F; lgf funds NVDA shows which of them hold a stock

For server admins

  • lgf congress feed #channelPost every new House trading report
  • lgf insiders feed #channel 250kPost insider buys of $250k or more as they're filed
  • lgf congress notices #channelPost when a House trading report is replaced or taken down on house.gov
  • lgf alertchannel #channelWhere members can have their own alerts posted

Use your server's prefix in front (for example =lgf portfolio).

API

Exports on the Site

WhatWhereHow
Chart imagesAny price chart: right-click, ExportSave a PNG, copy the image, or send it to your Discord DMs or a server's alerts channel, with your drawings and indicators on it.
Chart links and dataPrice chart: right-click, ExportA link that opens the exact chart; the visible range or every loaded bar as CSV.
Portfolio cardsPortfolio: ShareAn image of a portfolio, with amounts or percentages only, downloaded or posted to Discord. You can also get one in your DMs every trading day.
Portfolio statsPortfolioHoldings and realized gains as CSV; holdings import from a broker's CSV.
P&L and watchlist cardsP&L calculator or Watchlist: ShareCard images, downloaded or posted to Discord. Watchlists also export as CSV.
TablesFinancials, options chains, the screener, backtestsDownload what's on screen as CSV.
HELP

Keyboard shortcuts & functions

Anywhere

/ or Ctrl K
Focus the command line
?
Show this help
Esc
Close menus and dialogs

Command line

AAPL
Open a security
WEI
Open a function
NVDA GP
Ticker + function
↑ ↓ Enter
Pick a suggestion

Charts (click the chart first)

Right-click / Shift F10
Alerts, drawings, measure, export
Alt A
Alert at the cursor price
Alt H
Horizontal line
Alt T
Trend line
Alt F
Fibonacci retracement
Alt V
Vertical line
Del
Delete the selected drawing
Ctrl Z
Undo the last drawing change
Alt R
Reset to the chosen range
Esc
Stop drawing / deselect
Scroll · drag
Zoom · pan

Function codes

  • WEIWorld equity indices & cross-asset
  • BRIEFMarket brief for today
  • PREPGame plan: the next session for your stocks
  • RECAPEvening recap: the session just finished
  • WEEKWeek in review: the trading week on one page
  • WCLKWorld markets clock
  • EXCHExchanges: most traded stocks by sector
  • HMAPMarket heatmap
  • MOSTMovers & most active
  • GAPGap scanner: opening gaps and pre-/after-market movers (S&P 500)
  • UVOLUnusual volume: heavy buying and selling (S&P 500)
  • SCRNStock screener
  • TECHTechnical signals (S&P 500)
  • RSRelative strength ratings (S&P 500, MidCap 400, Nasdaq-100)
  • GRPIndustry group rankings (S&P 500, MidCap 400, Nasdaq-100)
  • SETUPSetups scanner: pullbacks, tight ranges and leaders (S&P 500, MidCap 400, Nasdaq-100)
  • TRNDTrend line scanner: on support, at resistance, breakouts and triangles (S&P 500, MidCap 400, Nasdaq-100)
  • CONFSignal confluence: where bullish or bearish signals line up (S&P 500, MidCap 400, Nasdaq-100)
  • REGMMarket regime: distribution days and follow-through
  • RISKRisk appetite: cross-asset ratios, risk-on or risk-off
  • ECALEarnings calendar
  • EAEarnings season scorecard
  • DRFTPost-earnings drift: gaps that hold or fade (S&P 500, MidCap 400, Nasdaq-100)
  • EXPMOptions vs reality: the move priced before each report against the move that came
  • ECOEconomic calendar
  • ECSTUS economic statistics
  • IPOIPO calendar
  • DVDDividends & splits
  • CURVTreasury yield curve
  • WIRPFed rate expectations (futures)
  • CBCentral bank policy rates
  • FXCFX cross rates & pairs
  • CMDTYCommodity futures
  • ATLASCommodity atlas: where oil, gas, grains, softs and metals are produced and shipped, and the chokepoints on the way
  • CRYPCrypto board
  • COTFutures positioning: where speculators stand (CFTC Commitments of Traders)
  • SECTSector & industry performance
  • RRGSector rotation
  • CORRCorrelation matrix
  • BRDHBreadth of the S&P 500
  • FGFear & greed gauge
  • VOLVolatility (VIX term structure)
  • CONGCongress trades (House & Senate)
  • CNBCongress notice board (changed & removed reports)
  • INSBInsider buying across the market (SEC Form 4)
  • SIShort interest: the most shorted stocks and squeeze watch
  • SVOLShort volume: daily short sale ratio vs its own average (FINRA)
  • 13FInvestor holdings from 13F filings (Buffett, Burry, Ackman…)
  • SMRTSmart money overlap: Congress, insiders and famous funds buying the same stocks
  • UOAUnusual options activity
  • GEXGamma exposure screener: dealer gamma, flip and walls across the most traded options
  • IVSOptions rich or cheap: implied vs realized volatility, put skew and term structure across the most traded options
  • UPDNAnalyst upgrades & downgrades
  • REVEstimate revisions: who analysts are raising and cutting EPS for
  • TOPNews wire (top stories)
  • GPPrice chart
  • DESDescription & key stats
  • ANRAnalyst ratings & targets
  • CNCompany news
  • SEASSeasonality
  • FAFinancial statements
  • EEEarnings & estimates
  • FILSEC filings: reports, 8-K events and ownership
  • FUNDFund holdings & profile
  • DCFValuation (discounted cash flow)
  • RVRelative value vs peers
  • HDSHolders (institutions & funds)
  • INSDInsider activity
  • OMONOptions chain, IV & gamma
  • ODDSOdds from option prices
  • PNLP&L calculator & scenarios
  • ANLGAnalogs: look-alikes from its own history or ~900 stocks'
  • RESResearch reports (PDF)
  • DESKMy desk: your stocks, trades, screens and notes
  • WATCHWatchlists
  • PORTPortfolio tracker
  • SIZETrade planner: position size, stop and targets
  • JRNLTrade journal: win rate, R, expectancy and equity curve
  • BLNDBlind chart practice: call a hidden chart, then see what happened
  • PAPRBullpen: trade the market with your Discord server's coins, on your own or as a server fund
  • NOTEMy notes on stocks
  • COMPCompare performance
  • MULTMulti-chart layout
  • STRSStress test through past crises
  • BTBacktest a strategy
  • RLIBResearch library (Market Intelligence Reports)
  • RCMPCompare companies' research reports
  • RTRKResearch track record (how reports' calls have done)
  • ALRTAlerts & chart drawings
  • APIPersonal API & exports
  • LOGWhat's new (changelog)