A crypto arbitrage trading bot coordinates separate actions that are intended to offset one another. The phrase two-leg trade can make the pair sound like one indivisible event, but the execution system may process each leg independently. One can fill before the other, one can complete only partly and one can become uncertain after a connection failure. A useful design makes those outcomes visible in a ledger.

This guide compares execution sequences through a fictional example. Every price, fee and quantity is hypothetical. The exercise is designed to show how account records change, not to forecast returns. The main question is whether the bot can explain the inventory it actually owns after each event, especially when the intended pair does not complete cleanly.

Crypto Arbitrage Trading Bot Execution Sequence Is a Risk Choice

A concurrent sequence sends both legs without waiting for the first fill. It can reduce the interval between submissions, but it does not force the results to match. A buy-first sequence waits for acquisition evidence before selling a corresponding quantity. A sell-first sequence does the reverse. Each arrangement changes which residual exposure is possible during the interval between results.

The choice should reflect the available inventory, execution constraints and tolerated mismatch. It should not be based solely on which sequence produces the shortest demonstration. A strategy with prepositioned base inventory can attempt a sale before a new purchase completes, while another account may lack that capacity. An execution sequence is therefore inseparable from the funding model that supports it.

The older arbitrage leg-risk guide provides a general framework for following each action independently. The specific asset mechanics differ, but the same discipline applies: link the legs by strategy intent while preserving separate external outcomes. The ledger should never infer completion merely because both requests were sent close together.

Establish the Starting Ledger

Assume Account A begins with 2,000 quote units and no base units. Account B begins with 100 base units and 200 quote units. The proposed pair buys 80 base units in A at a limit of 10 and sells 80 in B at a limit of 10.15. The starting combined inventory is therefore 100 base units and 2,200 quote units.

For this exercise, assume each fill incurs a fee equal to 0.1 percent of quote notional, charged in the quote asset. Ignore other expenses initially so the trade arithmetic remains visible; later sections add a separate operating expense. Actual fee structures and transaction requirements must be checked for the chosen market. These assumptions are part of the scenario, not general claims about trading venues.

Before submission, the bot reserves 800.80 quote units in A and 80 base units in B. If the sale fee is deducted from its quote proceeds under the fictional rules, no additional quote funding is required for that particular charge. A different fee mechanism would require a different reservation. This demonstrates why the funding model must reflect the actual denomination and timing of each expense.

Record the First Partial Purchase

Suppose the buy fills 50 units at 9.98. Purchase notional is 499, and the assumed fee is 0.499. Account A now holds 50 base units and 1,500.501 quote units before considering the still-active remainder. The remaining 30 units can still cost up to 300 plus a 0.30 fee at the stated limit, so that obligation needs continued reservation.

The fill record should preserve the 50-unit quantity, the 9.98 price, the 499 notional and the 0.499 fee as distinct fields. A cost-inclusive average for the acquired units is 9.98998. That is a different measure from the execution price of 9.98. Keeping both definitions clear helps a reviewer avoid comparing a gross sale price with a fee-inclusive purchase price without realizing it.

The older trade journal guide explains why intent, attempt and result need separate records. Apply that distinction here. The original intent remains an 80-unit pair, but the observed purchase is only 50 units. The bot must manage the actual result rather than substitute the requested quantity for the owned quantity.

Record an Unequal Sale

Now suppose the sale fills 35 units at 10.16. Gross proceeds are 355.60, and the assumed fee is 0.3556. Net quote received is 355.2444. Account B now holds 65 base units and 555.2444 quote units, while the unfilled 45-unit sale remainder may still be active under the selected order rules.

At this point, the combined accounts hold 115 base units: 50 in A and 65 in B. They hold 2,055.7454 quote units. Relative to the start, quote holdings have decreased by 144.2546 while base holdings have increased by 15. This is not a fully matched arbitrage outcome. The ledger shows an additional 15-unit exposure before any subsequent fills or cancellations.

The partial-fill arbitrage ledger should present that mismatch directly. A headline realized gain on the 35 matched units can be informative, but it does not describe the whole account change. The additional purchased units remain economically relevant. Their current value and any later disposal costs must be considered before assessing the result of the entire attempted pair.

Cancel Remainders Without Rewriting Earlier Fills

Suppose both remaining orders are canceled and the execution systems confirm that no additional fills occurred. The bot can release the 30-unit purchase reservation and the 45-unit sale reservation. It still owns the 50 units bought in A and has sold 35 units from B. Cancellation ends the remaining obligations; it does not undo the completed asset movements.

