Giter Club home page Giter Club logo

aevootcanalysis's Introduction

AevoOTC

Introduction

Analysis of Aevo alt option OTC trades PNL.

Usage

  1. Create a .env file with API_KEY=xxx where xxx is your alchemy api key
  2. (Optional) Go to alchemy playground and put the response to data/tokenMintEvents.json This is because there's a limit for the maximum block range we can query(2k).
  3. npm install .
    chmod +x lfg.sh
    ./lfg.sh
    

Methodology

To get All OTC transactions, we only pay attention to the following event:

Address
0xfed805e631ab9ed2b94f91255dd2714157fa759d
Name
ShortOtokenMinted (index_topic_1 address otoken, index_topic_2 address AccountOwner, index_topic_3 address to, uint256 vaultId, uint256 amount)View Source

Topics
0 0x4d7f96086c92b2f9a254ad21548b1c1f2d99502c7949508866349b96bb1a8d8a

We first get all events emitted by address 0xfed805e631ab9ed2b94f91255dd2714157fa759d

{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "eth_getLogs",
  "params": [
    {
      "fromBlock": "0x0",
      "toBlock": "0x10B5E39",
      "address": "0xFED805e631aB9Ed2b94F91255DD2714157fA759d",
      "topics": [
        "0x4d7f96086c92b2f9a254ad21548b1c1f2d99502c7949508866349b96bb1a8d8a"
      ]
    }
  ]
}

Then in extract_tx.js, we do:

  1. get the timestamp of the tx from transaction hash => block number => block timestamp
  2. get the premium of each option, this is done through checking eth_getTransactionReceipt
  3. get the minted option token, then aggregate all fields replated to that token, which looks like:
  {
    decimals: 8,
    logo: null,
    name: 'BNBUSDC 30-June-2023 230Put USDC Collateral',
    symbol: 'oBNBUSDC/USDC-30JUN23-230P',
    tokenHash: '0xe5b284a2b69c08f5f879640d85d3d69fa723f551',
    transactionHash: '0x1886e90924c7eaa411cd76925ae93f2a66fb66b1569abc25cf53d078bafef316',
    optionBuyerAddr: '0x7ca28c291c806c955f48cdd7445e65fd702acec6',
    transactionTimeStamp: 1687443407
  }

With these, we are ready to fetch the settlement price (if expired) for each option. We use the Binance endpoint can be queried like https://data.binance.vision/data/spot/daily/klines/{ticker}USDT/{granularity}/{ticker}USDT-{granularity}-{date}.zip

We download the market data with a granularity up to 1h and get the spot price at time UTC 08:00. All data are downloaded at data directory. The final aggregated PNL csv file is located in result/TokenInfo_processed.csv.

Here is the result up to June 30.

PNL Analysis up to June 30

Vol Smile Visualization

Head to scripts/smiles.ipynb. Remember to replace aevo_api_url with the actual endpoint.

Vol Smile

Contact

Twitter @0xJChen

aevootcanalysis's People

Contributors

0xjchen avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.