ATS
  • Overview
  • Getting Started
    • Quickstart
    • Sample Trading Configs
  • Basics
    • Definitions & Terminology
    • What is Market Making
    • Plots
    • Trading Report
    • Architecture
    • Exchange Configs
    • Strategy Configs
    • Canonical Namespaces
  • APIs
    • Create Trading Job
    • List Trading Jobs
    • Run Trading Job
    • Stop Trading Job
    • Get Plot Topic List
    • Plot Topics
    • Realtime Logs
  • Customizations
    • Adding a New Exchange
    • Adding a Strategy
    • Adding an Indicator
    • Custom Fee Structures
    • Adding a New Plot
Powered by GitBook
On this page
  • Trade Related
  • Parameters & Variables
  • Equations
  • Different Market Confitions and Behaviours
  1. Basics

Definitions & Terminology

The "Definitions & Terminology" section serves as a comprehensive guide to the key terms, concepts, and constructs used within our automated trading platform. It is designed to empower developers by p

Trade Related

  • Trade: A pair of buy and sell orders placed around a common reference price, positioned above and below it.

  • Fluctuating Component: A signal or indicator that aligns and moves in response to market trends and patterns.

  • Completion of an Order: The point at which an order is fully executed in the market.

  • Completion of a Trade: The successful execution of all orders associated with a specific trade.

  • Base Asset: The primary asset in a trading pair, such as BTC or ETH, representing the component being traded.

  • Quote Asset: The secondary asset in a trading pair that is used to express the value of the base asset, such as USDT or BUSD.

  • Open Trade: A trade that has only been partially completed, with at least one order executed.

  • Pending Trade: A trade in which none of the associated orders have been executed.

  • Pending Order: An order that has been placed but has not yet been executed.


Parameters & Variables

  • total_valueinit\text{total\_value}_{\text{init}}total_valueinit​ - Total initial asset value

  • base_amountinit\text{base\_amount}_{\text{init}}base_amountinit​ - Initial base asset amount

  • base_valueinit\text{base\_value}_{\text{init}}base_valueinit​ - Initial base asset value (in quote asset units)

  • pinitp_{\text{init}}pinit​ - Initial quote asset price

  • quote_valueinit\text{quote\_value}_{\text{init}}quote_valueinit​ - Initial quote asset value

  • total_valueclose\text{total\_value}_{\text{close}}total_valueclose​ - Total closing asset value

  • base_amountclose\text{base\_amount}_{\text{close}}base_amountclose​ - Closing base asset amount

  • base_valueclose\text{base\_value}_{\text{close}}base_valueclose​ - Closing base asset value (in quote asset units)

  • pclosep_{\text{close}}pclose​ - Closing quote asset price

  • quote_valueclose\text{quote\_value}_{\text{close}}quote_valueclose​ - Closing quote asset value

  • mm_gain\text{mm\_gain}mm_gain - Market-making gain (quote asset gain from completed trades → completed buy-sell pairs)

  • Δquote_value\Delta \text{quote\_value}Δquote_value - Quote asset difference

  • Δbase_amount\Delta \text{base\_amount}Δbase_amount - Base asset amount difference

  • Δbase_value\Delta \text{base\_value}Δbase_value - Base asset value difference (in quote asset units)

  • Δtotal_value\Delta \text{total\_value}Δtotal_value - Total asset value difference

  • Δp\Delta pΔp - Price difference (pclose−pinitp_{\text{close}} - p_{\text{init}}pclose​−pinit​)

  • half_buy_amountbase\text{half\_buy\_amount}_{\text{base}}half_buy_amountbase​ - Bought base asset amount of open trades (a trade with only the buy order has been executed)

  • half_buy_spentquote\text{half\_buy\_spent}_{\text{quote}}half_buy_spentquote​ - Spent quote asset value of open trades (a trade with only the buy order has been executed)

  • half_sell_amountbase\text{half\_sell\_amount}_{\text{base}}half_sell_amountbase​ - Sold base asset amount of open trades (a trade with only the sell order has been executed)

  • half_sell_earnedquote\text{half\_sell\_earned}_{\text{quote}}half_sell_earnedquote​ - Earned quote asset value of open trades (a trade with only the sell order has been executed)

  • Feemaker\text{Fee}_{\text{maker}}Feemaker​ - Maker fee

  • Feetaker\text{Fee}_{\text{taker}}Feetaker​ - Taker fee


Equations

Total initial and closing equity:

total_valueinit=base_valueinit+quote_valueinit(1)\text{total\_value}_{\text{init}} = \text{base\_value}_{\text{init}} + \text{quote\_value}_{\text{init}} \quad (1)total_valueinit​=base_valueinit​+quote_valueinit​(1)
total_valueclose=base_valueclose+quote_valueclose(2)\text{total\_value}_{\text{close}} = \text{base\_value}_{\text{close}} + \text{quote\_value}_{\text{close}} \quad (2)total_valueclose​=base_valueclose​+quote_valueclose​(2)

