JSPM

  • Created
  • Published
  • Downloads 36
  • Score
    100M100P100Q61629F
  • License MIT

Open-source Bitcoin trading SDK with AI strategies and Lightning Network execution

Package Exports

  • skayn-trading-sdk
  • skayn-trading-sdk/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (skayn-trading-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Skayn Trading SDK

The easiest way to build Bitcoin trading strategies. Focus on your trading logic, not infrastructure.

Features

  • ⚑ Simple - Get started in minutes, not days
  • πŸ”Œ Pluggable - Swap exchanges and data providers with one line
  • β‚Ώ Bitcoin-First - Built specifically for Bitcoin spot and perpetuals
  • πŸ“Š Backtest & Live - Same code for backtesting and live trading
  • πŸ”“ No Lock-in - Open source, extensible interfaces

Installation

npm install skayn-trading-sdk

Quick Start

πŸ‡ΊπŸ‡Έ US Developers: Enable VPN before running examples (Binance geoblocks US traffic)
πŸ“Š Data Source: Uses real Bitcoin OHLCV data from Binance for professional-grade backtests
⚑ Setup Time: 30 seconds

If You Get API Errors

  • US users: Enable VPN and retry for best experience
  • Alternative: CoinGecko provider available (note: limited granularity, daily data only)
  • Custom data: Plug in your own high-quality OHLCV files
const { SDK } = require('skayn-trading-sdk');

// Create a simple moving average strategy
const myStrategy = SDK.strategy(async (data, portfolio) => {
  const prices = data.map(bar => bar.close);
  const sma20 = average(prices.slice(-20));
  const sma50 = average(prices.slice(-50));
  
  if (sma20 > sma50) {
    return { action: 'BUY', confidence: 0.8 };
  }
  return { action: 'SELL', confidence: 0.7 };
});

// Run a backtest
const results = await SDK.create()
  .strategy(myStrategy)
  .dataProvider(myDataProvider)
  .backtest({
    startDate: '2024-01-01',
    endDate: '2024-12-31',
    initialBalance: 10000
  });

console.log('Backtest Results:', results);

Core Concepts

Strategies

Implement your trading logic by extending the Strategy interface:

const { Strategy } = require('skayn-trading-sdk');

class MyStrategy extends Strategy {
  async analyze(data, portfolio) {
    // Your trading logic here
    return {
      action: 'BUY',     // 'BUY', 'SELL', or 'HOLD'
      confidence: 0.85,   // 0-1 confidence score
      quantity: 0.001,    // BTC amount
      reasons: ['SMA crossover', 'RSI oversold']
    };
  }
}

Data Providers

Connect any data source by implementing the DataProvider interface:

const { DataProvider } = require('skayn-trading-sdk');

class MyDataProvider extends DataProvider {
  async getData(startDate, endDate, interval, symbol) {
    // Fetch and return OHLCV data
    return [{
      timestamp: 1234567890,
      open: 45000,
      high: 46000,
      low: 44500,
      close: 45500,
      volume: 100
    }];
  }
}

Exchange Providers

Execute trades on any exchange by implementing the ExchangeProvider interface:

const { ExchangeProvider } = require('skayn-trading-sdk');

class MyExchange extends ExchangeProvider {
  async executeSignal(signal, params) {
    // Execute the trade
    return {
      success: true,
      orderId: '12345',
      executedPrice: 45500
    };
  }
}

Available Providers

Install additional providers as needed:

  • skayn-lnmarkets-provider - Trade on LN Markets via Lightning
  • skayn-hyperliquid-provider - Trade on Hyperliquid DEX
  • skayn-cryptoquant-provider - On-chain data from CryptoQuant
  • More coming soon...

Advanced Usage

Custom Backtest Engine

const { BacktestEngine } = require('skayn-trading-sdk');

class MyBacktestEngine extends BacktestEngine {
  async runBacktest(config) {
    // Custom backtesting logic
  }
}

SDK.create()
  .backtestEngine(new MyBacktestEngine())
  .run();

Live Trading

const LNMarketsProvider = require('skayn-lnmarkets-provider');

SDK.create()
  .strategy(myStrategy)
  .exchange(new LNMarketsProvider({
    key: process.env.LN_MARKETS_KEY,
    secret: process.env.LN_MARKETS_SECRET
  }))
  .live({
    checkInterval: 60000,  // Check every minute
    maxPositionSize: 0.01  // Max 0.01 BTC
  });

Contributing

We welcome contributions! Please see our Contributing Guide for details.

License

MIT License - see LICENSE for details.

Support

Built for the Bitcoin trading community