CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-kucoin-python

A Python SDK for KuCoin cryptocurrency exchange API providing REST endpoints implementation, simple authentication handling, response exception handling, and websocket support for trading, market data, user account management, margin trading, lending, and earning features

Pending
Overview
Eval results
Files

earn-products.mddocs/

Earn Products

Access to KuCoin's comprehensive earning products including savings accounts, staking rewards, and fixed income products. Provides portfolio management for various cryptocurrency earning opportunities with competitive yields.

Capabilities

Savings Products

Flexible savings accounts with competitive interest rates.

def get_earn_savings_products():
    """
    Get available savings products.
    
    Returns:
        dict: List of savings products with rates and terms
    """

Staking Products

Cryptocurrency staking opportunities for earning rewards.

def get_earn_staking_products():
    """
    Get available staking products.
    
    Returns:
        dict: Staking products with reward rates and lock periods
    """

def get_earn_staking_products_v3():
    """
    Get staking products (v3 API).
    
    Returns:
        dict: Enhanced staking product information
    """

def get_earn_kcs_staking_products():
    """
    Get KCS-specific staking products.
    
    Returns:
        dict: KCS staking opportunities and rates
    """

def get_earn_kcs_staking_products_v3():
    """
    Get KCS staking products (v3 API).
    
    Returns:
        dict: Enhanced KCS staking information
    """

def get_earn_eth_staking_products():
    """
    Get Ethereum staking products.
    
    Returns:
        dict: ETH staking opportunities and rewards
    """

Fixed Income Products

Fixed-term investment products with guaranteed returns.

def get_earn_fixed_income_current_holdings():
    """
    Get current fixed income holdings.
    
    Returns:
        dict: Active fixed income positions and earnings
    """

Promotion Products

Special promotional earning opportunities.

def get_earn_promotion_products():
    """
    Get available promotion products.
    
    Returns:
        dict: Promotional earning opportunities with enhanced rates
    """

Usage Examples

Explore Available Products

from kucoin.client import Earn

# Initialize earn client
earn = Earn(api_key, api_secret, api_passphrase, is_sandbox=False)

# Get all savings products
savings = earn.get_earn_savings_products()
print("Available Savings Products:")
for product in savings.get('data', []):
    print(f"- {product['currency']}: {product['interestRate']}% APY")
    print(f"  Min amount: {product['minPurchaseSize']}")
    print(f"  Max amount: {product['maxPurchaseSize']}")

# Get staking opportunities
staking = earn.get_earn_staking_products()
print("\nStaking Products:")
for product in staking.get('data', []):
    print(f"- {product['currency']}: {product['rewardRate']}% rewards")
    print(f"  Lock period: {product['lockPeriod']} days")

KCS Staking Analysis

# Get KCS staking products
kcs_staking = earn.get_earn_kcs_staking_products()
print("KCS Staking Options:")

for product in kcs_staking.get('data', []):
    print(f"- Product: {product['productName']}")
    print(f"  APY: {product['annualizedRate']}%")
    print(f"  Min stake: {product['minAmount']} KCS")
    print(f"  Lock period: {product['lockPeriod']} days")
    print(f"  Available quota: {product['availableQuota']} KCS")

# Compare with v3 API
kcs_staking_v3 = earn.get_earn_kcs_staking_products_v3()
print("\nKCS Staking (V3 API):")
for product in kcs_staking_v3.get('data', []):
    print(f"- {product['productName']}: {product['expectedRate']}% expected rate")

Ethereum Staking

# Get ETH staking information
eth_staking = earn.get_earn_eth_staking_products()
print("Ethereum Staking:")

for product in eth_staking.get('data', []):
    print(f"- Product: {product['productName']}")
    print(f"  Expected APY: {product['expectedApr']}%")
    print(f"  Min stake: {product['minAmount']} ETH")
    print(f"  Validation period: {product['validationPeriod']}")
    print(f"  Withdrawal delay: {product['withdrawalDelay']} days")