Initial base asset:

base_valueinit=base_amountinitpinit(3)\text{base\_value}_{\text{init}} = \text{base\_amount}_{\text{init}} p_{\text{init}} \quad (3)base_valueinit​=base_amountinit​pinit​(3)

Closing base asset:

base_valueclose=base_amountclosepclose(4)\text{base\_value}_{\text{close}} = \text{base\_amount}_{\text{close}} p_{\text{close}} \quad (4)base_valueclose​=base_amountclose​pclose​(4)

Since completed order pair will not add/remove a resultant base asset (buy_size = sell_size),

base_amountclose=base_amountinit+half_buy_amountbase−half_sell_amountbase(5)\text{base\_amount}_{\text{close}} = \text{base\_amount}_{\text{init}} + \text{half\_buy\_amount}_{\text{base}} - \text{half\_sell\_amount}_{\text{base}} \quad (5)base_amountclose​=base_amountinit​+half_buy_amountbase​−half_sell_amountbase​(5)
base_valueclose=(base_amountinit+half_buy_amountbase−half_sell_amountbase)pclose(6)\text{base\_value}_{\text{close}} = \left(\text{base\_amount}_{\text{init}} + \text{half\_buy\_amount}_{\text{base}} - \text{half\_sell\_amount}_{\text{base}}\right) p_{\text{close}} \quad (6)base_valueclose​=(base_amountinit​+half_buy_amountbase​−half_sell_amountbase​)pclose​(6)

Closing quote assets: Mm_gain is the profit by completing an order pair,

quote_valueclose=quote_valueinit−half_buy_spentquote+half_sell_earnedquote+mm_gain(7)\text{quote\_value}_{\text{close}} = \text{quote\_value}_{\text{init}} - \text{half\_buy\_spent}_{\text{quote}} + \text{half\_sell\_earned}_{\text{quote}} + \text{mm\_gain} \quad (7)quote_valueclose​=quote_valueinit​−half_buy_spentquote​+half_sell_earnedquote​+mm_gain(7)

Base Asset Gain:

gainbase=base_valueclose−base_valueinit(8)\text{gain}_{\text{base}} = \text{base\_value}_{\text{close}} - \text{base\_value}_{\text{init}} \quad (8)gainbase​=base_valueclose​−base_valueinit​(8)

From (8), (6), (3),

gainbase=(base_amountinit+half_buy_amountbase−half_sell_amountbase)pclose−base_amountinitpinit(9)\text{gain}_{\text{base}} = (\text{base\_amount}_{\text{init}} + \text{half\_buy\_amount}_{\text{base}} - \text{half\_sell\_amount}_{\text{base}}) p_{\text{close}} - \text{base\_amount}_{\text{init}} p_{\text{init}} \quad (9)gainbase​=(base_amountinit​+half_buy_amountbase​−half_sell_amountbase​)pclose​−base_amountinit​pinit​(9)
gainbase=base_amountinit(pclose−pinit)+(half_buy_amountbase−half_sell_amountbase)pclose(10)\text{gain}_{\text{base}} = \text{base\_amount}_{\text{init}} (p_{\text{close}} - p_{\text{init}}) + (\text{half\_buy\_amount}_{\text{base}} - \text{half\_sell\_amount}_{\text{base}}) p_{\text{close}} \quad (10)gainbase​=base_amountinit​(pclose​−pinit​)+(half_buy_amountbase​−half_sell_amountbase​)pclose​(10)

Quote Asset Gain:

gainquote=quote_valueclose−quote_valueinit(11)\text{gain}_{\text{quote}} = \text{quote\_value}_{\text{close}} - \text{quote\_value}_{\text{init}} \quad (11)gainquote​=quote_valueclose​−quote_valueinit​(11)

From (11), (7),

gainquote=(quote_valueinit−half_buy_spentquote+half_sell_earnedquote+mm_gain)−quote_valueinit(12)\text{gain}_{\text{quote}} = (\text{quote\_value}_{\text{init}} - \text{half\_buy\_spent}_{\text{quote}} + \text{half\_sell\_earned}_{\text{quote}} + \text{mm\_gain}) - \text{quote\_value}_{\text{init}} \quad (12)gainquote​=(quote_valueinit​−half_buy_spentquote​+half_sell_earnedquote​+mm_gain)−quote_valueinit​(12)
gainquote=mm_gain+half_sell_earnedquote−half_buy_spentquote(13)\text{gain}_{\text{quote}} = \text{mm\_gain} + \text{half\_sell\_earned}_{\text{quote}} - \text{half\_buy\_spent}_{\text{quote}} \quad (13)gainquote​=mm_gain+half_sell_earnedquote​−half_buy_spentquote​(13)

