testsuite

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 RunLocalStateSuite added in v0.2.0

func RunLocalStateSuite(t *testing.T, adp exchanges.Exchange, cfg LocalStateConfig)

RunLocalStateSuite tests the unified LocalState against a live exchange adapter.

It validates:

  1. Start — REST snapshot + WS subscriptions
  2. State Queries — GetBalance, GetAllPositions, GetAllOpenOrders
  3. Order Subscription — SubscribeOrders fan-out
  4. PlaceOrder + WaitTerminal — market buy with order tracking
  5. Position Tracking — position update via subscription
  6. Limit Order + Cancel — PlaceOrder limit, then cancel, verify CANCELLED event
  7. Close Position — reverse market order, verify position closed
  8. Cleanup — Close LocalState

func RunOrderQuerySemanticsSuite added in v0.2.0

func RunOrderQuerySemanticsSuite(t *testing.T, adp exchanges.Exchange, cfg OrderQueryConfig)

RunOrderQuerySemanticsSuite verifies the semantic split between: - FetchOrderByID: single-order lookup - FetchOrders: all visible orders for a symbol - FetchOpenOrders: open orders only

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 LocalStateConfig added in v0.2.0

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

LocalStateConfig configures the LocalState integration test.

type OrderQueryConfig added in v0.2.0

type OrderQueryConfig struct {
	Symbol                 string
	SupportsOpenOrders     bool
	SupportsTerminalLookup bool
	SupportsOrderHistory   bool
}

OrderQueryConfig configures the shared order-query semantics suite.

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