{"modulePath":"github.com/QuantProcessing/exchanges","version":"v1.0.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package examples\n\n## Functions\n\n```go\nfunc FetchBTCUSDTFromBinanceSpot(ctx context.Context) (model.Ticker, error)\n```\nFetchBTCUSDTFromBinanceSpot is the same workflow using the concrete Binance spot adapter. It calls Binance public endpoints, so tests compile this helper but do not execute it by default.\n\n```go\nfunc FetchTickerWithDataClient(ctx context.Context, client venue.DataClient, instrumentID model.InstrumentID) (model.Ticker, error)\n```\nFetchTickerWithDataClient shows the smallest normalized market-data path: connect a venue.DataClient, request one ticker, and disconnect it.\n\n## Types\n\n```go\ntype BacktestStrategyResult struct {\n\tEventsProcessed int\n\tOrder           model.OrderStatusReport\n\tPosition        model.PositionStatusReport\n\tFills           []model.FillReport\n\tExposureUSDT    decimal.Decimal\n}\n```\n\n```go\nfunc RunThresholdStrategyBacktest(ctx context.Context) (BacktestStrategyResult, error)\n```\nRunThresholdStrategyBacktest replays two order-book events through the same strategy.Runtime surface used by live nodes. The strategy subscribes in OnStart, reacts in OnOrderBook, submits through OrderFactory, and reads final state from cache and portfolio.\n\n```go\ntype BracketBacktestResult struct {\n\tEntry      model.OrderStatusReport\n\tStopLoss   model.OrderStatusReport\n\tTakeProfit model.OrderStatusReport\n\tFills      []model.FillReport\n}\n```\n\n```go\nfunc RunBracketOrderBacktest(ctx context.Context) (BracketBacktestResult, error)\n```\nRunBracketOrderBacktest shows the advanced order-list path: one parent entry order releases two reduce-only children, and the take-profit fill cancels the stop-loss sibling.\n\n```go\ntype FundingArbitrageConfig struct {\n\tSymbol             string\n\tQuantity           decimal.Decimal\n\tMinFundingSpread   decimal.Decimal\n\tMinNetEdge         decimal.Decimal\n\tSlippageBufferRate decimal.Decimal\n\tMaxOrderNotional   decimal.Decimal\n}\n```\n\n```go\ntype FundingArbitrageDecision struct {\n\tShouldTrade       bool\n\tReason            string\n\tLong              FundingVenueSnapshot\n\tShort             FundingVenueSnapshot\n\tFundingSpread     decimal.Decimal\n\tEstimatedCostRate decimal.Decimal\n\tExpectedNetRate   decimal.Decimal\n\tExpectedNetUSDT   decimal.Decimal\n\tOrders            []model.SubmitOrder\n\tReports           []model.OrderStatusReport\n}\n```\n\n```go\nfunc RunFundingRateArbitrageMonitor(ctx context.Context) (FundingArbitrageDecision, error)\n```\nRunFundingRateArbitrageMonitor shows a production-shaped funding-rate arbitrage flow without depending on any live credentials:\n\n 1. collect funding snapshots from multiple venues;\n 2. find the venue paying the most to shorts and the venue charging longs the least;\n 3. estimate taker-fee plus slippage cost;\n 4. create a delta-neutral long/short order pair with OrderFactory;\n 5. run risk checks before routing orders to execution clients by AccountID.\n\n```go\ntype FundingArbitrageMonitor struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewFundingArbitrageMonitor(cfg FundingArbitrageConfig, sources []FundingRateSource, riskEngine *risk.Engine, executor *fundingExecutionRouter) *FundingArbitrageMonitor\n```\n\n```go\nfunc (m *FundingArbitrageMonitor) EvaluateOnce(ctx context.Context) (FundingArbitrageDecision, error)\n```\n\n```go\ntype FundingRateSource interface {\n\tName() string\n\tSnapshots(context.Context) ([]FundingVenueSnapshot, error)\n}\n```\n\n```go\ntype FundingVenueSnapshot struct {\n\tVenue        model.Venue\n\tAccountID    model.AccountID\n\tRawSymbol    string\n\tBase         model.Currency\n\tQuote        model.Currency\n\tFunding      model.FundingRate\n\tTakerFeeRate decimal.Decimal\n}\n```\n\n```go\ntype LiveNodeResult struct {\n\tSubmittedOrder model.OrderStatusReport\n\tFills          []model.FillReport\n\tPosition       model.PositionStatusReport\n\tExposureUSDT   decimal.Decimal\n\tEventLog       []string\n}\n```\n\n```go\nfunc RunLiveNodeWithInMemoryVenue(ctx context.Context) (LiveNodeResult, error)\n```\nRunLiveNodeWithInMemoryVenue is a full local live-node assembly. It is useful for paper trading, integration tests, and adapter development because the strategy, risk, execution, cache, portfolio, and callbacks are real; only the venue network edge is replaced by in-memory clients.\n\n```go\ntype OrderFactoryWalkthrough struct {\n\tMarket       model.SubmitOrder\n\tPostOnly     model.SubmitOrder\n\tStopMarket   model.SubmitOrder\n\tTrailingStop model.SubmitOrder\n\tBracket      model.OrderList\n}\n```\n\n```go\nfunc BuildOrdersWithOrderFactory() OrderFactoryWalkthrough\n```\nBuildOrdersWithOrderFactory shows how strategy code should create commands: use OrderFactory for account identity, client order IDs, list IDs, and shared command metadata instead of assembling those fields by hand.\n\n```go\ntype RiskValidationResult struct {\n\tAccepted  model.SubmitOrder\n\tRejected  model.SubmitOrder\n\tRejectErr error\n}\n```\n\n```go\nfunc ValidateRiskBeforeExecution() (RiskValidationResult, error)\n```\nValidateRiskBeforeExecution demonstrates the normal execution boundary: put instrument metadata in cache, configure limits, then call risk.Check before an order is allowed to reach a venue execution client.\n\n","path":"github.com/QuantProcessing/exchanges/examples","name":"examples","synopsis":"","isRedistributable":true}