Equity Gain:

gaintotal=gainbase+gainquote(14)\text{gain}_{\text{total}} = \text{gain}_{\text{base}} + \text{gain}_{\text{quote}} \quad (14)gaintotal​=gainbase​+gainquote​(14)

From (10), (13),

gaintotal=base_amountinit(pclose−pinit)+(half_buy_amountbase−half_sell_amountbase)pclose+(half_sell_earnedquote−half_buy_spentquote)+mm_gain(15)\text{gain}_{\text{total}} = \text{base\_amount}_{\text{init}} (p_{\text{close}} - p_{\text{init}}) + (\text{half\_buy\_amount}_{\text{base}} - \text{half\_sell\_amount}_{\text{base}}) p_{\text{close}} + (\text{half\_sell\_earned}_{\text{quote}} - \text{half\_buy\_spent}_{\text{quote}}) + \text{mm\_gain} \quad (15)gaintotal​=base_amountinit​(pclose​−pinit​)+(half_buy_amountbase​−half_sell_amountbase​)pclose​+(half_sell_earnedquote​−half_buy_spentquote​)+mm_gain(15)
  • gain1=base_amountinit(pclose−pinit)\text{gain1} = \text{base\_amount}_{\text{init}} (p_{\text{close}} - p_{\text{init}})gain1=base_amountinit​(pclose​−pinit​) - gain/loss due to the holding of the base asset

  • gain2=(half_buy_amountbase−half_sell_amountbase)pclose\text{gain2} = (\text{half\_buy\_amount}_{\text{base}} - \text{half\_sell\_amount}_{\text{base}}) p_{\text{close}}gain2=(half_buy_amountbase​−half_sell_amountbase​)pclose​ - base asset mismatch due to open trades/pending orders

  • gain3=(half_sell_earnedquote−half_buy_spentquote)\text{gain3} = (\text{half\_sell\_earned}_{\text{quote}} - \text{half\_buy\_spent}_{\text{quote}})gain3=(half_sell_earnedquote​−half_buy_spentquote​) - quote asset mismatch due to open trades/pending orders

  • gain4=mm_gain\text{gain4} = \text{mm\_gain}gain4=mm_gain - market-making gain from completed trades

gaintotal=holding_cost+pending_component+mm_gain(16)\text{gain}_{\text{total}} = \text{holding\_cost} + \text{pending\_component} + \text{mm\_gain} \quad (16)gaintotal​=holding_cost+pending_component+mm_gain(16)

Gain1 - Holding Cost

  • Definition: Represents gains or losses resulting from holding the base asset.

  • Market Impact:

    • Bullish Conditions: Gains are realized when the value of the base asset increases.

    • Bearish Conditions: Losses occur when the value of the base asset decreases.

  • Significance: This is the first component contributing to inventory risk, as fluctuations in the base asset's value directly affect overall asset performance.

Gain2 and Gain3 - Pending Component

  • Definition: Refers to the impact of pending orders or open trades on asset valuation.

  • Resultant Effect: Often leads to a loss due to unresolved trades.

  • Inventory Risk: This is the second major component contributing to inventory risk.

Gain2 - Base Asset Mismatch Due to Open Trades

  • Description: Represents changes caused by open trades involving the base asset.

    • Buy Order Execution: If only the buy order is executed, this term increases as more base assets are acquired.

    • Sell Order Execution: If only the sell order is executed, this term decreases as base assets are sold off.

  • Significance: This component contributes to the pending component by highlighting the imbalance in base asset positions during open trades.

Gain3 - Quote Asset Mismatch Due to Open Trades

  • Description: Reflects changes related to open trades involving the quote asset.

    • Buy Order Execution: If only the buy order is executed, this term decreases since quote assets are spent.

    • Sell Order Execution: If only the sell order is executed, this term increases as quote assets are received.

  • Significance: Like Gain2, this component contributes to the pending component by capturing the mismatch in quote asset holdings during open trades.

pending_component=(half_buy_amountbase−half_sell_amountbase)pclose+(half_sell_earnedquote−half_buy_spentquote)(17)\text{pending\_component} = (\text{half\_buy\_amount}_{\text{base}} - \text{half\_sell\_amount}_{\text{base}}) p_{\text{close}} + (\text{half\_sell\_earned}_{\text{quote}} - \text{half\_buy\_spent}_{\text{quote}}) \quad (17)pending_component=(half_buy_amountbase​−half_sell_amountbase​)pclose​+(half_sell_earnedquote​−half_buy_spentquote​)(17)

