simple_order_test.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env tsx
  2. import { Config, SmartAccountDiscovery } from './src/config/simpleEnv.js'
  3. import { PacificaProxyClient } from './src/exchanges/pacifica/PacificaProxyClient.js'
  4. async function simpleOrderTest() {
  5. console.log('🧪 简单下单测试')
  6. try {
  7. const accounts = SmartAccountDiscovery.discoverPacifica()
  8. if (accounts.length === 0) {
  9. console.log('❌ 未发现Pacifica账户')
  10. return
  11. }
  12. const account = accounts[0]
  13. console.log(`使用账户: ${account.account.substring(0, 8)}...`)
  14. const client = new PacificaProxyClient({
  15. account: account.account,
  16. privateKey: account.privateKey,
  17. })
  18. // 测试最小的市价单
  19. console.log('发送市价单...')
  20. console.log('参数: BTC, 0.01, bid, reduce_only=false')
  21. const result = await client.createMarketOrder({
  22. account: account.account,
  23. symbol: 'BTCUSDT', // 试试完整的符号格式
  24. amount: '0.01',
  25. side: 'bid',
  26. reduceOnly: false,
  27. slippagePercent: '2.0',
  28. })
  29. console.log('✅ 下单成功!')
  30. console.log(JSON.stringify(result, null, 2))
  31. } catch (error: any) {
  32. console.log('❌ 下单失败:', error.message)
  33. if (error.stack) {
  34. console.log('堆栈:', error.stack)
  35. }
  36. }
  37. }
  38. simpleOrderTest()