用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tools-only/X-Skills --skill track-position命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | track-position |
| description | Track crypto positions with entry prices, current values, and PnL calculations |
| shortcut | tp |
Comprehensive position tracking for cryptocurrency investments with real-time price updates and advanced analytics.
When the user wants to track a crypto position, gather the following information and implement a complete tracking system:
Create a structured database to track positions:
CREATE TABLE IF NOT EXISTS crypto_positions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
symbol VARCHAR(10) NOT NULL,
entry_price DECIMAL(20,8) NOT NULL,
quantity DECIMAL(20,8) NOT NULL,
entry_date TIMESTAMP NOT NULL,
current_price DECIMAL(20,8),
last_updated TIMESTAMP,
exchange VARCHAR(50),
target_price DECIMAL(20,8),
stop_loss DECIMAL(20,8),
status VARCHAR(20) DEFAULT 'open',
notes TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS position_history (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
position_id UUID REFERENCES crypto_positions(id),
price DECIMAL(20,8) NOT NULL,
value DECIMAL(20,8) NOT NULL,
pnl DECIMAL(20,8) NOT NULL,
pnl_percentage DECIMAL(10,4) NOT NULL,
recorded_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_positions_symbol ON crypto_positions(symbol);
CREATE INDEX idx_positions_status ON crypto_positions(status);
CREATE INDEX idx_history_position ON position_history(position_id);
class CryptoPositionTracker {
constructor() {
this.priceFeeds = {
coingecko: 'https://api.coingecko.com/api/v3',
binance: 'https://api.binance.com/api/v3',
coinbase: 'https://api.coinbase.com/v2'
};
}
async trackPosition(positionData) {
const {
symbol,
entryPrice,
quantity,
entryDate,
exchange = 'Unknown',
targetPrice = null,
stopLoss = null,
notes = ''
} = positionData;
// Validate input
this.validatePositionData(positionData);
// Get current price
const currentPrice = await this.getCurrentPrice(symbol);
// Calculate metrics
const metrics = this.calculateMetrics({
entryPrice,
quantity,
currentPrice
});
// Store position
const position = await this.storePosition({
symbol: symbol.toUpperCase(),
entry_price: entryPrice,
quantity,
entry_date: entryDate,
: currentPrice,
exchange,
: targetPrice,
: stopLoss,
notes
});
.(position., currentPrice, metrics);
{
position,
metrics,
: .(position, metrics)
};
}
() {
entryValue = entryPrice * quantity;
currentValue = currentPrice * quantity;
unrealizedPnL = currentValue - entryValue;
pnlPercentage = ((currentValue - entryValue) / entryValue) * ;
{
: (entryValue.()),
: (currentValue.()),
: (unrealizedPnL.()),
: (pnlPercentage.()),
: pnlPercentage,
: .({
entryPrice,
currentPrice,
: position.,
: position.
})
};
}
() {
(!targetPrice || !stopLoss) ;
potentialReward = targetPrice - entryPrice;
potentialRisk = entryPrice - stopLoss;
(potentialRisk === ) ;
((potentialReward / potentialRisk).());
}
() {
analysis = {
: .(metrics),
: .(position, metrics),
: .(position, metrics),
: .(position, metrics)
};
analysis;
}
() {
(metrics. > ) ;
(metrics. > ) ;
(metrics. > -) ;
(metrics. > -) ;
;
}
() {
recommendations = [];
(position. && position. <= position.) {
recommendations.({
: ,
: ,
:
});
}
(position. && position. >= position.) {
recommendations.({
: ,
: ,
:
});
}
(metrics. > ) {
recommendations.({
: ,
: ,
:
});
}
(metrics. < - && !position.) {
recommendations.({
: ,
: ,
:
});
}
recommendations;
}
() {
{
prices = .([
.(symbol),
.(symbol)
]);
prices.( sum + price, ) / prices.;
} (error) {
();
}
}
() {
openPositions = .();
updates = [];
( position openPositions) {
{
currentPrice = .(position.);
metrics = .({
: position.,
: position.,
currentPrice
});
.(position., {
: currentPrice,
: ()
});
.(position., currentPrice, metrics);
updates.({
: position.,
currentPrice,
metrics,
:
});
} (error) {
updates.({
: position.,
: ,
: error.
});
}
}
updates;
}
}
When displaying position information, format it clearly:
function displayPosition(position, metrics) {
const output = `
╔════════════════════════════════════════════════════════════════╗
║ CRYPTO POSITION TRACKER ║
╠════════════════════════════════════════════════════════════════╣
║ Symbol: ${position.symbol.padEnd(48)} ║
║ Entry Price: $${position.entry_price.toFixed(2).padEnd(47)} ║
║ Current Price: $${position.current_price.toFixed(2).padEnd(47)} ║
║ Quantity: ${position.quantity.toString().padEnd(48)} ║
╠════════════════════════════════════════════════════════════════╣
║ METRICS ║
╠════════════════════════════════════════════════════════════════╣
║ Entry Value: $${metrics.entryValue.toFixed(2).padEnd(47)} ║
║ Current Value: $${metrics.currentValue.toFixed(2).padEnd(47)} ║
║ Unrealized P&L: ${formatPnL(metrics.unrealizedPnL).padEnd(47)} ║
║ P&L %: ${formatPnLPercentage(metrics.pnlPercentage).padEnd(48)} ║
╠════════════════════════════════════════════════════════════════╣
║ Status: ${determineStatusEmoji(metrics.pnlPercentage)} ${metrics.status.padEnd(43)} ║
╚════════════════════════════════════════════════════════════════╝
`;
return output;
}
function formatPnL(value) {
const formatted = `$${Math.abs(value).toFixed(2)}`;
if (value >= 0) {
;
} {
;
}
}
() {
formatted = ;
(percentage >= ) {
;
} {
;
}
}
() {
(percentage > ) ;
(percentage > ) ;
(percentage > -) ;
(percentage > -) ;
;
}
Set up automatic alerts for significant events:
class PositionAlertSystem {
constructor() {
this.alertThresholds = {
profitTarget: 0.20, // 20% profit
lossWarning: -0.10, // 10% loss
criticalLoss: -0.25, // 25% loss
volatilitySpike: 0.15 // 15% daily move
};
}
async checkAlerts(position, previousPrice, currentPrice) {
const alerts = [];
const priceChange = ((currentPrice - previousPrice) / previousPrice) * 100;
// Check profit targets
if (metrics.pnlPercentage >= this.alertThresholds.profitTarget * 100) {
alerts.push({
type: 'PROFIT_TARGET',
message: ` ${position.symbol} hit profit target: +${metrics.pnlPercentage.toFixed(2)}%`,
severity: 'INFO',
action: 'Consider taking profits'
});
}
// Check loss warnings
if (metrics.pnlPercentage <= .. * &&
metrics. > .. * ) {
alerts.({
: ,
: ,
: ,
:
});
}
(metrics. <= .. * ) {
alerts.({
: ,
: ,
: ,
:
});
}
(.(priceChange) >= .. * ) {
alerts.({
: ,
: ,
: ,
:
});
}
alerts;
}
}
Always implement comprehensive error handling:
try {
const position = await tracker.trackPosition({
symbol: 'BTC',
entryPrice: 45000,
quantity: 0.5,
entryDate: new Date('2024-01-01'),
targetPrice: 60000,
stopLoss: 40000
});
displayPosition(position.position, position.metrics);
} catch (error) {
if (error.code === 'INVALID_SYMBOL') {
console.error(`Invalid cryptocurrency symbol: ${error.symbol}`);
} else if (error.code === 'API_ERROR') {
console.error(`Failed to fetch price data: ${error.message}`);
} else {
console.error(`Unexpected error: ${error.message}`);
}
}
This command provides comprehensive position tracking with real-time updates, PnL calculations, risk analysis, and actionable recommendations for crypto investments.