@3rd-eye-labs/openmm 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/cli.js +4 -5
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/commands/balance.d.ts.map +1 -1
- package/dist/cli/commands/balance.js +1 -1
- package/dist/cli/commands/balance.js.map +1 -1
- package/dist/cli/commands/grid.d.ts +3 -0
- package/dist/cli/commands/grid.d.ts.map +1 -0
- package/dist/cli/commands/grid.js +103 -0
- package/dist/cli/commands/grid.js.map +1 -0
- package/dist/cli/commands/multi-trade.d.ts +3 -0
- package/dist/cli/commands/multi-trade.d.ts.map +1 -0
- package/dist/cli/commands/multi-trade.js +175 -0
- package/dist/cli/commands/multi-trade.js.map +1 -0
- package/dist/cli/commands/orderbook.js +1 -1
- package/dist/cli/commands/orderbook.js.map +1 -1
- package/dist/cli/commands/orders.d.ts.map +1 -1
- package/dist/cli/commands/orders.js +3 -4
- package/dist/cli/commands/orders.js.map +1 -1
- package/dist/cli/commands/pool-discovery.d.ts.map +1 -1
- package/dist/cli/commands/pool-discovery.js +2 -4
- package/dist/cli/commands/pool-discovery.js.map +1 -1
- package/dist/cli/commands/price-comparison.d.ts +3 -0
- package/dist/cli/commands/price-comparison.d.ts.map +1 -0
- package/dist/cli/commands/price-comparison.js +103 -0
- package/dist/cli/commands/price-comparison.js.map +1 -0
- package/dist/cli/commands/ticker.d.ts.map +1 -1
- package/dist/cli/commands/ticker.js.map +1 -1
- package/dist/cli/commands/trade.d.ts.map +1 -1
- package/dist/cli/commands/trade.js +135 -18
- package/dist/cli/commands/trade.js.map +1 -1
- package/dist/cli/commands/trades.d.ts.map +1 -1
- package/dist/cli/commands/trades.js +2 -3
- package/dist/cli/commands/trades.js.map +1 -1
- package/dist/cli/exchange-factory.d.ts.map +1 -1
- package/dist/cli/exchange-factory.js +6 -6
- package/dist/cli/exchange-factory.js.map +1 -1
- package/dist/cli/pool-discovery-core.d.ts.map +1 -1
- package/dist/cli/pool-discovery-core.js +3 -9
- package/dist/cli/pool-discovery-core.js.map +1 -1
- package/dist/cli/pool-discovery.d.ts +56 -0
- package/dist/cli/pool-discovery.d.ts.map +1 -0
- package/dist/cli/pool-discovery.js +283 -0
- package/dist/cli/pool-discovery.js.map +1 -0
- package/dist/cli/utils/error-handler.d.ts.map +1 -1
- package/dist/cli/utils/error-handler.js +6 -5
- package/dist/cli/utils/error-handler.js.map +1 -1
- package/dist/config/environment.d.ts.map +1 -1
- package/dist/config/environment.js +3 -1
- package/dist/config/environment.js.map +1 -1
- package/dist/config/launcher-config.d.ts +13 -0
- package/dist/config/launcher-config.d.ts.map +1 -1
- package/dist/config/launcher-config.js +3 -1
- package/dist/config/launcher-config.js.map +1 -1
- package/dist/config/price-aggregation.d.ts +1 -1
- package/dist/config/price-aggregation.d.ts.map +1 -1
- package/dist/config/price-aggregation.js +20 -20
- package/dist/config/price-aggregation.js.map +1 -1
- package/dist/core/exchange/base-exchange-connector.d.ts.map +1 -1
- package/dist/core/exchange/base-exchange-connector.js +1 -5
- package/dist/core/exchange/base-exchange-connector.js.map +1 -1
- package/dist/core/exchange/base-exchange-data-mapper.d.ts.map +1 -1
- package/dist/core/exchange/base-exchange-data-mapper.js +1 -1
- package/dist/core/exchange/base-exchange-data-mapper.js.map +1 -1
- package/dist/core/price-aggregation/cardano-price-service.d.ts +2 -2
- package/dist/core/price-aggregation/cardano-price-service.d.ts.map +1 -1
- package/dist/core/price-aggregation/cardano-price-service.js +13 -13
- package/dist/core/price-aggregation/cardano-price-service.js.map +1 -1
- package/dist/core/price-aggregation/index.d.ts +1 -1
- package/dist/core/price-aggregation/index.d.ts.map +1 -1
- package/dist/core/price-aggregation/iris-api-client.d.ts.map +1 -1
- package/dist/core/price-aggregation/iris-api-client.js +5 -5
- package/dist/core/price-aggregation/iris-api-client.js.map +1 -1
- package/dist/core/price-aggregation/iris-pool-discovery.d.ts +2 -2
- package/dist/core/price-aggregation/iris-pool-discovery.d.ts.map +1 -1
- package/dist/core/price-aggregation/iris-pool-discovery.js +3 -3
- package/dist/core/price-aggregation/iris-pool-discovery.js.map +1 -1
- package/dist/core/price-aggregation/multi-exchange-price-service.d.ts +38 -0
- package/dist/core/price-aggregation/multi-exchange-price-service.d.ts.map +1 -0
- package/dist/core/price-aggregation/multi-exchange-price-service.js +123 -0
- package/dist/core/price-aggregation/multi-exchange-price-service.js.map +1 -0
- package/dist/core/price-aggregation/price-cache.d.ts +55 -0
- package/dist/core/price-aggregation/price-cache.d.ts.map +1 -0
- package/dist/core/price-aggregation/price-cache.js +152 -0
- package/dist/core/price-aggregation/price-cache.js.map +1 -0
- package/dist/core/price-aggregation/price-calculator.d.ts.map +1 -1
- package/dist/core/price-aggregation/price-calculator.js +3 -3
- package/dist/core/price-aggregation/price-calculator.js.map +1 -1
- package/dist/core/risk-management/risk-manager.d.ts.map +1 -1
- package/dist/core/risk-management/risk-manager.js +2 -2
- package/dist/core/risk-management/risk-manager.js.map +1 -1
- package/dist/core/strategy/strategy-factory.d.ts +5 -0
- package/dist/core/strategy/strategy-factory.d.ts.map +1 -1
- package/dist/core/strategy/strategy-factory.js +127 -5
- package/dist/core/strategy/strategy-factory.js.map +1 -1
- package/dist/examples/mexc-connector-comprehensive-test.d.ts +15 -0
- package/dist/examples/mexc-connector-comprehensive-test.d.ts.map +1 -0
- package/dist/examples/mexc-connector-comprehensive-test.js +514 -0
- package/dist/examples/mexc-connector-comprehensive-test.js.map +1 -0
- package/dist/examples/mexc-order-update-test.d.ts +4 -0
- package/dist/examples/mexc-order-update-test.d.ts.map +1 -0
- package/dist/examples/mexc-order-update-test.js +186 -0
- package/dist/examples/mexc-order-update-test.js.map +1 -0
- package/dist/examples/mexc-test.d.ts +9 -0
- package/dist/examples/mexc-test.d.ts.map +1 -0
- package/dist/examples/mexc-test.js +218 -0
- package/dist/examples/mexc-test.js.map +1 -0
- package/dist/examples/mexc-trades-debug.d.ts +2 -0
- package/dist/examples/mexc-trades-debug.d.ts.map +1 -0
- package/dist/examples/mexc-trades-debug.js +101 -0
- package/dist/examples/mexc-trades-debug.js.map +1 -0
- package/dist/examples/mexc-trades-subscription-debug.d.ts +2 -0
- package/dist/examples/mexc-trades-subscription-debug.d.ts.map +1 -0
- package/dist/examples/mexc-trades-subscription-debug.js +150 -0
- package/dist/examples/mexc-trades-subscription-debug.js.map +1 -0
- package/dist/examples/mexc-websocket-test.d.ts +8 -0
- package/dist/examples/mexc-websocket-test.d.ts.map +1 -0
- package/dist/examples/mexc-websocket-test.js +115 -0
- package/dist/examples/mexc-websocket-test.js.map +1 -0
- package/dist/examples/test-protobuf-status-detection.d.ts +9 -0
- package/dist/examples/test-protobuf-status-detection.d.ts.map +1 -0
- package/dist/examples/test-protobuf-status-detection.js +83 -0
- package/dist/examples/test-protobuf-status-detection.js.map +1 -0
- package/dist/exchanges/base-exchange-connector.d.ts +33 -0
- package/dist/exchanges/base-exchange-connector.d.ts.map +1 -0
- package/dist/exchanges/base-exchange-connector.js +55 -0
- package/dist/exchanges/base-exchange-connector.js.map +1 -0
- package/dist/exchanges/bitget/bitget-auth.d.ts +66 -0
- package/dist/exchanges/bitget/bitget-auth.d.ts.map +1 -0
- package/dist/exchanges/bitget/bitget-auth.js +203 -0
- package/dist/exchanges/bitget/bitget-auth.js.map +1 -0
- package/dist/exchanges/bitget/bitget-connector.d.ts +255 -0
- package/dist/exchanges/bitget/bitget-connector.d.ts.map +1 -0
- package/dist/exchanges/bitget/bitget-connector.js +709 -0
- package/dist/exchanges/bitget/bitget-connector.js.map +1 -0
- package/dist/exchanges/bitget/bitget-data-mapper.d.ts +47 -0
- package/dist/exchanges/bitget/bitget-data-mapper.d.ts.map +1 -0
- package/dist/exchanges/bitget/bitget-data-mapper.js +147 -0
- package/dist/exchanges/bitget/bitget-data-mapper.js.map +1 -0
- package/dist/exchanges/bitget/bitget-user-stream.d.ts +126 -0
- package/dist/exchanges/bitget/bitget-user-stream.d.ts.map +1 -0
- package/dist/exchanges/bitget/bitget-user-stream.js +474 -0
- package/dist/exchanges/bitget/bitget-user-stream.js.map +1 -0
- package/dist/exchanges/bitget/bitget-utils.d.ts +17 -0
- package/dist/exchanges/bitget/bitget-utils.d.ts.map +1 -0
- package/dist/exchanges/bitget/bitget-utils.js +60 -0
- package/dist/exchanges/bitget/bitget-utils.js.map +1 -0
- package/dist/exchanges/bitget/bitget-websocket.d.ts +124 -0
- package/dist/exchanges/bitget/bitget-websocket.d.ts.map +1 -0
- package/dist/exchanges/bitget/bitget-websocket.js +434 -0
- package/dist/exchanges/bitget/bitget-websocket.js.map +1 -0
- package/dist/exchanges/gateio/gateio-auth.d.ts +69 -0
- package/dist/exchanges/gateio/gateio-auth.d.ts.map +1 -0
- package/dist/exchanges/gateio/gateio-auth.js +205 -0
- package/dist/exchanges/gateio/gateio-auth.js.map +1 -0
- package/dist/exchanges/gateio/gateio-connector.d.ts +182 -0
- package/dist/exchanges/gateio/gateio-connector.d.ts.map +1 -0
- package/dist/exchanges/gateio/gateio-connector.js +605 -0
- package/dist/exchanges/gateio/gateio-connector.js.map +1 -0
- package/dist/exchanges/gateio/gateio-data-mapper.d.ts +57 -0
- package/dist/exchanges/gateio/gateio-data-mapper.d.ts.map +1 -0
- package/dist/exchanges/gateio/gateio-data-mapper.js +184 -0
- package/dist/exchanges/gateio/gateio-data-mapper.js.map +1 -0
- package/dist/exchanges/gateio/gateio-user-stream.d.ts +120 -0
- package/dist/exchanges/gateio/gateio-user-stream.d.ts.map +1 -0
- package/dist/exchanges/gateio/gateio-user-stream.js +384 -0
- package/dist/exchanges/gateio/gateio-user-stream.js.map +1 -0
- package/dist/exchanges/gateio/gateio-utils.d.ts +45 -0
- package/dist/exchanges/gateio/gateio-utils.d.ts.map +1 -0
- package/dist/exchanges/gateio/gateio-utils.js +138 -0
- package/dist/exchanges/gateio/gateio-utils.js.map +1 -0
- package/dist/exchanges/gateio/gateio-websocket.d.ts +145 -0
- package/dist/exchanges/gateio/gateio-websocket.d.ts.map +1 -0
- package/dist/exchanges/gateio/gateio-websocket.js +469 -0
- package/dist/exchanges/gateio/gateio-websocket.js.map +1 -0
- package/dist/exchanges/kraken/kraken-auth.d.ts +12 -0
- package/dist/exchanges/kraken/kraken-auth.d.ts.map +1 -0
- package/dist/exchanges/kraken/kraken-auth.js +68 -0
- package/dist/exchanges/kraken/kraken-auth.js.map +1 -0
- package/dist/exchanges/kraken/kraken-connector.d.ts +38 -0
- package/dist/exchanges/kraken/kraken-connector.d.ts.map +1 -0
- package/dist/exchanges/kraken/kraken-connector.js +355 -0
- package/dist/exchanges/kraken/kraken-connector.js.map +1 -0
- package/dist/exchanges/kraken/kraken-data-mapper.d.ts +14 -0
- package/dist/exchanges/kraken/kraken-data-mapper.d.ts.map +1 -0
- package/dist/exchanges/kraken/kraken-data-mapper.js +169 -0
- package/dist/exchanges/kraken/kraken-data-mapper.js.map +1 -0
- package/dist/exchanges/kraken/kraken-utils.d.ts +52 -0
- package/dist/exchanges/kraken/kraken-utils.d.ts.map +1 -0
- package/dist/exchanges/kraken/kraken-utils.js +206 -0
- package/dist/exchanges/kraken/kraken-utils.js.map +1 -0
- package/dist/exchanges/kraken/kraken-websocket.d.ts +64 -0
- package/dist/exchanges/kraken/kraken-websocket.d.ts.map +1 -0
- package/dist/exchanges/kraken/kraken-websocket.js +667 -0
- package/dist/exchanges/kraken/kraken-websocket.js.map +1 -0
- package/dist/exchanges/kraken/test-kraken-websocket.d.ts +19 -0
- package/dist/exchanges/kraken/test-kraken-websocket.d.ts.map +1 -0
- package/dist/exchanges/kraken/test-kraken-websocket.js +413 -0
- package/dist/exchanges/kraken/test-kraken-websocket.js.map +1 -0
- package/dist/exchanges/mexc/mexc-auth.d.ts.map +1 -1
- package/dist/exchanges/mexc/mexc-auth.js +5 -5
- package/dist/exchanges/mexc/mexc-auth.js.map +1 -1
- package/dist/exchanges/mexc/mexc-connector.d.ts.map +1 -1
- package/dist/exchanges/mexc/mexc-connector.js +12 -13
- package/dist/exchanges/mexc/mexc-connector.js.map +1 -1
- package/dist/exchanges/mexc/mexc-data-mapper.d.ts.map +1 -1
- package/dist/exchanges/mexc/mexc-data-mapper.js +6 -6
- package/dist/exchanges/mexc/mexc-data-mapper.js.map +1 -1
- package/dist/exchanges/mexc/mexc-protobuf-decoder.d.ts.map +1 -1
- package/dist/exchanges/mexc/mexc-protobuf-decoder.js +14 -13
- package/dist/exchanges/mexc/mexc-protobuf-decoder.js.map +1 -1
- package/dist/exchanges/mexc/mexc-user-stream.d.ts.map +1 -1
- package/dist/exchanges/mexc/mexc-user-stream.js +5 -5
- package/dist/exchanges/mexc/mexc-user-stream.js.map +1 -1
- package/dist/exchanges/mexc/mexc-utils.d.ts +1 -5
- package/dist/exchanges/mexc/mexc-utils.d.ts.map +1 -1
- package/dist/exchanges/mexc/mexc-utils.js +33 -39
- package/dist/exchanges/mexc/mexc-utils.js.map +1 -1
- package/dist/exchanges/mexc/mexc-websocket.d.ts.map +1 -1
- package/dist/exchanges/mexc/mexc-websocket.js +45 -31
- package/dist/exchanges/mexc/mexc-websocket.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/resources/index.d.ts +3 -0
- package/dist/mcp/resources/index.d.ts.map +1 -0
- package/dist/mcp/resources/index.js +11 -0
- package/dist/mcp/resources/index.js.map +1 -0
- package/dist/mcp/server.d.ts +4 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +29 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +3 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +12 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/strategies/grid/grid-calculator.d.ts +63 -4
- package/dist/strategies/grid/grid-calculator.d.ts.map +1 -1
- package/dist/strategies/grid/grid-calculator.js +190 -15
- package/dist/strategies/grid/grid-calculator.js.map +1 -1
- package/dist/strategies/grid/grid-order-manager.d.ts +9 -4
- package/dist/strategies/grid/grid-order-manager.d.ts.map +1 -1
- package/dist/strategies/grid/grid-order-manager.js +58 -15
- package/dist/strategies/grid/grid-order-manager.js.map +1 -1
- package/dist/strategies/grid/grid-strategy.d.ts +11 -0
- package/dist/strategies/grid/grid-strategy.d.ts.map +1 -1
- package/dist/strategies/grid/grid-strategy.js +127 -20
- package/dist/strategies/grid/grid-strategy.js.map +1 -1
- package/dist/strategies/grid/volatility-tracker.d.ts +67 -0
- package/dist/strategies/grid/volatility-tracker.d.ts.map +1 -0
- package/dist/strategies/grid/volatility-tracker.js +109 -0
- package/dist/strategies/grid/volatility-tracker.js.map +1 -0
- package/dist/tests/fixtures/test-helpers.d.ts +5 -0
- package/dist/tests/fixtures/test-helpers.d.ts.map +1 -0
- package/dist/tests/fixtures/test-helpers.js +8 -0
- package/dist/tests/fixtures/test-helpers.js.map +1 -0
- package/dist/tests/integration/exchanges/mexc/mexc-integration.test.d.ts +2 -0
- package/dist/tests/integration/exchanges/mexc/mexc-integration.test.d.ts.map +1 -0
- package/dist/tests/integration/exchanges/mexc/mexc-integration.test.js +237 -0
- package/dist/tests/integration/exchanges/mexc/mexc-integration.test.js.map +1 -0
- package/dist/tests/integration/price-aggregation/cardano-price-service.test.d.ts +2 -0
- package/dist/tests/integration/price-aggregation/cardano-price-service.test.d.ts.map +1 -0
- package/dist/tests/integration/price-aggregation/cardano-price-service.test.js +57 -0
- package/dist/tests/integration/price-aggregation/cardano-price-service.test.js.map +1 -0
- package/dist/tests/integration/price-aggregation/price-aggregation-integration.test.d.ts +2 -0
- package/dist/tests/integration/price-aggregation/price-aggregation-integration.test.d.ts.map +1 -0
- package/dist/tests/integration/price-aggregation/price-aggregation-integration.test.js +141 -0
- package/dist/tests/integration/price-aggregation/price-aggregation-integration.test.js.map +1 -0
- package/dist/tests/integration/strategies/grid/grid-strategy-e2e.test.d.ts +2 -0
- package/dist/tests/integration/strategies/grid/grid-strategy-e2e.test.d.ts.map +1 -0
- package/dist/tests/integration/strategies/grid/grid-strategy-e2e.test.js +375 -0
- package/dist/tests/integration/strategies/grid/grid-strategy-e2e.test.js.map +1 -0
- package/dist/tests/unit/cli/exchange-factory.test.d.ts +2 -0
- package/dist/tests/unit/cli/exchange-factory.test.d.ts.map +1 -0
- package/dist/tests/unit/cli/exchange-factory.test.js +148 -0
- package/dist/tests/unit/cli/exchange-factory.test.js.map +1 -0
- package/dist/tests/unit/config/environment.test.d.ts +2 -0
- package/dist/tests/unit/config/environment.test.d.ts.map +1 -0
- package/dist/tests/unit/config/environment.test.js +158 -0
- package/dist/tests/unit/config/environment.test.js.map +1 -0
- package/dist/tests/unit/config/launcher-config.test.d.ts +2 -0
- package/dist/tests/unit/config/launcher-config.test.d.ts.map +1 -0
- package/dist/tests/unit/config/launcher-config.test.js +117 -0
- package/dist/tests/unit/config/launcher-config.test.js.map +1 -0
- package/dist/tests/unit/config/price-aggregation.test.d.ts +2 -0
- package/dist/tests/unit/config/price-aggregation.test.d.ts.map +1 -0
- package/dist/tests/unit/config/price-aggregation.test.js +144 -0
- package/dist/tests/unit/config/price-aggregation.test.js.map +1 -0
- package/dist/tests/unit/core/exchange/base-exchange-connector.test.d.ts +2 -0
- package/dist/tests/unit/core/exchange/base-exchange-connector.test.d.ts.map +1 -0
- package/dist/tests/unit/core/exchange/base-exchange-connector.test.js +191 -0
- package/dist/tests/unit/core/exchange/base-exchange-connector.test.js.map +1 -0
- package/dist/tests/unit/core/exchange/base-exchange-data-mapper.test.d.ts +2 -0
- package/dist/tests/unit/core/exchange/base-exchange-data-mapper.test.d.ts.map +1 -0
- package/dist/tests/unit/core/exchange/base-exchange-data-mapper.test.js +324 -0
- package/dist/tests/unit/core/exchange/base-exchange-data-mapper.test.js.map +1 -0
- package/dist/tests/unit/core/price-aggregation/cardano-price-service.test.d.ts +2 -0
- package/dist/tests/unit/core/price-aggregation/cardano-price-service.test.d.ts.map +1 -0
- package/dist/tests/unit/core/price-aggregation/cardano-price-service.test.js +177 -0
- package/dist/tests/unit/core/price-aggregation/cardano-price-service.test.js.map +1 -0
- package/dist/tests/unit/core/price-aggregation/iris-api-client.test.d.ts +2 -0
- package/dist/tests/unit/core/price-aggregation/iris-api-client.test.d.ts.map +1 -0
- package/dist/tests/unit/core/price-aggregation/iris-api-client.test.js +168 -0
- package/dist/tests/unit/core/price-aggregation/iris-api-client.test.js.map +1 -0
- package/dist/tests/unit/core/price-aggregation/iris-pool-discovery.test.d.ts +2 -0
- package/dist/tests/unit/core/price-aggregation/iris-pool-discovery.test.d.ts.map +1 -0
- package/dist/tests/unit/core/price-aggregation/iris-pool-discovery.test.js +217 -0
- package/dist/tests/unit/core/price-aggregation/iris-pool-discovery.test.js.map +1 -0
- package/dist/tests/unit/core/price-aggregation/price-calculator.test.d.ts +2 -0
- package/dist/tests/unit/core/price-aggregation/price-calculator.test.d.ts.map +1 -0
- package/dist/tests/unit/core/price-aggregation/price-calculator.test.js +229 -0
- package/dist/tests/unit/core/price-aggregation/price-calculator.test.js.map +1 -0
- package/dist/tests/unit/core/risk-management/risk-manager.test.d.ts +2 -0
- package/dist/tests/unit/core/risk-management/risk-manager.test.d.ts.map +1 -0
- package/dist/tests/unit/core/risk-management/risk-manager.test.js +194 -0
- package/dist/tests/unit/core/risk-management/risk-manager.test.js.map +1 -0
- package/dist/tests/unit/core/strategy/base-strategy.test.d.ts +2 -0
- package/dist/tests/unit/core/strategy/base-strategy.test.d.ts.map +1 -0
- package/dist/tests/unit/core/strategy/base-strategy.test.js +254 -0
- package/dist/tests/unit/core/strategy/base-strategy.test.js.map +1 -0
- package/dist/tests/unit/core/strategy/strategy-factory.test.d.ts +2 -0
- package/dist/tests/unit/core/strategy/strategy-factory.test.d.ts.map +1 -0
- package/dist/tests/unit/core/strategy/strategy-factory.test.js +213 -0
- package/dist/tests/unit/core/strategy/strategy-factory.test.js.map +1 -0
- package/dist/tests/unit/exchanges/mexc/mexc-auth.test.d.ts +2 -0
- package/dist/tests/unit/exchanges/mexc/mexc-auth.test.d.ts.map +1 -0
- package/dist/tests/unit/exchanges/mexc/mexc-auth.test.js +452 -0
- package/dist/tests/unit/exchanges/mexc/mexc-auth.test.js.map +1 -0
- package/dist/tests/unit/exchanges/mexc/mexc-connector.test.d.ts +2 -0
- package/dist/tests/unit/exchanges/mexc/mexc-connector.test.d.ts.map +1 -0
- package/dist/tests/unit/exchanges/mexc/mexc-connector.test.js +1419 -0
- package/dist/tests/unit/exchanges/mexc/mexc-connector.test.js.map +1 -0
- package/dist/tests/unit/exchanges/mexc/mexc-data-mapper.test.d.ts +2 -0
- package/dist/tests/unit/exchanges/mexc/mexc-data-mapper.test.d.ts.map +1 -0
- package/dist/tests/unit/exchanges/mexc/mexc-data-mapper.test.js +435 -0
- package/dist/tests/unit/exchanges/mexc/mexc-data-mapper.test.js.map +1 -0
- package/dist/tests/unit/exchanges/mexc/mexc-protobuf-decoder.test.d.ts +2 -0
- package/dist/tests/unit/exchanges/mexc/mexc-protobuf-decoder.test.d.ts.map +1 -0
- package/dist/tests/unit/exchanges/mexc/mexc-protobuf-decoder.test.js +314 -0
- package/dist/tests/unit/exchanges/mexc/mexc-protobuf-decoder.test.js.map +1 -0
- package/dist/tests/unit/exchanges/mexc/mexc-protobuf-status-detection.test.d.ts +2 -0
- package/dist/tests/unit/exchanges/mexc/mexc-protobuf-status-detection.test.d.ts.map +1 -0
- package/dist/tests/unit/exchanges/mexc/mexc-protobuf-status-detection.test.js +178 -0
- package/dist/tests/unit/exchanges/mexc/mexc-protobuf-status-detection.test.js.map +1 -0
- package/dist/tests/unit/exchanges/mexc/mexc-user-stream.test.d.ts +2 -0
- package/dist/tests/unit/exchanges/mexc/mexc-user-stream.test.d.ts.map +1 -0
- package/dist/tests/unit/exchanges/mexc/mexc-user-stream.test.js +502 -0
- package/dist/tests/unit/exchanges/mexc/mexc-user-stream.test.js.map +1 -0
- package/dist/tests/unit/exchanges/mexc/mexc-utils.test.d.ts +2 -0
- package/dist/tests/unit/exchanges/mexc/mexc-utils.test.d.ts.map +1 -0
- package/dist/tests/unit/exchanges/mexc/mexc-utils.test.js +317 -0
- package/dist/tests/unit/exchanges/mexc/mexc-utils.test.js.map +1 -0
- package/dist/tests/unit/exchanges/mexc/mexc-websocket.test.d.ts +2 -0
- package/dist/tests/unit/exchanges/mexc/mexc-websocket.test.d.ts.map +1 -0
- package/dist/tests/unit/exchanges/mexc/mexc-websocket.test.js +843 -0
- package/dist/tests/unit/exchanges/mexc/mexc-websocket.test.js.map +1 -0
- package/dist/tests/unit/strategies/grid/grid-calculator.test.d.ts +2 -0
- package/dist/tests/unit/strategies/grid/grid-calculator.test.d.ts.map +1 -0
- package/dist/tests/unit/strategies/grid/grid-calculator.test.js +67 -0
- package/dist/tests/unit/strategies/grid/grid-calculator.test.js.map +1 -0
- package/dist/tests/unit/strategies/grid/grid-order-manager.test.d.ts +2 -0
- package/dist/tests/unit/strategies/grid/grid-order-manager.test.d.ts.map +1 -0
- package/dist/tests/unit/strategies/grid/grid-order-manager.test.js +211 -0
- package/dist/tests/unit/strategies/grid/grid-order-manager.test.js.map +1 -0
- package/dist/tests/unit/strategies/grid/grid-strategy-simple.test.d.ts +2 -0
- package/dist/tests/unit/strategies/grid/grid-strategy-simple.test.d.ts.map +1 -0
- package/dist/tests/unit/strategies/grid/grid-strategy-simple.test.js +197 -0
- package/dist/tests/unit/strategies/grid/grid-strategy-simple.test.js.map +1 -0
- package/dist/tests/unit/strategies/grid/grid-strategy.test.d.ts +2 -0
- package/dist/tests/unit/strategies/grid/grid-strategy.test.d.ts.map +1 -0
- package/dist/tests/unit/strategies/grid/grid-strategy.test.js +429 -0
- package/dist/tests/unit/strategies/grid/grid-strategy.test.js.map +1 -0
- package/dist/tests/unit/utils/logger.test.d.ts +2 -0
- package/dist/tests/unit/utils/logger.test.d.ts.map +1 -0
- package/dist/tests/unit/utils/logger.test.js +260 -0
- package/dist/tests/unit/utils/logger.test.js.map +1 -0
- package/dist/tests/unit/utils/symbol-utils.test.d.ts +2 -0
- package/dist/tests/unit/utils/symbol-utils.test.d.ts.map +1 -0
- package/dist/tests/unit/utils/symbol-utils.test.js +178 -0
- package/dist/tests/unit/utils/symbol-utils.test.js.map +1 -0
- package/dist/types/bitget-raw.d.ts +75 -0
- package/dist/types/bitget-raw.d.ts.map +1 -0
- package/dist/types/bitget-raw.js +10 -0
- package/dist/types/bitget-raw.js.map +1 -0
- package/dist/types/bitget.d.ts +35 -0
- package/dist/types/bitget.d.ts.map +1 -0
- package/dist/types/bitget.js +8 -0
- package/dist/types/bitget.js.map +1 -0
- package/dist/types/gateio-raw.d.ts +104 -0
- package/dist/types/gateio-raw.d.ts.map +1 -0
- package/dist/types/gateio-raw.js +7 -0
- package/dist/types/gateio-raw.js.map +1 -0
- package/dist/types/gateio.d.ts +41 -0
- package/dist/types/gateio.d.ts.map +1 -0
- package/dist/types/gateio.js +8 -0
- package/dist/types/gateio.js.map +1 -0
- package/dist/types/grid.d.ts +77 -0
- package/dist/types/grid.d.ts.map +1 -1
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/kraken-raw.d.ts +89 -0
- package/dist/types/kraken-raw.d.ts.map +1 -0
- package/dist/types/kraken-raw.js +10 -0
- package/dist/types/kraken-raw.js.map +1 -0
- package/dist/types/kraken.d.ts +44 -0
- package/dist/types/kraken.d.ts.map +1 -0
- package/dist/types/kraken.js +3 -0
- package/dist/types/kraken.js.map +1 -0
- package/dist/types/mexc.d.ts +9 -0
- package/dist/types/mexc.d.ts.map +1 -1
- package/dist/types/price-aggregation.d.ts +31 -0
- package/dist/types/price-aggregation.d.ts.map +1 -0
- package/dist/types/price-aggregation.js +6 -0
- package/dist/types/price-aggregation.js.map +1 -0
- package/dist/types/price.d.ts +23 -0
- package/dist/types/price.d.ts.map +1 -1
- package/dist/types/strategy.d.ts +5 -0
- package/dist/types/strategy.d.ts.map +1 -1
- package/dist/utils/crypto.d.ts +15 -0
- package/dist/utils/crypto.d.ts.map +1 -0
- package/dist/utils/crypto.js +50 -0
- package/dist/utils/crypto.js.map +1 -0
- package/dist/utils/exchange-utils.d.ts +194 -0
- package/dist/utils/exchange-utils.d.ts.map +1 -0
- package/dist/utils/exchange-utils.js +455 -0
- package/dist/utils/exchange-utils.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/logger.d.ts +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +7 -7
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/validation.d.ts +36 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +174 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +7 -1
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BitgetConnector = void 0;
|
|
7
|
+
const base_exchange_connector_1 = require("../../core/exchange/base-exchange-connector");
|
|
8
|
+
const bitget_auth_1 = require("./bitget-auth");
|
|
9
|
+
const bitget_utils_1 = require("./bitget-utils");
|
|
10
|
+
const bitget_data_mapper_1 = require("./bitget-data-mapper");
|
|
11
|
+
const bitget_websocket_1 = require("./bitget-websocket");
|
|
12
|
+
const bitget_user_stream_1 = require("./bitget-user-stream");
|
|
13
|
+
const utils_1 = require("../../utils");
|
|
14
|
+
const symbol_utils_1 = require("../../utils/symbol-utils");
|
|
15
|
+
const environment_1 = __importDefault(require("../../config/environment"));
|
|
16
|
+
/**
|
|
17
|
+
* Bitget Exchange Connector
|
|
18
|
+
*
|
|
19
|
+
* Implements the BaseExchangeConnector interface for Bitget exchange.
|
|
20
|
+
* Provides trading operations, market data access, and WebSocket streaming.
|
|
21
|
+
*/
|
|
22
|
+
class BitgetConnector extends base_exchange_connector_1.BaseExchangeConnector {
|
|
23
|
+
constructor() {
|
|
24
|
+
super('bitget', 'Bitget');
|
|
25
|
+
this.logger = (0, utils_1.createLogger)('bitget-connector');
|
|
26
|
+
this.baseUrl = 'https://api.bitget.com';
|
|
27
|
+
this.dataMapper = new bitget_data_mapper_1.BitgetDataMapper();
|
|
28
|
+
this.logger.info('BitgetConnector initialized');
|
|
29
|
+
if (environment_1.default.bitget) {
|
|
30
|
+
this.setCredentials({
|
|
31
|
+
apiKey: environment_1.default.bitget.apiKey,
|
|
32
|
+
secret: environment_1.default.bitget.secret,
|
|
33
|
+
passphrase: environment_1.default.bitget.passphrase,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Set API credentials and initialize authentication handler
|
|
39
|
+
*
|
|
40
|
+
* @param credentials - Bitget API credentials including apiKey, secret, and passphrase
|
|
41
|
+
* @throws Error if credentials are missing required Bitget fields (passphrase)
|
|
42
|
+
*/
|
|
43
|
+
setCredentials(credentials) {
|
|
44
|
+
super.setCredentials(credentials);
|
|
45
|
+
if (!this.isValidBitgetCredentials(credentials)) {
|
|
46
|
+
throw new Error('Invalid Bitget credentials: missing passphrase');
|
|
47
|
+
}
|
|
48
|
+
this.auth = new bitget_auth_1.BitgetAuth(credentials, this.baseUrl);
|
|
49
|
+
this.logger.info('Bitget credentials set and authentication initialized');
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Connect to Bitget API by testing server time and validating credentials
|
|
53
|
+
*
|
|
54
|
+
* @returns Promise that resolves when successfully connected to Bitget API
|
|
55
|
+
* @throws Error if connection fails or credentials are invalid
|
|
56
|
+
*/
|
|
57
|
+
async connect() {
|
|
58
|
+
try {
|
|
59
|
+
this.logger.info('Connecting to Bitget API...');
|
|
60
|
+
const credentials = this.getCredentials();
|
|
61
|
+
this.auth = new bitget_auth_1.BitgetAuth(credentials, this.baseUrl);
|
|
62
|
+
const timeResponse = await this.auth.makePublicRequest('/api/v2/public/time');
|
|
63
|
+
if (!timeResponse || !timeResponse.data) {
|
|
64
|
+
throw new Error('Invalid response from Bitget time endpoint');
|
|
65
|
+
}
|
|
66
|
+
if (!this.auth.validateCredentialsExist()) {
|
|
67
|
+
this.connected = false;
|
|
68
|
+
this.handleError(new Error('Invalid Bitget credentials'), 'connect');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
await this.auth.makeRequest('/api/v2/spot/account/assets');
|
|
73
|
+
}
|
|
74
|
+
catch (credError) {
|
|
75
|
+
if (credError instanceof Error) {
|
|
76
|
+
const errorMessage = bitget_utils_1.BitgetUtils.mapErrorMessage(credError);
|
|
77
|
+
throw new Error(`Credentials validation failed: ${errorMessage}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
this.connected = true;
|
|
81
|
+
this.logger.info('Successfully connected to Bitget API', {
|
|
82
|
+
serverTime: timeResponse.data.serverTime,
|
|
83
|
+
localTime: Date.now(),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
this.connected = false;
|
|
88
|
+
this.handleError(error, 'connect');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Disconnect from Bitget API and clean up resources
|
|
93
|
+
*
|
|
94
|
+
* @returns Promise that resolves when successfully disconnected from Bitget API
|
|
95
|
+
*/
|
|
96
|
+
async disconnect() {
|
|
97
|
+
try {
|
|
98
|
+
this.logger.info('Disconnecting from Bitget API...');
|
|
99
|
+
// Disconnect WebSocket if connected
|
|
100
|
+
await this.disconnectWebSocket();
|
|
101
|
+
await this.disconnectUserDataStream();
|
|
102
|
+
this.connected = false;
|
|
103
|
+
this.auth = undefined;
|
|
104
|
+
this.userStream = undefined;
|
|
105
|
+
this.logger.info('Successfully disconnected from Bitget API');
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
this.handleError(error, 'disconnect');
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Validate if credentials contain required Bitget fields
|
|
113
|
+
*/
|
|
114
|
+
isValidBitgetCredentials(credentials) {
|
|
115
|
+
return !!credentials.passphrase;
|
|
116
|
+
}
|
|
117
|
+
async getBalance(asset) {
|
|
118
|
+
try {
|
|
119
|
+
const assetsData = await this.makeRequest('/api/v2/spot/account/assets');
|
|
120
|
+
if (!assetsData || !assetsData.data) {
|
|
121
|
+
throw new Error('Invalid response from Bitget assets endpoint');
|
|
122
|
+
}
|
|
123
|
+
const balances = {};
|
|
124
|
+
for (const assetInfo of assetsData.data) {
|
|
125
|
+
const available = parseFloat(assetInfo.available || '0');
|
|
126
|
+
const frozen = parseFloat(assetInfo.frozen || '0');
|
|
127
|
+
const total = available + frozen;
|
|
128
|
+
balances[assetInfo.coin] = {
|
|
129
|
+
asset: assetInfo.coin,
|
|
130
|
+
free: available,
|
|
131
|
+
used: frozen,
|
|
132
|
+
total: total,
|
|
133
|
+
available: available,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
if (asset) {
|
|
137
|
+
return (balances[asset] || {
|
|
138
|
+
asset,
|
|
139
|
+
free: 0,
|
|
140
|
+
used: 0,
|
|
141
|
+
total: 0,
|
|
142
|
+
available: 0,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return balances;
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
const errorMessage = bitget_utils_1.BitgetUtils.mapErrorMessage(error);
|
|
149
|
+
this.handleError(new Error(errorMessage), 'getBalance');
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Create a new order on Bitget exchange
|
|
154
|
+
*
|
|
155
|
+
* @param symbol - Trading pair symbol (e.g., 'SNEK/USDT')
|
|
156
|
+
* @param type - Order type ('market' or 'limit')
|
|
157
|
+
* @param side - Order side ('buy' or 'sell')
|
|
158
|
+
* @param amount - Order quantity/amount
|
|
159
|
+
* @param price - Optional. Price for limit orders (required for limit orders)
|
|
160
|
+
* @returns Promise resolving to the created order details
|
|
161
|
+
* @throws Error if order creation fails or parameters are invalid
|
|
162
|
+
*/
|
|
163
|
+
async createOrder(symbol, type, side, amount, price) {
|
|
164
|
+
try {
|
|
165
|
+
if (!utils_1.ExchangeUtils.isValidSymbol(symbol)) {
|
|
166
|
+
throw new Error(`Invalid symbol format: ${symbol}`);
|
|
167
|
+
}
|
|
168
|
+
const orderParams = utils_1.ExchangeUtils.createBitgetOrderParams(symbol, type, side, amount, price);
|
|
169
|
+
const response = await this.makeRequest('/api/v2/spot/trade/place-order', {}, 'POST', orderParams);
|
|
170
|
+
if (!response || !response.data) {
|
|
171
|
+
throw new Error('Invalid response from Bitget place-order endpoint');
|
|
172
|
+
}
|
|
173
|
+
const orderData = {
|
|
174
|
+
orderId: response.data.orderId,
|
|
175
|
+
clientOid: response.data.clientOid,
|
|
176
|
+
symbol: (0, symbol_utils_1.toExchangeFormat)(symbol),
|
|
177
|
+
side: side.toLowerCase(),
|
|
178
|
+
orderType: type.toLowerCase(),
|
|
179
|
+
force: 'gtc',
|
|
180
|
+
price: price?.toString(),
|
|
181
|
+
size: amount.toString(),
|
|
182
|
+
filledQty: '0',
|
|
183
|
+
state: 'NEW',
|
|
184
|
+
cTime: Date.now(),
|
|
185
|
+
};
|
|
186
|
+
return this.dataMapper.mapOrder(orderData);
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
const errorMessage = bitget_utils_1.BitgetUtils.mapErrorMessage(error);
|
|
190
|
+
this.handleError(new Error(errorMessage), 'createOrder');
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Cancel an existing order on Bitget exchange
|
|
195
|
+
*
|
|
196
|
+
* @param orderId - The ID of the order to cancel
|
|
197
|
+
* @param symbol - Trading pair symbol (e.g., 'SNEK/USDT')
|
|
198
|
+
* @returns Promise that resolves when order is successfully cancelled
|
|
199
|
+
* @throws Error if cancellation fails or order not found
|
|
200
|
+
*/
|
|
201
|
+
async cancelOrder(orderId, symbol) {
|
|
202
|
+
try {
|
|
203
|
+
if (!orderId) {
|
|
204
|
+
throw new Error('Order ID is required');
|
|
205
|
+
}
|
|
206
|
+
if (!utils_1.ExchangeUtils.isValidSymbol(symbol)) {
|
|
207
|
+
throw new Error(`Invalid symbol format: ${symbol}`);
|
|
208
|
+
}
|
|
209
|
+
const bitgetSymbol = (0, symbol_utils_1.toExchangeFormat)(symbol);
|
|
210
|
+
const response = await this.makeRequest('/api/v2/spot/trade/cancel-order', {}, 'POST', {
|
|
211
|
+
symbol: bitgetSymbol,
|
|
212
|
+
orderId: orderId,
|
|
213
|
+
});
|
|
214
|
+
if (!response || response.code !== '00000') {
|
|
215
|
+
throw new Error('Failed to cancel order');
|
|
216
|
+
}
|
|
217
|
+
this.logger.info('Order cancelled successfully', {
|
|
218
|
+
orderId,
|
|
219
|
+
symbol: bitgetSymbol,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
const errorMessage = bitget_utils_1.BitgetUtils.mapErrorMessage(error);
|
|
224
|
+
this.handleError(new Error(errorMessage), 'cancelOrder');
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Cancel all open orders for a specific symbol
|
|
229
|
+
*
|
|
230
|
+
* @param symbol - Trading pair symbol (e.g., 'SNEK/USDT')
|
|
231
|
+
* @returns Promise that resolves when all orders are cancelled
|
|
232
|
+
* @throws Error if cancellation fails
|
|
233
|
+
*/
|
|
234
|
+
async cancelAllOrders(symbol) {
|
|
235
|
+
try {
|
|
236
|
+
if (!utils_1.ExchangeUtils.isValidSymbol(symbol)) {
|
|
237
|
+
throw new Error(`Invalid symbol format: ${symbol}`);
|
|
238
|
+
}
|
|
239
|
+
const bitgetSymbol = (0, symbol_utils_1.toExchangeFormat)(symbol);
|
|
240
|
+
try {
|
|
241
|
+
const response = await this.makeRequest('/api/v2/spot/trade/cancel-symbol-order', {}, 'POST', {
|
|
242
|
+
symbol: bitgetSymbol,
|
|
243
|
+
});
|
|
244
|
+
if (response && response.code === '00000') {
|
|
245
|
+
this.logger.info('All orders cancelled successfully via bulk operation', {
|
|
246
|
+
symbol: bitgetSymbol,
|
|
247
|
+
});
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
catch (bulkError) {
|
|
252
|
+
this.logger.warn('Bulk cancellation failed, falling back to individual cancellation', {
|
|
253
|
+
symbol: bitgetSymbol,
|
|
254
|
+
error: bulkError instanceof Error ? bulkError.message : String(bulkError),
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
const openOrders = await this.getOpenOrders(symbol);
|
|
258
|
+
if (openOrders.length === 0) {
|
|
259
|
+
this.logger.info('No open orders to cancel', { symbol: bitgetSymbol });
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const cancelPromises = openOrders.map(order => this.cancelOrder(order.id, symbol).catch(error => {
|
|
263
|
+
this.logger.error(`Failed to cancel order ${order.id}`, {
|
|
264
|
+
error: error instanceof Error ? error.message : String(error),
|
|
265
|
+
});
|
|
266
|
+
throw error;
|
|
267
|
+
}));
|
|
268
|
+
await Promise.all(cancelPromises);
|
|
269
|
+
this.logger.info(`Successfully cancelled ${openOrders.length} orders`, {
|
|
270
|
+
symbol: bitgetSymbol,
|
|
271
|
+
orderCount: openOrders.length,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
catch (error) {
|
|
275
|
+
const errorMessage = bitget_utils_1.BitgetUtils.mapErrorMessage(error);
|
|
276
|
+
this.handleError(new Error(errorMessage), 'cancelAllOrders');
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Get details of a specific order by ID
|
|
281
|
+
*
|
|
282
|
+
* @param orderId - The ID of the order to retrieve
|
|
283
|
+
* @param symbol - Trading pair symbol (e.g., 'SNEK/USDT')
|
|
284
|
+
* @returns Promise resolving to order details
|
|
285
|
+
* @throws Error if order not found or request fails
|
|
286
|
+
*/
|
|
287
|
+
async getOrder(orderId, symbol) {
|
|
288
|
+
try {
|
|
289
|
+
if (!orderId) {
|
|
290
|
+
throw new Error('Order ID is required');
|
|
291
|
+
}
|
|
292
|
+
if (!utils_1.ExchangeUtils.isValidSymbol(symbol)) {
|
|
293
|
+
throw new Error(`Invalid symbol format: ${symbol}`);
|
|
294
|
+
}
|
|
295
|
+
const bitgetSymbol = (0, symbol_utils_1.toExchangeFormat)(symbol);
|
|
296
|
+
const response = await this.makeRequest('/api/v2/spot/trade/orderInfo', {
|
|
297
|
+
symbol: bitgetSymbol,
|
|
298
|
+
orderId: orderId,
|
|
299
|
+
});
|
|
300
|
+
if (!response || !response.data) {
|
|
301
|
+
throw new Error('Order not found');
|
|
302
|
+
}
|
|
303
|
+
return this.dataMapper.mapOrder(response.data);
|
|
304
|
+
}
|
|
305
|
+
catch (error) {
|
|
306
|
+
const errorMessage = bitget_utils_1.BitgetUtils.mapErrorMessage(error);
|
|
307
|
+
this.handleError(new Error(errorMessage), 'getOrder');
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Get all open orders, optionally filtered by symbol
|
|
312
|
+
*
|
|
313
|
+
* @param symbol - Optional. Trading pair symbol to filter orders (e.g., 'SNEK/USDT')
|
|
314
|
+
* @returns Promise resolving to array of open orders
|
|
315
|
+
* @throws Error if request fails
|
|
316
|
+
*/
|
|
317
|
+
async getOpenOrders(symbol) {
|
|
318
|
+
try {
|
|
319
|
+
const params = {};
|
|
320
|
+
if (symbol) {
|
|
321
|
+
if (!bitget_utils_1.BitgetUtils.isValidSymbol(symbol)) {
|
|
322
|
+
throw new Error(`Invalid symbol format: ${symbol}`);
|
|
323
|
+
}
|
|
324
|
+
params.symbol = (0, symbol_utils_1.toExchangeFormat)(symbol);
|
|
325
|
+
}
|
|
326
|
+
const response = await this.makeRequest('/api/v2/spot/trade/unfilled-orders', params);
|
|
327
|
+
if (!response || !Array.isArray(response.data)) {
|
|
328
|
+
return [];
|
|
329
|
+
}
|
|
330
|
+
return response.data.map((orderData) => this.dataMapper.mapOrder(orderData));
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
const errorMessage = bitget_utils_1.BitgetUtils.mapErrorMessage(error);
|
|
334
|
+
this.handleError(new Error(errorMessage), 'getOpenOrders');
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Get ticker information for a trading pair
|
|
339
|
+
*
|
|
340
|
+
* @param symbol - Trading pair symbol (e.g., 'SNEK/USDT')
|
|
341
|
+
* @returns Promise resolving to ticker data including prices and volume
|
|
342
|
+
* @throws Error if ticker data not found or request fails
|
|
343
|
+
*/
|
|
344
|
+
async getTicker(symbol) {
|
|
345
|
+
try {
|
|
346
|
+
if (!utils_1.ExchangeUtils.isValidSymbol(symbol)) {
|
|
347
|
+
throw new Error(`Invalid symbol format: ${symbol}`);
|
|
348
|
+
}
|
|
349
|
+
const bitgetSymbol = (0, symbol_utils_1.toExchangeFormat)(symbol);
|
|
350
|
+
const response = await this.makePublicRequest('/api/v2/spot/market/tickers', {
|
|
351
|
+
symbol: bitgetSymbol,
|
|
352
|
+
});
|
|
353
|
+
if (!response ||
|
|
354
|
+
!response.data ||
|
|
355
|
+
!Array.isArray(response.data) ||
|
|
356
|
+
response.data.length === 0) {
|
|
357
|
+
throw new Error('No ticker data found');
|
|
358
|
+
}
|
|
359
|
+
return this.dataMapper.mapTicker(response.data[0]);
|
|
360
|
+
}
|
|
361
|
+
catch (error) {
|
|
362
|
+
const errorMessage = bitget_utils_1.BitgetUtils.mapErrorMessage(error);
|
|
363
|
+
this.handleError(new Error(errorMessage), 'getTicker');
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Get order book data for a trading pair
|
|
368
|
+
*
|
|
369
|
+
* @param symbol - Trading pair symbol (e.g., 'SNEK/USDT')
|
|
370
|
+
* @returns Promise resolving to order book with bids and asks
|
|
371
|
+
* @throws Error if order book data not found or request fails
|
|
372
|
+
*/
|
|
373
|
+
async getOrderBook(symbol) {
|
|
374
|
+
try {
|
|
375
|
+
if (!utils_1.ExchangeUtils.isValidSymbol(symbol)) {
|
|
376
|
+
throw new Error(`Invalid symbol format: ${symbol}`);
|
|
377
|
+
}
|
|
378
|
+
const bitgetSymbol = (0, symbol_utils_1.toExchangeFormat)(symbol);
|
|
379
|
+
const response = await this.makePublicRequest('/api/v2/spot/market/orderbook', {
|
|
380
|
+
symbol: bitgetSymbol,
|
|
381
|
+
type: 'step0',
|
|
382
|
+
limit: '100',
|
|
383
|
+
});
|
|
384
|
+
if (!response || !response.data) {
|
|
385
|
+
throw new Error('No orderbook data found');
|
|
386
|
+
}
|
|
387
|
+
return this.dataMapper.mapOrderBook(response.data, symbol);
|
|
388
|
+
}
|
|
389
|
+
catch (error) {
|
|
390
|
+
const errorMessage = bitget_utils_1.BitgetUtils.mapErrorMessage(error);
|
|
391
|
+
this.handleError(new Error(errorMessage), 'getOrderBook');
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Get recent trades for a trading pair
|
|
396
|
+
*
|
|
397
|
+
* @param symbol - Trading pair symbol (e.g., 'SNEK/USDT')
|
|
398
|
+
* @returns Promise resolving to array of recent trade executions
|
|
399
|
+
* @throws Error if request fails
|
|
400
|
+
*/
|
|
401
|
+
async getRecentTrades(symbol) {
|
|
402
|
+
try {
|
|
403
|
+
if (!utils_1.ExchangeUtils.isValidSymbol(symbol)) {
|
|
404
|
+
throw new Error(`Invalid symbol format: ${symbol}`);
|
|
405
|
+
}
|
|
406
|
+
const bitgetSymbol = (0, symbol_utils_1.toExchangeFormat)(symbol);
|
|
407
|
+
const response = await this.makePublicRequest('/api/v2/spot/market/fills', {
|
|
408
|
+
symbol: bitgetSymbol,
|
|
409
|
+
limit: '100',
|
|
410
|
+
});
|
|
411
|
+
if (!response || !Array.isArray(response.data)) {
|
|
412
|
+
return [];
|
|
413
|
+
}
|
|
414
|
+
return response.data.map((tradeData) => this.dataMapper.mapTrade(tradeData, symbol));
|
|
415
|
+
}
|
|
416
|
+
catch (error) {
|
|
417
|
+
const errorMessage = bitget_utils_1.BitgetUtils.mapErrorMessage(error);
|
|
418
|
+
this.handleError(new Error(errorMessage), 'getRecentTrades');
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
// WebSocket Methods Implementation
|
|
422
|
+
/**
|
|
423
|
+
* Connect to Bitget WebSocket for real-time data
|
|
424
|
+
*
|
|
425
|
+
* @returns Promise that resolves when WebSocket connection is established
|
|
426
|
+
* @throws Error if connection fails
|
|
427
|
+
*/
|
|
428
|
+
async connectWebSocket() {
|
|
429
|
+
try {
|
|
430
|
+
if (!this.ws) {
|
|
431
|
+
this.ws = new bitget_websocket_1.BitgetWebSocket();
|
|
432
|
+
}
|
|
433
|
+
await this.ws.connectWebSocket();
|
|
434
|
+
this.logger.info('Successfully connected to Bitget WebSocket');
|
|
435
|
+
}
|
|
436
|
+
catch (error) {
|
|
437
|
+
this.handleError(error, 'connectWebSocket');
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Disconnect from Bitget WebSocket
|
|
442
|
+
*
|
|
443
|
+
* @returns Promise that resolves when WebSocket is disconnected
|
|
444
|
+
*/
|
|
445
|
+
async disconnectWebSocket() {
|
|
446
|
+
try {
|
|
447
|
+
if (this.ws) {
|
|
448
|
+
await this.ws.disconnectWebSocket();
|
|
449
|
+
this.ws = undefined;
|
|
450
|
+
this.logger.info('Successfully disconnected from Bitget WebSocket');
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
catch (error) {
|
|
454
|
+
this.handleError(error, 'disconnectWebSocket');
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Subscribe to real-time ticker updates for a trading pair
|
|
459
|
+
*
|
|
460
|
+
* @param symbol - Trading pair symbol (e.g., 'SNEK/USDT')
|
|
461
|
+
* @param callback - Function called when ticker updates are received
|
|
462
|
+
* @returns Promise resolving to subscription ID for managing the subscription
|
|
463
|
+
* @throws Error if WebSocket not connected or subscription fails
|
|
464
|
+
*/
|
|
465
|
+
async subscribeTicker(symbol, callback) {
|
|
466
|
+
try {
|
|
467
|
+
if (!this.ws) {
|
|
468
|
+
throw new Error('WebSocket not initialized. Call connectWebSocket() first.');
|
|
469
|
+
}
|
|
470
|
+
return await this.ws.subscribeTicker(symbol, callback);
|
|
471
|
+
}
|
|
472
|
+
catch (error) {
|
|
473
|
+
this.handleError(error, 'subscribeTicker');
|
|
474
|
+
return '';
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Subscribe to real-time order book updates for a trading pair
|
|
479
|
+
*
|
|
480
|
+
* @param symbol - Trading pair symbol (e.g., 'SNEK/USDT')
|
|
481
|
+
* @param callback - Function called when order book updates are received
|
|
482
|
+
* @returns Promise resolving to subscription ID for managing the subscription
|
|
483
|
+
* @throws Error if WebSocket not connected or subscription fails
|
|
484
|
+
*/
|
|
485
|
+
async subscribeOrderBook(symbol, callback) {
|
|
486
|
+
try {
|
|
487
|
+
if (!this.ws) {
|
|
488
|
+
throw new Error('WebSocket not initialized. Call connectWebSocket() first.');
|
|
489
|
+
}
|
|
490
|
+
return await this.ws.subscribeOrderBook(symbol, callback);
|
|
491
|
+
}
|
|
492
|
+
catch (error) {
|
|
493
|
+
this.handleError(error, 'subscribeOrderBook');
|
|
494
|
+
return '';
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Subscribe to real-time trade updates for a trading pair
|
|
499
|
+
*
|
|
500
|
+
* @param symbol - Trading pair symbol (e.g., 'SNEK/USDT')
|
|
501
|
+
* @param callback - Function called when new trades are executed
|
|
502
|
+
* @returns Promise resolving to subscription ID for managing the subscription
|
|
503
|
+
* @throws Error if WebSocket not connected or subscription fails
|
|
504
|
+
*/
|
|
505
|
+
async subscribeTrades(symbol, callback) {
|
|
506
|
+
try {
|
|
507
|
+
if (!this.ws) {
|
|
508
|
+
throw new Error('WebSocket not initialized. Call connectWebSocket() first.');
|
|
509
|
+
}
|
|
510
|
+
return await this.ws.subscribeTrades(symbol, callback);
|
|
511
|
+
}
|
|
512
|
+
catch (error) {
|
|
513
|
+
this.handleError(error, 'subscribeTrades');
|
|
514
|
+
return '';
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Subscribe to real-time order updates (user data)
|
|
519
|
+
*
|
|
520
|
+
* @param callback - Function called when user's order status changes
|
|
521
|
+
* @returns Promise resolving to subscription ID for managing the subscription
|
|
522
|
+
* @throws Error if WebSocket not connected or subscription fails
|
|
523
|
+
*/
|
|
524
|
+
async subscribeOrders(callback) {
|
|
525
|
+
try {
|
|
526
|
+
if (!this.userStream) {
|
|
527
|
+
throw new Error('User Data Stream not initialized. Call connectUserDataStream() first.');
|
|
528
|
+
}
|
|
529
|
+
return await this.userStream.subscribeUserOrders(callback);
|
|
530
|
+
}
|
|
531
|
+
catch (error) {
|
|
532
|
+
this.handleError(error, 'subscribeOrders');
|
|
533
|
+
return '';
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Unsubscribe from a WebSocket subscription
|
|
538
|
+
*
|
|
539
|
+
* @param subscriptionId - The ID of the subscription to cancel
|
|
540
|
+
* @returns Promise that resolves when subscription is cancelled
|
|
541
|
+
* @throws Error if WebSocket not connected or unsubscribe fails
|
|
542
|
+
*/
|
|
543
|
+
async unsubscribe(subscriptionId) {
|
|
544
|
+
try {
|
|
545
|
+
if (!this.ws) {
|
|
546
|
+
throw new Error('WebSocket not initialized.');
|
|
547
|
+
}
|
|
548
|
+
await this.ws.unsubscribe(subscriptionId);
|
|
549
|
+
}
|
|
550
|
+
catch (error) {
|
|
551
|
+
this.handleError(error, 'unsubscribe');
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Check if WebSocket connection is active
|
|
556
|
+
*
|
|
557
|
+
* @returns Boolean indicating WebSocket connection status
|
|
558
|
+
*/
|
|
559
|
+
isWebSocketConnected() {
|
|
560
|
+
return this.ws ? this.ws.isConnected() : false;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Get current WebSocket connection status
|
|
564
|
+
*
|
|
565
|
+
* @returns Current WebSocket status ('connected', 'disconnected', etc.)
|
|
566
|
+
*/
|
|
567
|
+
getWebSocketStatus() {
|
|
568
|
+
return this.ws ? this.ws.getWebSocketStatus() : 'disconnected';
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* User Data Stream Methods Implementation
|
|
572
|
+
*/
|
|
573
|
+
/**
|
|
574
|
+
* Connect to user data stream for real-time account updates
|
|
575
|
+
*
|
|
576
|
+
* @returns Promise that resolves when user data stream is connected
|
|
577
|
+
* @throws Error if authentication fails or connection cannot be established
|
|
578
|
+
*/
|
|
579
|
+
async connectUserDataStream() {
|
|
580
|
+
try {
|
|
581
|
+
if (!this.auth) {
|
|
582
|
+
throw new Error('Authentication required. Call connect() first.');
|
|
583
|
+
}
|
|
584
|
+
if (!this.userStream) {
|
|
585
|
+
this.userStream = new bitget_user_stream_1.BitgetUserDataStream(this.auth);
|
|
586
|
+
}
|
|
587
|
+
await this.userStream.connectUserDataStream();
|
|
588
|
+
this.logger.info('Successfully connected to Bitget User Data Stream');
|
|
589
|
+
}
|
|
590
|
+
catch (error) {
|
|
591
|
+
this.handleError(error, 'connectUserDataStream');
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Disconnect from user data stream
|
|
596
|
+
*
|
|
597
|
+
* @returns Promise that resolves when user data stream is disconnected
|
|
598
|
+
*/
|
|
599
|
+
async disconnectUserDataStream() {
|
|
600
|
+
try {
|
|
601
|
+
if (this.userStream) {
|
|
602
|
+
await this.userStream.disconnectUserDataStream();
|
|
603
|
+
this.userStream = undefined;
|
|
604
|
+
this.logger.info('Successfully disconnected from Bitget User Data Stream');
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
catch (error) {
|
|
608
|
+
this.handleError(error, 'disconnectUserDataStream');
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Subscribe to real-time user order updates (limit/market orders)
|
|
613
|
+
*
|
|
614
|
+
* @param callback - Function called when user's orders change status
|
|
615
|
+
* @returns Promise resolving to subscription ID for managing the subscription
|
|
616
|
+
* @throws Error if user data stream not connected or subscription fails
|
|
617
|
+
*/
|
|
618
|
+
async subscribeUserOrders(callback) {
|
|
619
|
+
try {
|
|
620
|
+
if (!this.userStream) {
|
|
621
|
+
throw new Error('User Data Stream not initialized. Call connectUserDataStream() first.');
|
|
622
|
+
}
|
|
623
|
+
return await this.userStream.subscribeUserOrders(callback);
|
|
624
|
+
}
|
|
625
|
+
catch (error) {
|
|
626
|
+
this.handleError(error, 'subscribeUserOrders');
|
|
627
|
+
return '';
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Subscribe to real-time user trade executions
|
|
632
|
+
* Notifies when user's orders are filled/executed
|
|
633
|
+
*
|
|
634
|
+
* @param callback - Function called when user's trades are executed
|
|
635
|
+
* @returns Promise resolving to subscription ID for managing the subscription
|
|
636
|
+
* @throws Error if user data stream not connected or subscription fails
|
|
637
|
+
*/
|
|
638
|
+
async subscribeUserTrades(callback) {
|
|
639
|
+
try {
|
|
640
|
+
if (!this.userStream) {
|
|
641
|
+
throw new Error('User Data Stream not initialized. Call connectUserDataStream() first.');
|
|
642
|
+
}
|
|
643
|
+
return await this.userStream.subscribeUserTrades(callback);
|
|
644
|
+
}
|
|
645
|
+
catch (error) {
|
|
646
|
+
this.handleError(error, 'subscribeUserTrades');
|
|
647
|
+
return '';
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Subscribe to real-time account balance updates
|
|
652
|
+
*
|
|
653
|
+
* @param callback - Function called when account balance changes
|
|
654
|
+
* @returns Promise resolving to subscription ID for managing the subscription
|
|
655
|
+
* @throws Error if user data stream not connected or subscription fails
|
|
656
|
+
*/
|
|
657
|
+
async subscribeAccountUpdates(callback) {
|
|
658
|
+
try {
|
|
659
|
+
if (!this.userStream) {
|
|
660
|
+
throw new Error('User Data Stream not initialized. Call connectUserDataStream() first.');
|
|
661
|
+
}
|
|
662
|
+
return await this.userStream.subscribeAccountUpdates(callback);
|
|
663
|
+
}
|
|
664
|
+
catch (error) {
|
|
665
|
+
this.handleError(error, 'subscribeAccountUpdates');
|
|
666
|
+
return '';
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Check if user data stream is connected
|
|
671
|
+
*
|
|
672
|
+
* @returns Boolean indicating user data stream connection status
|
|
673
|
+
*/
|
|
674
|
+
isUserDataStreamConnected() {
|
|
675
|
+
return this.userStream ? this.userStream.isUserDataStreamConnected() : false;
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Make authenticated request to Bitget API
|
|
679
|
+
*
|
|
680
|
+
* @param endpoint - API endpoint path
|
|
681
|
+
* @param params - Query parameters for the request
|
|
682
|
+
* @param method - HTTP method ('GET', 'POST', 'PUT', 'DELETE')
|
|
683
|
+
* @param body - Request body data for POST/PUT requests
|
|
684
|
+
* @returns Promise resolving to API response data
|
|
685
|
+
* @throws Error if not authenticated or request fails
|
|
686
|
+
*/
|
|
687
|
+
async makeRequest(endpoint, params = {}, method = 'GET', body) {
|
|
688
|
+
if (!this.auth) {
|
|
689
|
+
throw new Error('Bitget connector not authenticated');
|
|
690
|
+
}
|
|
691
|
+
return this.auth.makeRequest(endpoint, params, method, body);
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Make public request to Bitget API (no authentication required)
|
|
695
|
+
*
|
|
696
|
+
* @param endpoint - API endpoint path
|
|
697
|
+
* @param params - Query parameters for the request
|
|
698
|
+
* @returns Promise resolving to API response data
|
|
699
|
+
* @throws Error if request fails
|
|
700
|
+
*/
|
|
701
|
+
async makePublicRequest(endpoint, params = {}) {
|
|
702
|
+
if (!this.auth) {
|
|
703
|
+
throw new Error('Bitget connector not authenticated');
|
|
704
|
+
}
|
|
705
|
+
return this.auth.makePublicRequest(endpoint, params);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
exports.BitgetConnector = BitgetConnector;
|
|
709
|
+
//# sourceMappingURL=bitget-connector.js.map
|