The distinction matters because an interface may offer a single cancel-pair control. That control should produce two cancellation requests and preserve their separate outcomes. If only one cancellation is confirmed, the other remainder may still be active. The pair should remain unresolved to the extent that an additional fill is possible. A convenient combined button must not erase the independence of the underlying accounts.

The guide to crypto portfolio automation is relevant when the residual position shares capital with other strategies. The portfolio layer needs the actual 15-unit net increase and any still-reserved resources. It should not assume the arbitrage module returned to its starting exposure merely because the original pair is no longer being actively submitted.

Value the Residual Separately From Matched Economics

Under the fictional fills, 35 units are matched economically between the purchase and sale. Allocating the purchase fee proportionally, those 35 units cost 349.30 plus 0.3493, or 349.6493. Their sale produced 355.2444 net, leaving 5.5951 before other expenses. The remaining 15 purchased units cost 149.70 plus 0.1497, or 149.8497.

That decomposition agrees with the overall quote change. The matched portion adds 5.5951, while acquiring the extra 15 units consumes 149.8497, producing a net quote decrease of 144.2546. The arithmetic is useful because it proves the summary and account ledger are describing the same events. If they disagree, the discrepancy should be investigated before reporting a result.

A market mark can estimate the residual's current worth, but it should not be presented as realized proceeds. If the 15 units are marked at 10, their marked value is 150. An actual exit could return a different amount after depth and costs. Preserve both the acquisition basis and the valuation method so the reader can see which part of the reported result remains exposed.

Crypto Arbitrage Trading Bot Recovery Must Preserve Unknown Legs

Now change the scenario. Instead of receiving the sale fill response, the bot loses communication after submitting the sale. The purchase evidence remains known, but the sale may have filled, remained open or been rejected. The correct state is uncertainty about the sale, not a zero fill. The bot should preserve the corresponding inventory reservation while it searches for the existing outcome.

A fresh sale attempt could produce an excessive reduction if the first sale already completed. A fresh purchase could worsen a residual in the opposite direction. Recovery should therefore begin with identifiers and account evidence. The bot needs a durable relationship between its intent, the external request and any later fills discovered during reconciliation.

The older automated wallet event guide offers a useful perspective on delayed observations. Events can arrive after the application has moved into recovery. The ledger must accept that evidence without treating it as a new independent decision. An old fill discovered late is still part of the original attempt and must retain its original economic time and ownership.

Compare the Concurrent Sequence Against the Same Scenario

In a concurrent design, both 80-unit orders can be active before either result is known. The earlier 50-unit purchase and 35-unit sale are plausible unequal outcomes. The advantage is reduced submission delay between legs. The cost is that the bot must be prepared for mismatches in either direction and cannot use the first actual fill quantity to size the second initial request.

A meaningful test holds the fictional market and account assumptions constant while varying only the sequence. Record the maximum unmatched quantity that occurs and how long it remains. Do not compare a perfect concurrent case with a deliberately difficult sequential case. The purpose is to understand structural tradeoffs, so each design should face comparable delayed, partial and unknown outcomes.

The concurrent design also needs a rule for intervening after an early fill. It may request cancellation of an oversized remainder or allow the original plan to continue within a limit. Either policy should be predeclared. Otherwise, the bot's behavior can drift between examples, making the apparent performance depend on hindsight rather than on an implementable decision rule.

Compare a Buy-First Sequence

In a buy-first variant, the bot waits for the 50-unit purchase result before submitting a sale for up to 50 units. This avoids initially requesting an 80-unit sale against a smaller observed acquisition, although preexisting inventory may still fund it. The design creates a period in which the account has additional base exposure while the sale is being prepared and attempted.

If the sale then fills only 35, the final residual is again 15 units. The sequence has not eliminated partial-fill risk. It has changed the information available when the sale is sized and the timing of exposure. The ledger should measure those differences directly rather than assume that waiting for the first fill makes the pair safe.

For a market in which quotes change rapidly, the later sale may have worse economics than the original candidate. The bot should re-evaluate its permitted price and residual policy rather than force completion at any cost. A pair that no longer meets the original spread condition can still require exposure management, but that management is a separate decision with its own budget and reason.

Compare a Sell-First Sequence

