Explore our growing ecosystem of DeAI applications in the awesome-aiforge repository.
Build custom plugins to extend your AI agents with specialized functionality. Create trading strategies, data connectors, notification systems, and AI models that integrate seamlessly with the AI Forge ecosystem.
Connect to external APIs and data sources
Custom trading algorithms and decision logic
Alert and communication integrations
Custom machine learning models and algorithms
Create the basic plugin structure and configuration
// plugin.json
{
"name": "custom-trading-strategy",
"version": "1.0.0",
"description": "Advanced momentum trading strategy",
"author": "Your Name",
"category": "trading",
"dependencies": {
"@aiforge/plugin-sdk": "^1.0.0",
"technicalindicators": "^3.1.0"
},
"permissions": [
"market_data",
"trading",
"portfolio_read"
]
}
Implement your plugin's core functionality
// index.js
import { Plugin } from '@aiforge/plugin-sdk'
export default class CustomTradingStrategy extends Plugin {
constructor(config) {
super(config)
this.name = 'Custom Trading Strategy'
this.version = '1.0.0'
}
async initialize() {
// Plugin initialization logic
this.rsiPeriod = this.config.rsiPeriod || 14
this.macdPeriod = this.config.macdPeriod || 12
console.log('Trading strategy plugin initialized')
}
async execute(data) {
// Main plugin logic
const signals = await this.generateSignals(data)
return {
action: signals.action, // 'buy', 'sell', 'hold'
confidence: signals.confidence,
reasoning: signals.reasoning
}
}
}
Test your plugin with sample data and validation
// test.js
import CustomTradingStrategy from './index.js'
const plugin = new CustomTradingStrategy({
rsiPeriod: 14,
macdPeriod: 12
})
// Test with sample data
const testData = {
prices: [100, 102, 98, 105, 107, 103],
volume: [1000, 1200, 800, 1500, 1800, 1100]
}
const result = await plugin.execute(testData)
console.log('Plugin result:', result)
// Validate output format
assert(result.action in ['buy', 'sell', 'hold'])
assert(typeof result.confidence === 'number')
assert(result.confidence >= 0 && result.confidence <= 1)
Package and deploy your plugin to the marketplace
# Package plugin
npm run build
# Test plugin locally
aiforge plugin test ./dist
# Deploy to marketplace
aiforge plugin deploy ./dist --public
# Install in agent
aiforge agent install custom-trading-strategy
Essential plugin lifecycle methods
initialize()
Plugin setup and configurationexecute(data)
Main plugin execution logiccleanup()
Cleanup resources on shutdownvalidate(config)
Validate plugin configurationMethods to access agent and market data
getMarketData(symbol, timeframe)
Get price datagetPortfolio()
Access current portfolio stategetAccountBalance()
Get account balancesgetHistoricalData(params)
Access historical dataMethods to interact with the agent system
sendNotification(message)
Send alerts/notificationslogEvent(event)
Log custom eventsupdateState(state)
Update plugin statescheduleTask(task, interval)
Schedule recurring tasksMethods for trading operations (requires permissions)
executeTrade(order)
Execute trading ordersgetOpenOrders()
Get active orderscancelOrder(orderId)
Cancel existing ordersgetTradeHistory()
Access trade historyA complete example showing how to build a trading strategy plugin using technical indicators.
import { Plugin } from '@aiforge/plugin-sdk'
import { RSI, MACD } from 'technicalindicators'
export default class MomentumStrategy extends Plugin {
async initialize() {
this.rsi = new RSI({ period: 14 })
this.macd = new MACD({ fastPeriod: 12, slowPeriod: 26, signalPeriod: 9 })
}
async execute(data) {
const { prices, volumes } = data
// Calculate technical indicators
const rsiValue = this.rsi.nextValue(prices[prices.length - 1])
const macdResult = this.macd.nextValue(prices[prices.length - 1])
// Generate trading signal
let signal = 'hold'
let confidence = 0
if (rsiValue < 30 && macdResult.MACD > macdResult.signal) {
signal = 'buy'
confidence = 0.8
} else if (rsiValue > 70 && macdResult.MACD < macdResult.signal) {
signal = 'sell'
confidence = 0.7
}
return {
action: signal,
confidence: confidence,
reasoning: `RSI: ${rsiValue.toFixed(2)}, MACD: ${macdResult.MACD.toFixed(4)}`,
indicators: {
rsi: rsiValue,
macd: macdResult
}
}
}
}
Publish your plugins to the AI Forge marketplace and earn revenue from downloads and usage.