agentleFS
gravity-technologiesgravity-technologies/grvt-skills/skills/account-management/SKILL.md

account-management

Skill4 starsChanged 8 months agoMITView on GitHub

Manage GRVT trading account — check balances, positions, margin, and trade history. Use when the user asks about their portfolio, PnL, or account status.

  • Reads credentials
  • Installs packages

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. 0gfoundation/0g-agent-skills★ 15same name
    2. poorvith-mp/skills-sales-support★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository3 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when the user wants to:

    line 10
  2. Distinctive:

    Check account balance or portfolio value

    line 11
  3. Distinctive:

    Check funding payment history

    line 15
  4. Distinctive:

    All account endpoints require authentication.

    line 23
  5. Distinctive:

    All account data requires authentication — ensure env vars are set

    line 195
  6. Very specific:

    Use GrvtEnv.TESTNET for testing before production

    line 198

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

GRVT Account Management

When to Use

Use this skill when the user wants to:

  • Check account balance or portfolio value
  • View open positions and unrealized PnL
  • Manage position margin (add margin, check limits)
  • View trade/fill history
  • Check funding payment history

Prerequisites

pip install grvt-pysdk

All account endpoints require authentication. GRVT has two types of API keys:

# Trading API Key — for balances, positions, trade history
export GRVT_TRADING_API_KEY="<Trading API Key from GRVT exchange UI>"
export GRVT_TRADING_PRIVATE_KEY="<private key associated with Trading API Key>"

# Funding API Key — for funding account transfers
export GRVT_FUNDING_API_KEY="<Funding API Key from GRVT exchange UI>"
export GRVT_FUNDING_PRIVATE_KEY="<private key associated with Funding API Key>"

export GRVT_ENV="testnet"  # or "prod"

Both key types can be created at:

This skill primarily uses GRVT_TRADING_API_KEY. Use GRVT_FUNDING_API_KEY only for funding account transfers.

SDK Setup

Login to auto-detect trading_account_id and funding_account_address:

import os
import requests
from pathlib import Path
from pysdk.grvt_ccxt import GrvtCcxt
from pysdk.grvt_ccxt_env import GrvtEnv

# Load .env file if present
env_file = Path(".env")
if env_file.exists():
    for line in env_file.read_text().splitlines():
        line = line.strip()
        if line and not line.startswith("#") and "=" in line:
            key, _, value = line.partition("=")
            os.environ.setdefault(key.strip(), value.strip())

env = os.getenv("GRVT_ENV", "testnet")
base = "edge.testnet.grvt.io" if env == "testnet" else "edge.grvt.io"

# Login with Trading API Key
login_resp = requests.post(
    f"https://{base}/auth/api_key/login",
    json={"api_key": os.getenv("GRVT_TRADING_API_KEY")},
).json()
trading_account_id = login_resp["sub_account_id"]
funding_account_address = login_resp["funding_account_address"]

api = GrvtCcxt(
    env=GrvtEnv.TESTNET if env == "testnet" else GrvtEnv.PRODUCTION,
    parameters={
        "api_key": os.getenv("GRVT_TRADING_API_KEY"),
        "trading_account_id": trading_account_id,
        "private_key": os.getenv("GRVT_TRADING_PRIVATE_KEY"),
    },
)

# For funding account operations, login with Funding API Key instead:
# login_resp = requests.post(
#     f"https://{base}/auth/api_key/login",
#     json={"api_key": os.getenv("GRVT_FUNDING_API_KEY")},
# ).json()

Account Balance

# Get account balance
balance = api.fetch_balance()
# Top-level keys: info, timestamp, datetime, total, free, used, USDT
print(f"USDT Total: {balance['total']['USDT']}")
print(f"USDT Free:  {balance['free']['USDT']}")
print(f"USDT Used:  {balance['used']['USDT']}")

# Detailed info per currency in balance["info"]
for entry in balance["info"]:
    print(f"{entry['currency']}: balance={entry['balance']}, unrealized_pnl={entry['unrealized_pnl']}")

Account Summary

# Sub-account summary — balances, margin usage, equity
summary = api.get_account_summary(type="sub-account")

# Aggregated summary across all sub-accounts
agg_summary = api.get_account_summary(type="aggregated")

Positions

# Fetch all open positions
positions = api.fetch_positions()

# Fetch positions for specific symbols
positions = api.fetch_positions(symbols=["BTC_USDT_Perp", "ETH_USDT_Perp"])

for pos in positions:
    side = "long" if float(pos["size"]) > 0 else "short"
    print(f"{pos['instrument']}: size={pos['size']} side={side}")
    print(f"  Entry: {pos['entry_price']}, Mark: {pos['mark_price']}")
    print(f"  Unrealized PnL: {pos['unrealized_pnl']}, ROI: {pos['roi']}%")
    print(f"  Leverage: {pos['leverage']}x, Margin: {pos['margin_type']}")

Position Margin Management

# Add margin to a position (reduce liquidation risk)
api.add_position_margin(
    symbol="BTC_USDT_Perp",
    amount=100,  # Additional USDT margin
)

# Check margin limits
limits = api.get_position_margin_limits(symbol="BTC_USDT_Perp")

Trade / Fill History

# Recent fills
fills = api.fetch_my_trades(symbol="BTC_USDT_Perp", limit=50)
for fill in fills:
    side = "buy" if fill.get("is_taker_buyer") else "sell"
    print(f"{side} {fill['size']} @ {fill['price']} — trade_id: {fill['trade_id']}")

Funding Payment History

# Check funding payments received/paid on perpetual positions
funding = api.fetch_funding_payment_history(symbol="BTC_USDT_Perp", limit=24)
for f in funding:
    print(f"Payment: {f['amount']} at {f['datetime']}")

Account History

# Full account history (deposits, withdrawals, transfers, settlements)
history = api.fetch_account_history()

Common Patterns

Portfolio Overview

def portfolio_overview(api):
    balance = api.fetch_balance()
    positions = api.fetch_positions()

    print(f"Account Balance: {balance['total']['USDT']} USDT")
    print(f"Available: {balance['free']['USDT']} USDT")
    print(f"\nOpen Positions ({len(positions)}):")
    total_pnl = 0
    for pos in positions:
        pnl = float(pos.get("unrealized_pnl", 0))
        total_pnl += pnl
        side = "long" if float(pos["size"]) > 0 else "short"
        print(f"  {pos['instrument']}: {pos['size']} ({side})")
        print(f"    Entry: {pos['entry_price']} | PnL: {pnl}")
    print(f"\nTotal Unrealized PnL: {total_pnl}")

Important Notes

  • All account data requires authentication — ensure env vars are set
  • Position PnL is calculated against current mark price
  • Funding payments occur at regular intervals on perpetual positions (typically every 8 hours)
  • Use GrvtEnv.TESTNET for testing before production

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.