A sell-first design uses prepositioned base inventory to execute the sale before purchasing replacement units. If 35 units sell, the bot can consider buying a corresponding amount afterward. The temporary exposure is a reduction in base holdings relative to the starting portfolio. That may be acceptable within the chosen policy, but it is still an economic position whose value can change.

The account must have actual available units to sell. An anticipated future purchase cannot fund a sale that requires settled inventory. This is particularly important when the platform displays a combined strategy plan that visually nets the legs. The external account may evaluate each action independently and reject a leg whose required resource does not yet exist in that account.

The crypto market making guide offers a related inventory perspective. A quoting strategy also changes inventory through asymmetric fills. Arbitrage and market making have different objectives, but both need a clear account of the exposure left by actual executions. The shared accounting discipline should not be confused with a guarantee that either activity earns a spread after all costs.

Compare a Sell-First SequenceConcurrentBuy FirstSell FirstTRADING FIELD NOTESEDUCATIONAL RESOURCE
Execution sequences place uncertainty at different points and require distinct recovery rules.

Add Operating Expenses Without Hiding Their Allocation

Return to the original partial-fill scenario and assume an additional 2.50 quote units of combined execution expense. If charged to Account A, its quote balance falls from 1,500.501 to 1,498.001. Combined quote holdings become 2,053.2454. The 115 base units remain unchanged under this fictional expense model because the charge is paid in quote units.

How the expense is allocated between the matched and residual portions is an accounting choice that should be disclosed. Assigning all of it to the matched portion lowers its reported remainder from 5.5951 to 3.0951. Allocating proportionally produces different intermediate figures while leaving the combined account result unchanged. A consistent method matters more than selecting the most flattering subtotal.

The automated market maker bot guide examines another setting where fees and inventory value interact. The useful connection is methodological: separate asset quantities, cash flows and valuation assumptions before calculating a combined result. This prevents a fee receipt or a positive subtotal from being mistaken for a complete assessment of economic performance.

Reconcile the Two Accounts Independently

Two-account arbitrage reconciliation should first explain each account on its own. Account A's change comes from the purchase, purchase fee and any assigned operating expense. Account B's change comes from the sale and sale fee. Only after those records agree with observed balances should the strategy combine them into a portfolio view.

This order helps identify discrepancies. If Account A differs from the expected balance, the issue may be an extra transaction cost, an unobserved transfer or a missing fill. Netting immediately against Account B can hide the error if another discrepancy happens to offset it. A matching combined total is not proof that both account histories are correct.

Also preserve fee currencies and decimal precision. Rounding each event too early can accumulate a difference across many fills. Store the quantities in the appropriate exact units and apply display rounding at the presentation layer. The reader does not need to see every internal digit at all times, but the exported record should support the displayed totals and explain any deliberate rounding convention.

Use the Ledger to Define Stop Conditions

The ledger can drive concrete stop conditions. A maximum unmatched quantity, unresolved leg duration or unexplained balance difference can block new pairs. These conditions are more interpretable than a broad warning that market risk is high. They identify a specific account fact and the evidence required before the strategy may continue.

For the fictional 15-unit residual, a policy with a 10-unit limit would stop new pairs immediately after the mismatch is established. The bot may still be permitted to execute a bounded residual-management action. The interface should distinguish that permission from ordinary entry authority. Stopping the strategy does not necessarily mean abandoning the records or preventing every action that could reduce an existing obligation.

Review the stop conditions with the same rigor as entry rules. A threshold that can be crossed without a visible explanation is hard to operate. A threshold that resets automatically while an unknown leg remains unresolved may be unsafe. The ledger provides the factual basis for these decisions, while the policy determines what the bot is authorized to do about them.

Keep the Comparison About Consequences

No execution sequence should be declared best based on one invented example. The worked ledger shows the questions a comparison must answer: what can fill independently, which resources are needed at each moment and what exposure remains when the legs differ. Real evaluation needs representative conditions and current knowledge of the chosen venue's mechanics.

A useful design record preserves the selected sequence, its assumptions and its recovery policy. It also records alternatives and the specific tradeoffs that mattered, such as temporary inventory exposure or the ability to resize the second leg. That record helps future reviewers understand whether a market or platform change invalidates the original choice.

The final standard is reconstructability. Another reader should be able to start with the opening balances, apply each confirmed event and arrive at the ending quantities and cash. If that is possible, the bot has made its economic consequences visible. If the explanation depends on treating requested quantities as fills or ignoring a residual, the pair is not yet adequately understood.

Continue Learning

Explore All Resources