app.ts 755 B

123456789101112131415161718192021
  1. import { marketDataFetcher } from './market/marketDataFetcher'
  2. import { positionStrategy } from './strategy/positionStrategy'
  3. import { hedgingExecutor } from './hedging/hedgingExecutor'
  4. import { riskAssessor } from '../risk/riskAssessor'
  5. import { logger } from '../utils/logger'
  6. export async function startApp() {
  7. await marketDataFetcher.init()
  8. const symbols = ['BTCUSDT', 'ETHUSDT']
  9. marketDataFetcher.subscribe(symbols, ['1m'])
  10. setInterval(async () => {
  11. const signals = positionStrategy.generateSignals(symbols)
  12. for (const s of signals) {
  13. if (s.action === 'hedge' && s.quantity > 0) {
  14. const tx = await hedgingExecutor.hedgeSpot(s.symbol, s.quantity)
  15. logger.info(`Hedge executed: ${tx}`)
  16. }
  17. }
  18. }, 5000)
  19. }