Allan Trapp
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Updated derivations of NFT price ranges using new energy function ## Definitions There exists set $\mathcal{S}$ representing the universe of items. For each item $i\in \mathcal{S}$, there is a vector $x\in \mathbb{R}^n$ such that $x= M(i)$ where $M$ is an attribute map. Given a set of $m$ items from $\mathcal{S}$ it is possible to apply a clustering method $C:\mathcal{S}^m\rightarrow\mathcal{C}$, (such as Gaussian Mixture) to assign each item $i\in \mathcal{S}^m$ to exactly one cluster $j\in\mathcal{C}$ with a centroid $\bar x_j\in \mathbb{R}^n$; futher more let's set $|\mathcal{C}|=k$ to be the number of clusters. The items in cluster $j$ are denoted $\mathcal{C}_j \subset \mathcal{S}$, satisfying $\mathcal{S}^m = \displaystyle{\bigsqcup_{j \in \mathcal{C}} C_j}$. Now let's suppose we possess such a collection of $m$ items, sorted into into our $k$ clusters. Denote the quantity of items in cluster $j$ to be $q_j =\sum_{i =1}^m \mathbb{1}[i\in C_j]$, satisfying $\sum_{j=1}^k q_j=m$. Imposing a requirement on the method clustering method $C$, we will assume $q_j\ge 1 \forall j$. Define the positive definite matrix $Q=Diag(q) \in \mathbb{S}_{++}^k \subset \mathbb{R}^{k \times k}$, which is the diagonal of the quantities of items each of the clusers: $Q_{jj}=q_j$ and $Q_{ij}=0$ for all $i\neq j$. Construct the attribute matrix $X \in \mathbb{R}^{n \times k}$ by collecting the $n$-dimensional column vectors of cluster centroids $X=\left[\begin{array}{c} \cdots|&\bar x_j&|\cdots \end{array}\right]$. Combining the attribute matrix $X$ with the quantities of items $Q$ into a quadratic form yields the positive semidefinite matrix $Z = XQX^T \in \mathbb{S}_+^n\subset \mathbb{R}^{n \times n}$, which has rank $l \leq \min(n,k)$. The Matrix $Z$ has a singular value decomposition $Z = V\Lambda V^T$ where $\Lambda = Diag(\lambda) \in \mathbb{S}_{++}^l \subset\mathbb{R}^{l \times l}$, the diagaonal matrix of eigenvalues, and $V=\left[\begin{array}{c}\cdots|& v_j&|\cdots\end{array}\right]\in\mathbb{R}^{n \times l}$. It is still possible that $l$ is quite large. In order to allow for further dimensionality reduction, we may select the $p\le l$ largest eigenvalues to for $\hat \Lambda$ and associated eigenvectors $\hat V$ to approximate $Z$ with $\hat Z = \hat V \hat \Lambda\hat V^T$. ### Note on Eigenvalues It is possible that in a specific case the singular value decomposition of $Z$ results in $\Lambda = Q$. Particularly, it will happen only when the rank of matrix $X$ is $k$. Note that the number of eigenvalues ($\lambda$) expected from the singular value decomposition of $Z$ is equal to its rank and $rank(Z) = rank(X)$. In order for $X$ to have rank $k$, we must have $k = min(n,k)$ meaning that the number of clusters ($k$) needs to be at most equal to the number of features ($n$). Additionally, all the centroids of the clusters need to be linearly independent from each other. However, in reality, it is expected that the number of clusters ($k$) are greater than the dimension of the feature space ($n$) which results in $n = min(n,k)$ and subsequently $rank(X) \leq n$. With this in mind, $rank(X) = n$ is only possible if the features are linearly independent, otherwise $rank(X) < n$. In any of these two cases, the number of eigenvalues expected from the singular value decomposition is going to be less than the number of clusters, and therefore, $\Lambda \not = Q$. ## Energy function Let's suppose our market contains a quantity of a reserve currency $r$, in addition to quantities of items $q_j>0$ of items in clusters $\mathcal{C}_j$ with attribute vectors $\bar x_j$. We define the energy function for this market as $$ \Psi(r,q;X) = r \bigg[ \prod_{j=1}^{k}{\lambda_j(XQX^{T})} \bigg] $$ ## Buy algorithm For a buy scenario that our market maker pays $\Delta r$ to add $\Delta q$ items into its inventory, the transaction must increase its energy. Therefore, having $r - \Delta r$ as the new currency reserve and $Q + \Delta q$ as the new diagonal quantity matrix, we have \begin{aligned} \Psi(r-\Delta r, q+\Delta q; X) &> \Psi(r, q; X) \\ (r-\Delta r) \bigg[ \prod_{j=1}^{k}{\lambda_j\big(X(Q+\Delta q)X^{T}\big)} \bigg] &> r \bigg[ \prod_{j=1}^{k}{\lambda_j(XQX^{T})} \bigg] \\ 1- \frac{\Delta r}{r} &> \frac{ \prod_{j=1}^{k}{\lambda_j(XQX^{T})} }{\prod_{j=1}^{k}{\lambda_j\big(X(Q+\Delta q)X^{T}\big)} }\\ 1- \frac{ \prod_{j=1}^{k}{\lambda_j(XQX^{T})} }{\prod_{j=1}^{k}{\lambda_j\big(X(Q+\Delta q)X^{T}\big)} } &> \frac{\Delta r}{r}\\ \Delta r &< r \bigg[1- \frac{\prod_{j=1}^{k} \lambda_j(XQX^T) }{\prod_{j=1}^{k} \lambda_j(X(Q +\Delta q) X^T)}\bigg]. \end{aligned} Therefore, in order to add $\Delta q$ items into its inventory, ARMM will pay a maximum amount of $r \bigg[1- \frac{\prod_{j=1}^{k} \lambda_j(XQX^T) }{\prod_{j=1}^{k} \lambda_j(X(Q +\Delta q) X^T)}\bigg]$ ## Sell algorithm For a sell scenario that our market maker receives $\Delta r$ to remove $\Delta q$ items from its inventory, the transaction must increase its energy. Therefore, having $r + \Delta r$ as the new currency reserve and $Q - \Delta q$ as the new diagonal quantity matrix, we have \begin{aligned} \Psi(r+\Delta r, q-\Delta q; X) &> \Psi(r, q; X) \\ (r+\Delta r) \bigg[ \prod_{j=1}^{k}{\lambda_j\big(X(Q-\Delta q)X^{T}\big)} \bigg] &> r \bigg[ \prod_{j=1}^{k}{\lambda_j(XQX^{T})} \bigg] \\ 1+ \frac{\Delta r}{r} &> \frac{ \prod_{j=1}^{k}{\lambda_j(XQX^{T})} }{\prod_{j=1}^{k}{\lambda_j\big(X(Q-\Delta q)X^{T}\big)} }\\ \frac{\Delta r}{r} &> \frac{ \prod_{j=1}^{k}{\lambda_j(XQX^{T})} }{\prod_{j=1}^{k}{\lambda_j\big(X(Q-\Delta q)X^{T}\big)} } - 1 \\ \Delta r &> r\bigg[\frac{\prod_{j=1}^{k} \lambda_j(XQX^T) }{\prod_{j=1}^{k} \lambda_j(X(Q -\Delta q) X^T)} - 1\bigg]. \end{aligned} $$ \Delta r > r\bigg[\sqrt[k]{\frac{\prod_{j=1}^{k} \lambda_j(XQX^T) }{\prod_{j=1}^{k} \lambda_j(X(Q -\Delta q) X^T)}} - 1\bigg]$$ Therefore, in order to sell $\Delta q$ items from its inventory, ARMM will receive a minimum amount of $r\bigg[\frac{\prod_{j=1}^{k} \lambda_j(XQX^T) }{\prod_{j=1}^{k} \lambda_j(X(Q -\Delta q) X^T)} - 1\bigg]$ # ARMM as Price recommender Considering that, in order to increase its energy function, ARMM will buy low at a max price of $r \bigg[1- \frac{\prod_{j=1}^{k} \lambda_j(XQX^T) }{\prod_{j=1}^{k} \lambda_j(X(Q +\Delta q) X^T)}\bigg]$ and sell high at a min price of $r\bigg[\frac{\prod_{j=1}^{k} \lambda_j(XQX^T) }{\prod_{j=1}^{k} \lambda_j(X(Q -\Delta q) X^T)} - 1\bigg]$, these prices can also be used as our recommendations. In other words, if ARMM is to be used as a price recommender, the *minimum* recommended price is the maximum price that ARMM is willing to buy the item, and the *maximum* recomended price is the minimum price that ARMM is willing to sell the item. # Recommended price assessment metric How do we assess the quality of ARMM's recommended price? A user queries the price of the NFTs that they want to sell/buy by posting the attributes of NFTs. Depending on whether an order exists matching the attributes or not, there will be two cases: - ## Case 1: Query returns no existing order based on the attributes. Therefore, they are opening a new buy/sell order that doesn't have a complement on the books so ARMM needs to recommend a price to them. ARMM recommendation for item $i$ will be a range as $[\hat{p}_{i,min}, \hat{p}_{i,max}]$ where $\hat{p}_{i,min}$ and $\hat{p}_{i,max}$ are the minimum and the maximum recommended price, respectively. - Case 1a: the user creates an order with the price $p_{i}$ where $\hat{p}_{i,min} \leq p_{i} \leq \hat{p}_{i,max}$. This reflects that the user found the ARMM's recommended price acceptable, and therefore, we consider no penalty for this case. - in this case the $\Delta p_{i} =0$ - Case 1b: the user deviates from the recommendation from the ARMM by some amount and places the order with price $p_{i} < \hat{p}_{i,min}$. This reflects that the user found the ARMM's recommended price more than the value of the NFT, and therefore, we consider a penalty for this case. - in this case the $\Delta p_{i} = \hat{p}_{i,min} - p_{i}$, and since $p_{i} < \hat{p}_{i,min}$, $\Delta p_{i} > 0$. - with this definition, $\Delta p_{i} > 0$ means that the recommended price was higher than the user's valuation for the NFT. - Case 1c: the user deviates from the recommendation from the ARMM by some amount and places the order with price $p_{i} > \hat{p}_{i,max}$. This reflects that the user found the ARMM's recommended price less than the value of the NFT, and therefore, we consider a penalty for this case. - in this case the $\Delta p_{i} = \hat{p}_{i,max} - p_{i}$, and since $p_{i} > \hat{p}_{i,max}$, $\Delta p_{i} < 0$. - with this definition, $\Delta p_{i} < 0$ means that the recommended price was less than the user's valuation for the NFT. - Case 1d: the user chooses not to place an order at all. This case does not provide clear information over the user's valuation, and therefore, we consider no penalty for this case. - in this case the $\Delta p_{i} =0$ As summary, having $[\hat{p}_{i,min}, \hat{p}_{i,max}]$ as the ARMM's recommended range, and $p_{i}$ as the price decided by the user, we define penalty as $$ \Delta p_{i} = \begin{cases} \hat{p}_{i,min} - p_{i} & p_{i} < \hat{p}_{i,min}\\ \hat{p}_{i,max} - p_{i} & p_{i} > \hat{p}_{i,max}\\ 0 & otherwise \end{cases}$$ and models can be compared in different ways such as 1. RMSE = $\sqrt{\frac{\sum_{i=1}^{N} (\Delta p_i)^2}{N}}$ 2. MSE = $\frac{\sum_{i=1}^{N} (\Delta p_i)^2}{N}$ 3. MAE = $\frac{\sum_{i=1}^{N} |\Delta p_i|}{N}$ Another set of metrics can be defined based on the number of out of recommended range orders. \begin{aligned} \text{Ratio of successful recommendations} &= \frac{\sum_{i=1}^{N} I(\hat{p}_{i,min} \leq p_{i} \leq \hat{p}_{i,max})}{N}\\ \text{Ratio of failed recommendations} &= 1- \frac{\sum_{i=1}^{N} I(\hat{p}_{i,min} \leq p_{i} \leq \hat{p}_{i,max})}{N}\\ \text{Ratio of overvalued recommendations} &= \frac{\sum_{i=1}^{N} I( p_{i} \leq \hat{p}_{i,min})}{N}\\ \text{Number of undervalued recommendations} &= \frac{\sum_{i=1}^{N} I( \hat{p}_{i,max} \leq p_{i} )}{N} \end{aligned} - ## Case 1 buyer/seller differentiated In the previous formulation, the price recommendation did not differentiate wether the price was for seller or buyer. To include this in the equations, we define ARMM recommendation for buying item $i$ as the range $[\hat{p}_{i,min}^b, \hat{p}_{i,max}^b]$ where $\hat{p}_{i,min}^b$ and $\hat{p}_{i,max}^b$ are the minimum and the maximum recommended price to buy item $i$, respectively. Similarly, we define ARMM recommendation for selling item $i$ as the range $[\hat{p}_{i,min}^s, \hat{p}_{i,max}^s]$ where $\hat{p}_{i,min}^s$ and $\hat{p}_{i,max}^s$ are the minimum and the maximum recommended price to buy item $i$, respectively. With this definitions, the same equations from Case 1 can be used to measure the price recommended for buy and sell seperately. Consider the following as the example for measuring the performance of buy recommended prices: having $[\hat{p}_{i,min}^b, \hat{p}_{i,max}^b]$ as the ARMM's recommended range, and $p_{i}^b$ as the price decided by the user, we define penalty as $$ \Delta p_{i}^b = \begin{cases} \hat{p}_{i,min}^b - p_{i}^b & p_{i}^b < \hat{p}_{i,min}^b\\ \hat{p}_{i,max}^b - p_{i}^b & p_{i}^b > \hat{p}_{i,max}^b\\ 0 & otherwise \end{cases}$$ and models can be compared in different ways such as 1. RMSE = $\sqrt{\frac{\sum_{i=1}^{N^b} (\Delta p_i^b)^2}{N^b}}$ 2. MSE = $\frac{\sum_{i=1}^{N^b} (\Delta p_i^b)^2}{N^b}$ 3. MAE = $\frac{\sum_{i=1}^{N^b} |\Delta p_i^b|}{N^b}$ where $N^b$ is the number of all the buy orders. - ## Case 2: there are complementing orders that satisfy the user's query. In such case, users are closing out an existing buy/sell order, in which case they will be quoted prices based on the complementing orders. Depending on whether the existing order was following the price recommendation, we define ''accepatble'' and ''unaccepable''. **Note:** as the pricing in this case is based on the existing orders, the metrics defined can be used for evaluating the performance of liquidity providing system rather than the pricing. - Case 2a - acceptable: The ''acceptable'' refers to the case that the existing order found the price recommendation reasonable and set the price in the recommended range. There are two potential outcomes: - Case 2a.1: the order is eventually cleared which tells us that it had an adequate price. This outcome indicates that both buyer and seller found the price acceptable. - Case 2a.2: the order sits there forever and/or eventual timesout or gets removed. This outcome indicates that pricing was only acceptable to the creator of the order. - Case 2b - unacceptable: The ''unacceptable'' refers to the case that the existing order found the price recommendation unreasonable and set the price out of the recommended range. There are two potential outcomes: - Case 2b.1: the order is eventually cleared which tells us that the market has a different valuation compared to the price recommendation system. - Case 2b.2: the order sits there forever and/or eventual timesout or gets removed. This outcome indicates that the market behaved as the price recommender system expected. As summary, having $N$ as the set of orders: \begin{aligned} &\text{Number of closed "acceptable" pricings} = &&\sum_{i=1}^{N} I(\text{Order $i$ followed recommended price and cleared})\\ &\text{Number of expired "acceptable" pricings} = &&\sum_{i=1}^{N} I(\text{Order $i$ followed recommended price but timed out})\\ &\text{Number of closed "unacceptable" pricings} = &&\sum_{i=1}^{N} I(\text{Order $i$ did NOT followed recommended price and cleared})\\ &\text{Number of expired "unacceptable" pricings} = &&\sum_{i=1}^{N} I(\text{Order $i$ did NOT followed recommended price and timed out}) \end{aligned} and models can be compared in different ways such as but not limited to 1. Ratio of closed "acceptable" pricings = $\frac{\text{Number of closed "acceptable" pricings}}{\text{Total number of orders}}$ 2. Ratio of closed "unacceptable" pricings = $\frac{\text{Number of closed "unacceptable" pricings}}{\text{Total number of orders}}$

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully