Introduction
In the following article we will use the API provided by cryptocompare that allow us to import the Order Book from Binance. Using this data we will try to estimate a very simple model for demand and supply for Bitcoin. In July 2022 the price of Bitcoin is fluctuating in the range from 18700 and 24000 dollars.
ggplot()+
geom_line(data = mutate(BTC_hourly_price, eq.price = 21250), aes(Date, Adj), color = "#FF9416")+
geom_line(data = mutate(BTC_hourly_price, eq.price = 21250), aes(Date, eq.price), color = "red")+
geom_label(data = BTC_hourly_price[100,], aes(Date, 20850, label = "Eq. Price [20 850]"), alpha = 0.8)+
ggthemes::theme_solarized()+
theme(axis.text.x = element_text(angle = 0, face = "bold", size = 7),
axis.text.y = element_text(face = "bold"),
axis.title = element_text(face = "bold"),
plot.title = element_text(face = "bold"),
plot.subtitle = element_text(face = "italic"),
plot.caption = element_text(face = "italic"),
panel.grid.major.x = element_line(colour="grey60", linetype="dotted"),
panel.grid.minor.x = element_blank(),
panel.grid.major.y = element_line(colour="grey60", linetype="dotted"),
legend.text = element_text(face = "italic", size = 5),
legend.title = element_text(face = "bold"),
legend.position = "top" ) +
ggtitle("Bitcoin, Hourly Price", subtitle = paste0("From: ", BTC_hourly_price$Date[1], "; To: ", BTC_hourly_price$Date[nrow(BTC_hourly_price)])) +
xlab("")+
ylab("Price")+
labs(caption = "July 2022")In order to have an idea on the behaviour of Bitcoin with respect to Altcoin market, we could use Ethereum as proxy and compare the returns computed starting from the first observation in July. As we can see Ethereum is over performing Bitcoin in this month, indicating that the Altcoin market is not so weak, insted is reacting very well to this period of bear market.
ret_BTC_df = bind_cols(BTC_hourly_price, Ret = ComputeReturns(BTC_hourly_price$Adj, perc = TRUE, dynamics = FALSE) )
ret_ETH_df = bind_cols(ETH_hourly_price, Ret = ComputeReturns(ETH_hourly_price$Adj, perc = TRUE, dynamics = FALSE) )
ETH_BTC_df = bind_rows(ret_BTC_df, ret_ETH_df)
gap_df = tibble(x = ret_BTC_df[nrow(ret_BTC_df),]$Date, xend = ret_BTC_df[nrow(ret_BTC_df),]$Date, y = ret_BTC_df[nrow(ret_BTC_df),]$Ret, yend = ret_ETH_df[nrow(ret_ETH_df),]$Ret)
label_df = tibble(x = ret_BTC_df[nrow(ret_BTC_df),]$Date, y = (gap_df$yend+gap_df$y)/2, label = paste0(round(gap_df$yend-gap_df$y,2), " %" ))
ggplot()+
geom_line(data = ETH_BTC_df, aes(Date, Ret, color = Symbol))+
geom_segment(data = gap_df, aes(x, y, xend = xend, yend = yend), linetype = "dashed", color = "red") +
geom_label(data = label_df, aes(x, y, label = label), size = 3)+
geom_point(data = gap_df, aes(x, y), color = "red") +
geom_point(data = gap_df, aes(xend, yend), color = "red") +
ggthemes::theme_solarized()+
theme(axis.text.x = element_text(angle = 0, face = "bold", size = 7),
axis.text.y = element_text(face = "bold"),
axis.title = element_text(face = "bold"),
plot.title = element_text(face = "bold"),
plot.subtitle = element_text(face = "italic"),
plot.caption = element_text(face = "italic"),
panel.grid.major.x = element_line(colour="grey60", linetype="dotted"),
panel.grid.minor.x = element_blank(),
panel.grid.major.y = element_line(colour="grey60", linetype="dotted"),
legend.text = element_text(face = "italic", size = 10),
legend.title = element_text(face = "bold"),
legend.position = "none" ) +
ggtitle("Comparison between returns of BTC (Orange) & ETH (Black)") +
scale_color_manual(values = c("#FF9416", "#383838"))+
xlab("")+
ylab("Return (%)")+
labs(caption = "July 2022")The Order Book on Binance
The Order Book for a given exchange is composed by two parts:
the BID curve (Green), that represent the Demand curve. This curve is composed by the limit buy order placed for a given price. For example if read 180 BTC in correspondence of a price of 21000 dollars means that there is a limit buy of that amount at that price.
the ASK curve (Red), instead, represent the Supply curve, and the mechanism are like above but with limit sell orders.
A more usefull reppresentation is to compute the cumulative quantity for the ASK/BID curve, in this way:
ggplot()+
geom_line(data = unnest(db_binanceL2[1,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_label(data = unnest(db_binanceL2[1,])[1,], (aes(BID_Price - 150, BID_Quantity, label = "13 July")))+
geom_line(data = unnest(db_binanceL2[1,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
geom_line(data = unnest(db_binanceL2[2,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_label(data = unnest(db_binanceL2[2,])[1,], (aes(BID_Price - 150, BID_Quantity, label = "14 July")))+
geom_line(data = unnest(db_binanceL2[2,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red")+
geom_line(data = unnest(db_binanceL2[3,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_label(data = unnest(db_binanceL2[3,])[1,], (aes(BID_Price - 150, BID_Quantity, label = "15-16-17 July")))+
geom_line(data = unnest(db_binanceL2[3,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red")+
geom_line(data = unnest(db_binanceL2[4,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_line(data = unnest(db_binanceL2[4,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
geom_line(data = unnest(db_binanceL2[5,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_line(data = unnest(db_binanceL2[5,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
geom_line(data = unnest(db_binanceL2[6,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_label(data = unnest(db_binanceL2[6,])[1,], (aes(BID_Price - 100, BID_Quantity, label = "18 July")))+
geom_line(data = unnest(db_binanceL2[6,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
ggthemes::theme_solarized()+
theme(axis.text.x = element_text(angle = 0, face = "bold", size = 7),
axis.text.y = element_text(face = "bold"),
axis.title = element_text(face = "bold"),
plot.title = element_text(face = "bold"),
plot.subtitle = element_text(face = "italic"),
plot.caption = element_text(face = "italic"),
panel.grid.major.x = element_line(colour="grey60", linetype="dotted"),
panel.grid.minor.x = element_blank(),
panel.grid.major.y = element_line(colour="grey60", linetype="dotted"),
legend.text = element_text(face = "italic", size = 10),
legend.title = element_text(face = "bold"),
legend.position = "top" ) +
ggtitle("Supply & Demand: Binance Order Book", "Red(ASK): Supply, Green(BID): Demand") +
xlab("Quantity")+
ylab("Price")+
labs(caption = "July 2022")We have taken a screen shot of the order book for these days, we can see what happen when the price is in an increasing trend: every day the equilibrium price moves on the right lefting some holes between on curve and another (but if we are able to have for example the hourly data those holes will be smaller). We have continued to import the data every day, since equilibrium price of the 16th of july is very similar to the 15th of July we have chosen to represent it in another graph. As we can see the demand and supply seems to be quite in equilibrium for the 16 th with a strong buy pressure under 20600 dollars and a strong sell pressure above 21000 dollars.
ggplot()+
geom_line(data = unnest(db_binanceL2[7,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_label(data = unnest(db_binanceL2[7,])[1,], (aes(BID_Price - 100, BID_Quantity, label = "23 July")))+
geom_line(data = unnest(db_binanceL2[7,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
geom_line(data = unnest(db_binanceL2[8,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_line(data = unnest(db_binanceL2[8,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
geom_line(data = unnest(db_binanceL2[9,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_label(data = unnest(db_binanceL2[9,])[1,], (aes(BID_Price - 100, BID_Quantity, label = "25 July")))+
geom_line(data = unnest(db_binanceL2[9,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
geom_line(data = unnest(db_binanceL2[10,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_label(data = unnest(db_binanceL2[10,])[1,], (aes(BID_Price - 100, BID_Quantity, label = "27 July")))+
geom_line(data = unnest(db_binanceL2[10,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
geom_line(data = unnest(db_binanceL2[11,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_label(data = unnest(db_binanceL2[11,])[1,], (aes(BID_Price - 100, BID_Quantity, label = "24-28 July")))+
geom_line(data = unnest(db_binanceL2[11,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
geom_line(data = unnest(db_binanceL2[12,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_label(data = unnest(db_binanceL2[12,])[1,], (aes(BID_Price - 100, BID_Quantity, label = "29 July")))+
geom_line(data = unnest(db_binanceL2[12,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
ggthemes::theme_solarized()+
theme(axis.text.x = element_text(angle = 0, face = "bold", size = 7),
axis.text.y = element_text(face = "bold"),
axis.title = element_text(face = "bold"),
plot.title = element_text(face = "bold"),
plot.subtitle = element_text(face = "italic"),
plot.caption = element_text(face = "italic"),
panel.grid.major.x = element_line(colour="grey60", linetype="dotted"),
panel.grid.minor.x = element_blank(),
panel.grid.major.y = element_line(colour="grey60", linetype="dotted"),
legend.text = element_text(face = "italic", size = 10),
legend.title = element_text(face = "bold"),
legend.position = "top" ) +
ggtitle("Supply & Demand: Binance Order Book", "Red(ASK): Supply, Green(BID): Demand") +
xlab("Quantity")+
ylab("Price")+
labs(caption = "July 2022")In the last days of may the price of bitcoin has experienced a pump till 24000 dollars and now it is decreasing till 23000.
ggplot()+
geom_line(data = unnest(db_binanceL2[13,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_label(data = unnest(db_binanceL2[13,])[1,], (aes(BID_Price - 100, BID_Quantity, label = "30 July")))+
geom_line(data = unnest(db_binanceL2[13,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
geom_line(data = unnest(db_binanceL2[14,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_label(data = unnest(db_binanceL2[14,])[1,], (aes(BID_Price - 100, BID_Quantity, label = "31 July")))+
geom_line(data = unnest(db_binanceL2[14,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
geom_line(data = unnest(db_binanceL2[15,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_label(data = unnest(db_binanceL2[15,])[1,], (aes(BID_Price - 100, BID_Quantity, label = "1 August")))+
geom_line(data = unnest(db_binanceL2[15,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
ggthemes::theme_solarized()+
theme(axis.text.x = element_text(angle = 0, face = "bold", size = 7),
axis.text.y = element_text(face = "bold"),
axis.title = element_text(face = "bold"),
plot.title = element_text(face = "bold"),
plot.subtitle = element_text(face = "italic"),
plot.caption = element_text(face = "italic"),
panel.grid.major.x = element_line(colour="grey60", linetype="dotted"),
panel.grid.minor.x = element_blank(),
panel.grid.major.y = element_line(colour="grey60", linetype="dotted"),
legend.text = element_text(face = "italic", size = 10),
legend.title = element_text(face = "bold"),
legend.position = "top" ) +
ggtitle("Supply & Demand: Binance Order Book", "Red(ASK): Supply, Green(BID): Demand") +
xlab("Quantity")+
ylab("Price")+
labs(caption = "July 2022")ggplot()+
geom_line(data = unnest(db_binanceL2[16,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_label(data = unnest(db_binanceL2[16,])[1,], (aes(BID_Price - 100, BID_Quantity, label = "6 August")))+
geom_line(data = unnest(db_binanceL2[16,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
geom_line(data = unnest(db_binanceL2[17,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_label(data = unnest(db_binanceL2[17,])[1,], (aes(BID_Price - 100, BID_Quantity, label = "8 August")))+
geom_line(data = unnest(db_binanceL2[17,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
geom_line(data = unnest(db_binanceL2[18,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_label(data = unnest(db_binanceL2[18,])[1,], (aes(BID_Price - 100, BID_Quantity, label = "23 August")))+
geom_line(data = unnest(db_binanceL2[18,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
geom_line(data = unnest(db_binanceL2[19,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_line(data = unnest(db_binanceL2[19,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
geom_line(data = unnest(db_binanceL2[20,]), (aes(BID_Price, cumsum(BID_Quantity))), color = "green")+
geom_label(data = unnest(db_binanceL2[20,])[1,], (aes(BID_Price - 100, BID_Quantity, label = "27-28 August")))+
geom_line(data = unnest(db_binanceL2[20,]), (aes(ASK_Price, cumsum(ASK_Quantity))), color = "red") +
ggthemes::theme_solarized()+
theme(axis.text.x = element_text(angle = 0, face = "bold", size = 7),
axis.text.y = element_text(face = "bold"),
axis.title = element_text(face = "bold"),
plot.title = element_text(face = "bold"),
plot.subtitle = element_text(face = "italic"),
plot.caption = element_text(face = "italic"),
panel.grid.major.x = element_line(colour="grey60", linetype="dotted"),
panel.grid.minor.x = element_blank(),
panel.grid.major.y = element_line(colour="grey60", linetype="dotted"),
legend.text = element_text(face = "italic", size = 10),
legend.title = element_text(face = "bold"),
legend.position = "top" ) +
ggtitle("Supply & Demand: Binance Order Book", "Red(ASK): Supply, Green(BID): Demand") +
xlab("Quantity")+
ylab("Price")+
labs(caption = "July 2022")Curve of Supply and Demand
In this part we will try to extrapolate an estimate of the curve of Demand and Supply using the data from the order book of Binance. In order to estimate such model we should have a dataset in which at each price should correspond a quantity that the buyers/sellers are willing to buy/sell. Obviosly this kind of data are not directly available, but we can build it from the order book aggregating the orders book for differents days. For each day in time we have at our disposal:
BID Prices and BID Quantity that are the prices at which the buyers will buy a certain quantity, in other words, is the size of the limit buy order placed for the price BID Price.
ASK Prices and ASK Quantity that are the prices at which the sellers will sell a certain quantity, in other words, is the size of the limit sell order placed for the price ASK Price
The procedure used to build such curve is to:
- using multiple days we split our data in 2 considering the ASK/BID separately and for each one we compute the sum quantity ASK/BID for each price in the serie.
- each dataset is reordered (increasing) with respect to the price and the the cumulated quantities for each ASK/BID prices is computed.
- finally using the dataset obtained we can estimate the following system of equations:
\[\begin{cases} Q^{BID}(P) = \beta_0^{BID} + \beta_1^{BID} P \\ \\ Q^{ASK}(P) = \beta_0^{ASK} + \beta_1^{ASK} P \end{cases}\]
The \(\beta_1\) coefficients represents the increase/decreas in quantity (demanded or supply) due to a unitary increase of price.
model1 = SupplyDemandBTC(start_date = "2022-07-13", end_date = "2022-07-18", db.name = "db_binanceL2", min_price = 12000, max_price = 30000)
model2 = SupplyDemandBTC(start_date = "2022-07-13", end_date = "2022-07-24", db.name = "db_binanceL2", min_price = 10000, max_price = 30000)
model3 = SupplyDemandBTC(start_date = "2022-07-13", end_date = "2022-07-27", db.name = "db_binanceL2", min_price = 10000, max_price = 30000)
model4 = SupplyDemandBTC(start_date = "2022-07-13", end_date = "2022-08-08", db.name = "db_binanceL2", min_price = 10000, max_price = 30000)
model5 = SupplyDemandBTC(start_date = "2022-07-13", end_date = "2022-08-28", db.name = "db_binanceL2", min_price = 5000, max_price = 30000)
bind_rows(model1$model, model2$model, model3$model, model4$model, model5$model) %>%
arrange(Model) %>%
knitr::kable(caption = "Coeffients of Supply and Demand symultaneus equations") %>%
kableExtra::kable_classic() %>%
kable_styling(latex_options = "hold_position")| start | end | Model | Beta0 | Beta1 | MSE |
|---|---|---|---|---|---|
| 2022-07-13 | 2022-07-18 | ASK (Supply) | -180.09447 | 0.0166060 | 444.1607 |
| 2022-07-13 | 2022-07-24 | ASK (Supply) | -189.94317 | 0.0195574 | 604.8345 |
| 2022-07-13 | 2022-07-27 | ASK (Supply) | -243.53999 | 0.0249984 | 759.5230 |
| 2022-07-13 | 2022-08-08 | ASK (Supply) | 50.71026 | 0.0194391 | 1178.0711 |
| 2022-07-13 | 2022-08-28 | ASK (Supply) | 458.88359 | 0.0058360 | 1386.7067 |
| 2022-07-13 | 2022-07-18 | BID (Demand) | 537.75500 | -0.0179946 | 441.2880 |
| 2022-07-13 | 2022-07-24 | BID (Demand) | 510.83494 | -0.0138615 | 556.6905 |
| 2022-07-13 | 2022-07-27 | BID (Demand) | 549.09734 | -0.0125624 | 694.2828 |
| 2022-07-13 | 2022-08-08 | BID (Demand) | 574.54816 | -0.0052134 | 1080.1065 |
| 2022-07-13 | 2022-08-28 | BID (Demand) | 971.00415 | -0.0187063 | 1301.1335 |
An interpretation of the cofficients, considering the first model (13/07 - 18/07):
- \(\beta_1^{ASK}\): for an increase of 1 in the bitcoin price the quantity in the limit sell orders increase by \(\beta_1^{ask} \sim 0.0166\) BTC.
- \(\beta_1^{BID}\): for an increase of 1 in the bitcoin price the quantity in the limit buy orders decrease by \(\beta_1^{bid} \sim 0.0179\) BTC.
As we can see during the dump in the 26/27/28 of August the behaviour of the buyer and the sellers seems to be changed, in fact looking at the betas, for the model from 13/07 to 28/08:
- \(\beta_1^{ASK}\): for an increase of 1 in the bitcoin price the quantity in the limit sell orders increase by \(\beta_1^{ask} \sim 0.0058360\) BTC.
- \(\beta_1^{BID}\): for an increase of 1 in the bitcoin price the quantity in the limit buy orders decrease by \(\beta_1^{bid} \sim 0.0187063\) BTC.
Therefore seems that the seellers are more reluctant to sell at this lower price but at the same time the demand in increasing. Comparing the beta of the Demand of the last model (28/08) with the other ones we can see that it has reached its maximum, denoting a strong demand despite the fall in price. Moreover the equilibrium price is not changed during this two months, it vary between 20700 and 21300.
BTC_price_model1 <- filter(BTC_hourly_price, Date == as.POSIXct("2022-07-18 09:00:00 CEST"))$Adj
BTC_price_model2 <- filter(BTC_hourly_price, Date == as.POSIXct("2022-07-24 14:00:00 CEST"))$Adj
BTC_price_model3 <- filter(BTC_hourly_price, Date == as.POSIXct("2022-07-27 14:00:00 CEST"))$Adj
BTC_price_model4 <- filter(BTC_hourly_price, Date == as.POSIXct("2022-08-08 14:00:00 CEST"))$Adj
model1$plot +
geom_point(data = tibble(P = BTC_price_model1, pred_ASK = model1$model$Beta0[2] + model1$model$Beta1[2]*P ), aes(pred_ASK, P), color = "black", size = 2.5)+
geom_point(data = tibble(P = BTC_price_model1, pred_BID = model1$model$Beta0[1] + model1$model$Beta1[1]*P ), aes(pred_BID, P), color = "black", size = 2.5)+
ggtitle(paste0("Supply & Demand: Binance OB ( BTC Price: ", BTC_price_model1, " $)"))model2$plot+
geom_line(data = mutate(model1$predict, P = model1$predict$P), aes(pred_BID, P), linetype = "dotted", color = "purple")+
geom_line(data = mutate(model1$predict, P = model1$predict$P), aes(pred_ASK, P), linetype = "dotted", color = "purple")+
geom_point(data = tibble(P = BTC_price_model2, pred_ASK = model2$model$Beta0[2] + model2$model$Beta1[2]*P ), aes(pred_ASK, P), color = "black", size = 2.5)+
geom_point(data = tibble(P = BTC_price_model2, pred_BID = model2$model$Beta0[1] + model2$model$Beta1[1]*P ), aes(pred_BID, P), color = "black", size = 2.5)+
ggtitle(paste0("Supply & Demand: Binance OB ( BTC Price: ", BTC_price_model2, " $)"))model3$plot+
geom_line(data = mutate(model1$predict, P = model1$predict$P), aes(pred_BID, P), linetype = "dotted", color = "purple")+
geom_line(data = mutate(model1$predict, P = model1$predict$P), aes(pred_ASK, P), linetype = "dotted", color = "purple")+
geom_line(data = mutate(model2$predict, P = model2$predict$P), aes(pred_BID, P), linetype = "dotted")+
geom_line(data = mutate(model2$predict, P = model2$predict$P), aes(pred_ASK, P), linetype = "dotted")+
geom_point(data = tibble(P = BTC_price_model3, pred_ASK = model3$model$Beta0[2] + model3$model$Beta1[2]*P ), aes(pred_ASK, P), color = "black", size = 2.5)+
geom_point(data = tibble(P = BTC_price_model3, pred_BID = model3$model$Beta0[1] + model3$model$Beta1[1]*P ), aes(pred_BID, P), color = "black", size = 2.5)+
ggtitle(paste0("Supply & Demand: Binance OB ( BTC Price: ", BTC_price_model3, " $)"))model4$plot+
geom_line(data = mutate(model3$predict, P = model3$predict$P), aes(pred_BID, P), linetype = "dotted")+
geom_line(data = mutate(model3$predict, P = model3$predict$P), aes(pred_ASK, P), linetype = "dotted")+
geom_point(data = tibble(P = BTC_price_model4, pred_ASK = model4$model$Beta0[2] + model4$model$Beta1[2]*P ), aes(pred_ASK, P), color = "black", size = 2.5)+
geom_point(data = tibble(P = BTC_price_model4, pred_BID = model4$model$Beta0[1] + model4$model$Beta1[1]*P ), aes(pred_BID, P), color = "black", size = 2.5)+
ggtitle(paste0("Supply & Demand: Binance OB ( BTC Price: ", BTC_price_model4, " $)"))The black points represents the ASK/BID quantity estimate for the market price of the last day using the represented model. The black dotted line represent the model till 24 of July while the purple lines represent the curve using the model till 18 of July. We can see how the points in the estimate converges to the equilibrium price, in fact in the estimates for 18/07 and 24/07 the price was very far from the equilibrium and this causes the movement of both curves till reaching a new equilibrium. In the last day (27/07) seems that a new equilibrium, around 21000 dollars, was found.
As we can see the \(\beta_1^{BID}\) is lower in the 3 model with respect to the other 2, an interpretation of this could be the change in the behaviour of the buyer: an increase of \(\beta_1^{BID}\) means that if the price increase, ceteribus paribus, the buyer will place a limit order for a lower quantity. In the same way if \(\beta_1^{BID}\) decrease it means that the buyer are less sensitive to price and will buy a greater quantity even if the price increase. On the opposite the behaviour of the sellers also changed, in fact an increase of \(\beta_1^{ASK}\) means that for an increase of price the sellers will sell more bitcoin. Summarising till now we have that:
- the buyers are buying more even if the price is going up (more in 3 model with respect to 1 model).
- the sellers are selling more when the price goes up (more in 3 model with respect to 1 model).
BTC_price_model5 <- filter(BTC_hourly_price, Date == as.POSIXct("2022-08-28 17:00:00 CEST"))$Adj
model5$plot+
geom_line(data = mutate(model4$predict, P = model4$predict$P), aes(pred_BID, P), linetype = "dotted")+
geom_line(data = mutate(model4$predict, P = model4$predict$P), aes(pred_ASK, P), linetype = "dotted")+
geom_point(data = tibble(P = BTC_price_model5, pred_ASK = model5$model$Beta0[2] + model5$model$Beta1[2]*P ), aes(pred_ASK, P), color = "black", size = 2.5)+
geom_point(data = tibble(P = BTC_price_model5, pred_BID = model5$model$Beta0[1] + model5$model$Beta1[1]*P ), aes(pred_BID, P), color = "black", size = 2.5)+
ggtitle(paste0("Supply & Demand: Binance OB ( BTC Price: ", BTC_price_model5, " $)"))In the last model the behaviour of the buyers/sellers is again different, looking at the change in the coefficients seems that:
- the sellers are selling less
- the buyers are buying more
This mixed behaviour have cause the pump of the bitcoin price in the last days but as we can see the equilibrium price is increased but not changed drammatically, therefore it is probable to touch the 21200/21500 dollars again. Till the equilibrium price is around 21000 dollars the price will continue to fluctuate around that level.