Fixed Income Portfolio

# Check current fixed income holdings
holdings = earn.get_earn_fixed_income_current_holdings()
print("Current Fixed Income Holdings:")

total_principal = 0
total_earnings = 0

for holding in holdings.get('data', []):
    principal = float(holding['principal'])
    earnings = float(holding['earnings'])
    
    total_principal += principal
    total_earnings += earnings
    
    print(f"- {holding['currency']}: {principal} principal")
    print(f"  Earnings: {earnings} {holding['currency']}")
    print(f"  APY: {holding['interestRate']}%")
    print(f"  Maturity: {holding['maturityDate']}")

print(f"\nPortfolio Summary:")
print(f"Total Principal: {total_principal}")
print(f"Total Earnings: {total_earnings}")
print(f"Overall Return: {(total_earnings / total_principal * 100):.2f}%")

Promotional Opportunities

# Check for promotional products
promotions = earn.get_earn_promotion_products()
print("Promotional Products:")

for promo in promotions.get('data', []):
    print(f"- {promo['productName']}")
    print(f"  Currency: {promo['currency']}")
    print(f"  Promotional rate: {promo['promotionalRate']}%")
    print(f"  Regular rate: {promo['regularRate']}%")
    print(f"  Promotion period: {promo['promotionDays']} days")
    print(f"  Available until: {promo['endDate']}")
    
    # Calculate potential earnings
    if 'maxAmount' in promo:
        max_amount = float(promo['maxAmount'])
        promo_rate = float(promo['promotionalRate']) / 100
        promo_days = int(promo['promotionDays'])
        
        potential_earnings = max_amount * promo_rate * (promo_days / 365)
        print(f"  Max potential earnings: {potential_earnings:.4f} {promo['currency']}")

Product Comparison

def compare_earn_products():
    """Compare different earning products to find the best yields."""
    earn_products = {}
    
    # Collect all products
    try:
        savings = earn.get_earn_savings_products()
        earn_products['savings'] = savings.get('data', [])
    except:
        earn_products['savings'] = []
    
    try:
        staking = earn.get_earn_staking_products()
        earn_products['staking'] = staking.get('data', [])
    except:
        earn_products['staking'] = []
    
    try:
        promotions = earn.get_earn_promotion_products()
        earn_products['promotions'] = promotions.get('data', [])
    except:
        earn_products['promotions'] = []
    
    # Find best rates by currency
    best_rates = {}
    
    for product_type, products in earn_products.items():
        for product in products:
            currency = product.get('currency', 'Unknown')
            rate_key = 'interestRate' if 'interestRate' in product else 'rewardRate'
            rate = float(product.get(rate_key, 0))
            
            if currency not in best_rates or rate > best_rates[currency]['rate']:
                best_rates[currency] = {
                    'rate': rate,
                    'type': product_type,
                    'product': product.get('productName', 'Unknown')
                }
    
    print("Best Earning Rates by Currency:")
    for currency, info in best_rates.items():
        print(f"{currency}: {info['rate']}% - {info['product']} ({info['type']})")
    
    return best_rates

# best_rates = compare_earn_products()

Yield Farming Strategy