Rearranging (17),

pending_component=(half_buy_amountbasepclose−half_buy_spentquote)+(half_sell_earnedquote−half_sell_amountbasepclose)(18)\text{pending\_component} = (\text{half\_buy\_amount}_{\text{base}} p_{\text{close}} - \text{half\_buy\_spent}_{\text{quote}}) + (\text{half\_sell\_earned}_{\text{quote}} - \text{half\_sell\_amount}_{\text{base}} p_{\text{close}}) \quad (18)pending_component=(half_buy_amountbase​pclose​−half_buy_spentquote​)+(half_sell_earnedquote​−half_sell_amountbase​pclose​)(18)

If pending buy orders get accumulated (only the sell part of trades gets executed more often),

Gain4 - Market-Making Gain (mm_gain)

  • Definition: Represents gains earned through market-making activities from completed trades.

  • Mechanism: Involves placing a buy-sell order pair of the same size, with the buy price set lower than the sell price. This approach ensures a profit is generated through the difference (spread) between the buy and sell prices when both orders are successfully executed.

  • Significance: This gain highlights the profitability of market-making strategies and reflects the effectiveness of capturing spreads between orders as a key component of trading performance.

Rearranged Aggregated Gain Components: Here, we have rearranged some of the aforementioned components for the sake of representation and ease.

half_buy_component=(half_buy_amountbasepclose−half_buy_spentquote)(19)\text{half\_buy\_component} = (\text{half\_buy\_amount}_{\text{base}} p_{\text{close}} - \text{half\_buy\_spent}_{\text{quote}}) \quad (19)half_buy_component=(half_buy_amountbase​pclose​−half_buy_spentquote​)(19)
half_sell_component=(half_sell_earnedquote−half_sell_amountbasepclose)(20)\text{half\_sell\_component} = (\text{half\_sell\_earned}_{\text{quote}} - \text{half\_sell\_amount}_{\text{base}} p_{\text{close}}) \quad (20)half_sell_component=(half_sell_earnedquote​−half_sell_amountbase​pclose​)(20)
pending_component=half_buy_component+half_sell_component(21)\text{pending\_component} = \text{half\_buy\_component} + \text{half\_sell\_component} \quad (21)pending_component=half_buy_component+half_sell_component(21)
net_mm_gain=pending_component+mm_gain(22)\text{net\_mm\_gain} = \text{pending\_component} + \text{mm\_gain} \quad (22)net_mm_gain=pending_component+mm_gain(22)
resultant_gain=holding_component+net_mm_gain(23)\text{resultant\_gain} = \text{holding\_component} + \text{net\_mm\_gain} \quad (23)resultant_gain=holding_component+net_mm_gain(23)
big_bulls_mm_gain=half_sell_component+mm_gain(24)\text{big\_bulls\_mm\_gain} = \text{half\_sell\_component} + \text{mm\_gain} \quad (24)big_bulls_mm_gain=half_sell_component+mm_gain(24)

Note: \text{big_bulls_mm_gain} is a measure favoring long-term bullish behavior in the market. Therefore, we ignore the \text{half_buy_component} from the \text{net_mm_gain} equation since having extra base asset (BTC) in hand will benefit in long-term bullish conditions.


Different Market Confitions and Behaviours

Factors Reducing Total Equity Value:

  • Pending Component: When the majority of pending orders or open trades are positioned against the direction of market profit.

    • Bearish Market Impact: The value of the base asset declines, resulting in reduced equity value.

Bear Markets:

  • Objective: Aim to accumulate more quote assets.

  • Impact on Holding Cost:

    • The decline in base asset prices turns the holding cost into a loss.

  • Trade Behavior:

    • More sell orders remain pending while buy orders get executed frequently, leading to an accumulation of base assets and a reduction in quote assets.

    • Result: Loss

  • Market-Making Impact:

    • Expected gains from market-making activities are reduced due to pending orders, leading to a loss.

Bull Markets:

  • Objective: Aim to accumulate more base assets.

  • Impact on Holding Cost:

    • The increase in base asset prices turns the holding cost into a gain.

  • Trade Behavior:

    • More buy orders remain pending while sell orders get executed frequently, resulting in the accumulation of quote assets and a reduction in base assets.

    • Result: Loss

  • Market-Making Impact:

    • Expected gains from market-making activities are reduced due to pending orders, leading to a loss.

Ranging Markets:

  • Holding Cost:

    • This component does not dominate the overall behavior, resulting in a neutral effect.

  • Pending Orders:

    • Minimal pending orders, with trades getting completed more frequently, leading to a neutral effect.

  • Market-Making Gains:

    • Maximized gains from market-making activities.

PreviousSample Trading ConfigsNextWhat is Market Making

Last updated 7 months ago