Skip to content

REChain-Network-Solutions/Autonomous-Agent-for-Pythagorean-perpetual-futures-pyth-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

REChain ® Autonomous Agent for Pythagorean Perpetual Futures

A sophisticated autonomous trading agent implementing Pythagorean geometric risk distribution for perpetual futures trading with real-time WebSocket capabilities.

🚀 Features

  • Pythagorean Risk Model: Geometric distribution of risk across positions
  • Oracle Integrations: Katya, Pyth, and custom oracle support
  • Automated Position Sizing: Intelligent position management based on risk metrics
  • Smart Contract Execution: Direct interaction with DeFi protocols
  • Adaptive Strategy Switching: Dynamic strategy selection based on market conditions
  • Real-time Monitoring: Live dashboard and performance metrics via WebSocket
  • Advanced Risk Management: VaR analysis, drawdown protection, correlation limits
  • WebSocket Integration: Real-time updates for trading activities, market data, and alerts

🏁 Quick Start

Prerequisites

  • Node.js >= 14.0.0
  • npm or yarn

Installation

git clone https://github.com/REChain-Network-Solutions/Autonomous-Agent-for-Pythagorean-perpetual-futures-pyth-.git
cd Autonomous-Agent-for-Pythagorean-perpetual-futures-pyth-
npm install

Configuration

Copy the environment template and configure your settings:

cp .env.example .env

Edit the .env file with your specific configuration.

Running the Agent

npm start

The agent will start on http://localhost:3000 (default port).

⚙️ Configuration

See .env.example for comprehensive configuration options. Key environment variables include:

  • API_KEY: Secret API key for authentication
  • PORT: Server port (default: 3000)
  • INITIAL_CASH: Initial trading capital
  • MAX_POSITION_SIZE: Maximum position size per trade
  • MAX_DRAWDOWN: Maximum allowed drawdown percentage
  • STOP_LOSS_PERCENT: Stop-loss percentage
  • TAKE_PROFIT_PERCENT: Take-profit percentage
  • LEVERAGE: Trading leverage

📖 API Documentation

Authentication

All API endpoints require authentication via API key in the x-api-key header.

Core Endpoints

  • Health Check: GET /healthz
  • Readiness Check: GET /readyz
  • Metrics Status: GET /metrics/status
  • Positions: GET /metrics/positions
  • Performance: GET /metrics/performance

Admin Endpoints (require admin token)

  • Manual Refresh: POST /admin/refresh-metrics
  • Webhook Management: POST/DELETE/GET /admin/hooks
  • Event Emission: POST /admin/emit
  • Configuration View: GET /admin/config
  • Session Management: GET/DELETE /admin/sessions

Web3 Authentication

  • Nonce Generation: GET /web3/nonce
  • Signature Verification: POST /web3/verify

Real-time Streaming

  • SSE Metrics Stream: GET /metrics/stream (Server-Sent Events)
  • WebSocket Connection: ws://localhost:3000 (Real-time updates)

WebSocket Events

The WebSocket server provides real-time updates for:

  • Trading Activities: Position opens, closes, and modifications
  • Market Data: Price updates and market data changes
  • Alerts: System alerts and notifications
  • Analytics: Dashboard updates and performance metrics
  • Risk Management: Risk assessment updates and limit breaches

For detailed API specification, see openapi.yaml or visit /docs when the server is running.

🐳 Docker Deployment

Build the Image

docker build -t pyth-aa .

Run the Container

docker run -p 3000:3000 --env-file .env pyth-aa

Docker Compose

docker-compose up --build

🧪 Testing

Run All Tests

npm test

Run Specific Test Suites

npm test -- test/alertSystem.test.js
npm test -- test/api.test.js
npm test -- test/tradingEngine.test.js

Lint Code

npm run lint

📄 License

MIT License - see LICENSE for details.

🤝 Contributing

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

💬 Support

❤️ Donations

We accept donations through KatyaAI and forward a portion to other open-source projects that made Pyth possible.

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •