Skip to content

Instantly share code, notes, and snippets.

@ahouts
ahouts / select-most-recent-fee-trade.sql
Created October 31, 2025 15:06
Selecting the most recent fee trade for a portfolio
SELECT id
FROM trades
WHERE portfolio_id = :portfolio_id
AND type = 'fee'
ORDER BY date DESC
LIMIT 1;
@ahouts
ahouts / trades.sql
Created October 31, 2025 15:05
Schema of the trades table
CREATE TABLE portfolio
(
id BIGINT AUTO_INCREMENT PRIMARY KEY
);
CREATE TABLE trades
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
portfolio_id BIGINT NOT NULL,
type VARCHAR(255) NOT NULL,
@ahouts
ahouts / GetMostRecentFeeTrade.java
Created October 31, 2025 15:03
Finding the most recent fee trade for a portfolio
portfolio.trades()
.stream()
.filter(trade -> trade instanceof Fee)
.max(Comparators.comparing(Trade::date));
@ahouts
ahouts / CollectAndRenderProfileSvg-invocation-for-RunAllCalculatePortfolioBalances.sh
Created October 31, 2025 14:54
CollectAndRenderProfileSvg invocation for RunAllCalculatePortfolioBalances
$ qc biw CollectAndRenderProfileSvg QUERY RunAllCalculatePortfolioBalances > RunAllCalculatePortfolioBalances.svg
@ahouts
ahouts / CollectAndRenderProfileSvg-help.sh
Created October 31, 2025 14:50
CollectAndRenderProfileSvg help
$ qc biw Help CollectAndRenderProfileSvg
CollectAndRenderProfileSvg(
@Param(QUERY, BATCH_QUEUE, or POOL) Kind kind,
@NoConcurrentExecution @Param(queue name, query name, session id, or thread pool prefix) String identifier,
@Param(stop recording after this many seconds) int stopNumSeconds,
@Optional(11) @Param(number of samples to record per second) double samplesPerSecond,
@Optional(0) @Param(negative value to disable) int stopWhenAllWorkersIdleFor,
@Optional(0.1) @Param(disable further analysis of traces with less than given % of parent traces) Scalar filterThreshold
): String