testsuite

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunAdapterComplianceTests

func RunAdapterComplianceTests(t *testing.T, adp exchanges.Exchange, symbol string)

RunAdapterComplianceTests runs a standard set of compliance tests against any exchanges.

func RunLifecycleSuite

func RunLifecycleSuite(t *testing.T, adp exchanges.Exchange, cfg LifecycleConfig)

RunLifecycleSuite executes a comprehensive trading lifecycle test:

  1. Subscribe — WatchOrders, collect all order state transitions
  2. Open — Place a market buy and wait for FILLED
  3. Verify — Check position (perp) or balance change (spot)
  4. Close — Reverse the position while monitoring state transitions
  5. Verify — Assert position/balance is restored
  6. Disconnect — StopWatchOrders, Close

This test is intentionally a single sequential flow to validate that all pieces work together end-to-end.

func RunOrderSuite

func RunOrderSuite(t *testing.T, adp exchanges.Exchange, cfg OrderSuiteConfig)

RunOrderSuite runs a complete order placement test suite against any Exchange.

func SetupOrderWatch

func SetupOrderWatch(t *testing.T, adp exchanges.Exchange) <-chan *exchanges.Order

SetupOrderWatch subscribes to order updates via WatchOrders (Streamable) and returns a channel that receives all order updates.

func SmartLimitPrice

func SmartLimitPrice(t *testing.T, adp exchanges.Exchange, symbol string, side exchanges.OrderSide) decimal.Decimal

SmartLimitPrice calculates a passive limit price that won't fill immediately.

func SmartQuantity

func SmartQuantity(t *testing.T, adp exchanges.Exchange, symbol string) (qty, price decimal.Decimal)

SmartQuantity calculates a reasonable order quantity for testing.

func TestFetchAccount

func TestFetchAccount(t *testing.T, adp exchanges.Exchange)

TestFetchAccount verifies the FetchAccount implementation

func TestFetchFeeRate

func TestFetchFeeRate(t *testing.T, adp exchanges.Exchange, symbol string)

TestFetchFeeRate verifies the FetchFeeRate implementation

func TestFetchOrderBook

func TestFetchOrderBook(t *testing.T, adp exchanges.Exchange, symbol string)

TestFetchOrderBook verifies the FetchOrderBook implementation

func TestFetchSymbolDetails

func TestFetchSymbolDetails(t *testing.T, adp exchanges.Exchange, symbol string)

TestFetchSymbolDetails verifies the FetchSymbolDetails implementation

func TestFetchTicker

func TestFetchTicker(t *testing.T, adp exchanges.Exchange, symbol string)

TestFetchTicker verifies the FetchTicker implementation

func TestWatchOrderBook

func TestWatchOrderBook(t *testing.T, adp exchanges.Exchange, symbol string)

TestWatchOrderBook verifies the WebSocket OrderBook subscription and local syncing

func WaitOrderStatus

func WaitOrderStatus(
	t *testing.T,
	ch <-chan *exchanges.Order,
	orderID, clientID string,
	target exchanges.OrderStatus,
	timeout time.Duration,
) *exchanges.Order

WaitOrderStatus blocks until an order with matching orderID or clientID reaches the target status, or times out.

Types

type LifecycleConfig

type LifecycleConfig struct {
	Symbol string // Required: e.g. "DOGE"
}

LifecycleConfig configures the full lifecycle integration test.

type OrderSuiteConfig

type OrderSuiteConfig struct {
	Symbol       string          // Required: symbol to test on, e.g. "DOGE" or "ETH"
	Slippage     decimal.Decimal // Slippage for slippage test (default 0.05)
	SkipMarket   bool            // Skip market order test
	SkipSlippage bool            // Skip slippage order test
	SkipLimit    bool            // Skip limit order test
}

OrderSuiteConfig configures the order test suite.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL