FinML / method /Readme.md
StevenJingfeng's picture
Update method/Readme.md
cc83345 verified

Research Question Formulation

Objective

RQ1: Can this dataset be applied to different machine learning models?
RQ2: Can this dataset be extended to apply to other algorithms, enhancing its utility and revealing additional insights in financial market analysis?

Significance

Our analysis indicates that among the four machine learning models evaluated, DNN demonstrated the best prediction performance in both fungible token airdrop and normal periods. Specifically, DNN models showed superior predictive accuracy for gas usage during these periods. The results highlighted minimal disparity in prediction loss when comparing a DNN trained on data from normal periods to a DNN trained on data specifically from the token-airdrop period. This finding suggests that DNN models exhibit robust scalability on this dataset, eliminating the need to train a new neural network specifically for token-airdrop events. In addition to evaluating DNN models, we explored the extensibility of incorporating monotonicity constraints and sentiment analysis within the Neural Additive Model (NAM). Although these enhancements did not significantly improve the predictive accuracy of the NAM model on our test dataset, the intrinsic variability and complexity of blockchain data imply that different datasets from different time periods might yield different results. This opens a significant platform for other researchers to utilize and further explore the dataset, enabling comprehensive analyses and advancing financial machine-learning models. Our contributions include developing a comprehensive dataset that integrates both on-chain and off-chain data, compatible with various machine learning algorithms for financial prediction. This dataset forms the cornerstone of a novel research framework, enabling a deeper exploration of the financial market and its mechanisms. By offering a robust and versatile dataset, we facilitate advanced exploration and optimization efforts, driving innovation and enhancing the accuracy and reliability of financial machine-learning models in blockchain technology.

Data Selection

We query Ethereum’s data using Google BigQuery. The raw data contains information on timestamps, block numbers, hash, parent hash, transaction, etc. Since our research aims to predict gas used in the next block, we only keep the relevant features, including time stamp, block number, gas limit, gas used, and base fee. Notably, the token-airdrop can substantially boost recipients' and non-recipients' engagement levels in the transactions. As a result, high volatility in gas used will occur and lead to subsequent base fee alternation. Hence, our research is structured around two distinct periods. The first period spans the apex of the ARB airdrop, recognized as the most substantial in 2023, from March 21 to April 1, encompassing 78290 blocks. The second period pertains to the month devoid of significant token-airdrop activities, spanning from June 1st, 2023, to July 1st, 2023, and containing 213244 blocks.

We also query the discord data.

Data

On-chain data

We utilize Google BigQuery to extract Ethereum's blockchain data, including timestamps, block numbers, hashes, parent hashes, transactions, etc. We retain only the pertinent features to predict gas usage in forthcoming blocks: timestamp, gas limit, gas used, and base fee. We exclude other variables, such as transaction numbers, despite their high correlation with gas usage, based on our specific research focus. Furthermore, our study acknowledges the impact of token airdrops on transaction engagement levels for recipients and non-recipients. According to Guo\cite{guo2023spillover}, token airdrops can significantly influence engagement, resulting in pronounced gas usage volatility and subsequent base fee fluctuations. Consequently, our analysis is bifurcated into two distinct periods. The first period examines the ARB token airdrop, the most substantial airdrop event in 2023, which occurred from March 21 to April 1 and comprised 78,290 blocks. The second period, devoid of significant fungible token airdrop activities, extends from June 1, 2023, to July 1, 2023, encompassing 213,244 blocks. This temporal delineation allows for a comprehensive analysis of the effects of significant airdrop events on Ethereum's gas dynamics.

Variable Description
Variable Name Description Unit Type
timestamp Recording of the time of each block String
number The number of blocks on the chain Numeric
gas_used Actual Gas Used Gwei Numeric
gas_limit The maximum allowed gas per block Gwei Numeric
base_fee_per_gas The base fee set for each block Ether Numeric
gas_fraction Fraction between Gas Used and Gas Limit Numeric
gas_target The optimal gas used for each block Numeric
Y Normalized Gas Used Numeric
$Y_t$ Response variable equals to the gas_fraction Numeric

Data processing

In the original dataset, the base fee is denominated in units of Gwei, where each Gwei is equivalent to $10^{-9}$ Ether. Consequently, for enhanced interpretability of the dataset, we scale the base fee by $10^{-9}$, expressing it in terms of Ether.

We create a regressor, denoted as $\alpha$, by computing the ratio of gas used to the gas limit. The predicted variable $Y$ represents the normalized gas used, determined by the formula:

\[ Y = \frac{{\text{{gasUsed}} - \text{{gasTarget}}}}{{\text{{gasTarget}}}} \]

For varying periods $k$, the regressor variable for the preceding $k$ data points is collected into a list, forming the feature set $X$. The variable $Y$ corresponds precisely to the prediction variable for the data point at time $t$.

Off-chain data

We focused our analysis on key communities within the blockchain ecosystem, specifically targeting the Binance, Uniswap, and Ethereum Dev channels on Discord. These communities represent major segments of the industry: Binance as the largest centralized exchange, Uniswap as a leading decentralized exchange, and Ethereum Dev as a hub for Ethereum developers. Our data collection involved querying the discussion text from the "general" channels of these three communities.We query all the discussion data of the selected channels, starting from the establish date of each channel until April 2, 2024. After aggregating the text data, we compiled a total of 728863 individual discussion entries.

AuthorID Date Content Attach
301186049323958272 2019-08-24 13:47 If you believe that each of these stable coins are eventually stable though, then you'll make money on the swinging back and forth. NA
510252034310799360 2019-08-24 14:59 Heh, I was imagining a world where the pool has more liquidity than the rest of the market participants combined. Your, actually realistic, scenario makes it a little difficult for pool participants to exit. NA
589621262733672448 2019-08-24 17:02 I kinda prefer variable price. NA

Data processing

we also incorporate an additional off-chain data source, specifically the discussion text from Discord. To analyze this data, we use a large language model to process English sentences or words, estimating the probability of each sentence being classified as positive, negative, or neutral, ensuring that the total probability sums to 1. After obtaining sentiment information, we organize the corpus sequentially and compute average sentiment scores over both hourly and daily intervals. This sentiment information is denoted as gammma. We then synchronize the on-chain data with the off-chain sentiment using corresponding block data from the previous time chunk, ensuring that only preceding sentiment information is included in the training data.

Monotonicity

we propose a novel method for predicting gas usage in blockchain transactions, inspired by the concept of pairwise monotonicity as detailed by Chen \cite{chen2023address}. Unlike traditional methods like EMA, which emphasizes the forgetting of older information, our approach employs a monotonicity representation to attribute varying levels of importance to data over time. Monotonicity has demonstrated its interdisciplinary applicability, as evidenced by works such as Liu et al. \cite{liu2020certified} and Milani \cite{milani2016fast}, which focused on individual monotonicity for single variables. Our method is inspired by Chen's work \cite{chen2023address} for introducing pairwise monotonicity in the financial domain. For instance, past due amounts over a longer period in credit scoring should more significantly impact the scoring of new debt risk. Similarly, older data points are less influential in blockchain transactions, whereas recent data points are more critical for prediction.

We apply monotonicity to the α feature, where changes in α for recent blocks result in greater prediction variance than changes in distant previous data points.

FinBert model

The sentiment extraction from the data is conducted using FinBert, a model proposed by Dogu and Araci in 2019 \cite{araci2019finbert}. FinBert is a BERT-based architecture specifically trained on financial data sets, including the Financial PhraseBank, TRC2-financial, and FiQA Sentiment. This training enables FinBert to achieve state-of-the-art performance in FiQA sentiment scoring. Our research uses FinBert to predict sentiment in our text data, ensuring accurate sentiment analysis aligned with financial contexts.

NAM model

The Neural Additive Model (NAM), proposed by Agarwal et al. in 2021 \cite{agarwal2021neural}, offers a transparent framework for utilizing Deep Neural Networks (DNNs) to model individual or combined features. In this architecture, the outputs from all DNNs are aggregated at the final hidden layer, resulting in a unified model. Our research omits interactions between unrelated features, enabling the imposition of weak monotonicity constraints on each feature.