def analyze_yield_opportunities(target_currencies=['USDT', 'BTC', 'ETH']):
    """Analyze earning opportunities for target currencies."""
    
    opportunities = {}
    
    for currency in target_currencies:
        opportunities[currency] = []
        
        # Check savings
        try:
            savings = earn.get_earn_savings_products()
            for product in savings.get('data', []):
                if product.get('currency') == currency:
                    opportunities[currency].append({
                        'type': 'savings',
                        'name': product.get('productName', 'Savings'),
                        'rate': float(product.get('interestRate', 0)),
                        'min_amount': float(product.get('minPurchaseSize', 0)),
                        'liquidity': 'flexible'
                    })
        except:
            pass
        
        # Check staking
        try:
            staking = earn.get_earn_staking_products()
            for product in staking.get('data', []):
                if product.get('currency') == currency:
                    opportunities[currency].append({
                        'type': 'staking',
                        'name': product.get('productName', 'Staking'),
                        'rate': float(product.get('rewardRate', 0)),
                        'min_amount': float(product.get('minAmount', 0)),
                        'liquidity': f"{product.get('lockPeriod', 0)} days lock"
                    })
        except:
            pass
    
    # Display opportunities
    for currency, opps in opportunities.items():
        if opps:
            print(f"\n{currency} Earning Opportunities:")
            sorted_opps = sorted(opps, key=lambda x: x['rate'], reverse=True)
            for opp in sorted_opps:
                print(f"- {opp['name']}: {opp['rate']}% ({opp['liquidity']})")
                print(f"  Min: {opp['min_amount']} {currency}")
    
    return opportunities

# opportunities = analyze_yield_opportunities()

Types

SavingsProduct = dict
# {
#   "currency": str,         # Currency code
#   "productName": str,      # Product name
#   "interestRate": str,     # Interest rate (APY)
#   "minPurchaseSize": str,  # Minimum purchase amount
#   "maxPurchaseSize": str,  # Maximum purchase amount
#   "purchaseEnable": bool,  # Purchase enabled
#   "redeemEnable": bool,    # Redemption enabled
#   "productStatus": str     # Product status
# }

StakingProduct = dict
# {
#   "currency": str,         # Staking currency
#   "productName": str,      # Product name
#   "rewardRate": str,       # Reward rate (APY)
#   "annualizedRate": str,   # Annualized rate
#   "lockPeriod": int,       # Lock period in days
#   "minAmount": str,        # Minimum staking amount
#   "maxAmount": str,        # Maximum staking amount
#   "availableQuota": str,   # Available staking quota
#   "productStatus": str     # Product status
# }

FixedIncomeHolding = dict
# {
#   "orderId": str,          # Order ID
#   "currency": str,         # Currency
#   "principal": str,        # Principal amount
#   "earnings": str,         # Earned amount
#   "interestRate": str,     # Interest rate
#   "purchaseTime": int,     # Purchase timestamp
#   "maturityDate": str,     # Maturity date
#   "status": str            # Holding status
# }

PromotionProduct = dict
# {
#   "productName": str,      # Product name
#   "currency": str,         # Currency
#   "promotionalRate": str,  # Promotional interest rate
#   "regularRate": str,      # Regular interest rate
#   "promotionDays": int,    # Promotion period in days
#   "maxAmount": str,        # Maximum investment amount
#   "startDate": str,        # Promotion start date
#   "endDate": str,          # Promotion end date
#   "productStatus": str     # Product status
# }

ETHStakingProduct = dict
# {
#   "productName": str,      # Product name
#   "expectedApr": str,      # Expected annual percentage rate
#   "minAmount": str,        # Minimum stake amount (ETH)
#   "validationPeriod": str, # Validation period
#   "withdrawalDelay": int,  # Withdrawal delay in days
#   "stakingRewards": str,   # Staking rewards structure
#   "productStatus": str     # Product status
# }

KCSStakingProduct = dict
# {
#   "productName": str,      # Product name
#   "annualizedRate": str,   # Annualized reward rate
#   "expectedRate": str,     # Expected rate
#   "lockPeriod": int,       # Lock period in days
#   "minAmount": str,        # Minimum stake amount (KCS)
#   "availableQuota": str,   # Available staking quota
#   "stakingType": str,      # Staking type
#   "productStatus": str     # Product status
# }

Install with Tessl CLI

npx tessl i tessl/pypi-kucoin-python

docs

account-management.md

earn-products.md

index.md

lending.md

margin-trading.md

market-data.md

spot-trading.md

websocket.md

tile.json