Master Level Python Coding Assignment For The Major Of Business Analytics

Abstract

We study the price impact of order book events – limit orders, market orders and cancelations – using the NYSE TAQ data for 50 U.S. stocks. We show that, over short time intervals, price changes are mainly driven by the order flow imbalance, defined as the imbalance between supply and demand at the best bid and ask prices. Our study reveals a linear relation between order flow imbalance and price changes, with a slope inversely proportional to the market depth. These results are shown to be robust to seasonality effects, and stable across time scales and across stocks. We argue that this linear price impact model, together with a scaling argument, implies the empirically observed “square-root” relation between price changes and trading volume. However, the relation between price changes and trade volume is found to be noisy and less robust than the one based on order flow imbalance.

1. Introduction

The availability of high-frequency records of trades and quotes has stimulated an extensive empirical and theoretical literature on the relation between order flow, liquidity and price movements in order-driven markets. A particularly important issue for applications is the impact of orders on prices: the optimal liquidation of a large block of shares, given a fixed time horizon, crucially involves assumptions on price impact (see Bertsimas and Lo [6], Almgren and Chriss [2], Obizhaeva and Wang [35]).

Various models for price impact have been proposed in the literature but there is little agreement on how to model it [7]. In the empirical literature, price impact has been described by various authors as linear, non-linear, square root, virtual, mechanical, temporary, instantaneous, permanent or transient. The only consensus seems to be the intuitive notion that imbalance between supply and demand moves prices.

The empirical literature on price impact has primarily focused on trades. One approach is to study the impact of “parent orders” gradually executed over time using proprietary data (see Engle et. al [14], Almgren et. al [3]). Alternatively, empirical studies on public data [16, 18, 20, 28, 29, 43, 38, 39] have investigated the relation between the direction and sizes of trades and price changes and typically conclude that the price impact of trades is an increasing, concave (“square root”) function of their size. This focus on trades leaves out the information in quotes, which provide a more detailed picture of price formation [15], and raises a natural question: is volume of trades truly the best explanatory variable for price movements in markets where many quote events can happen between two trades?

Understanding the price impact of orders is also important from a theoretical perspective, in the context of optimal order execution. Huberman and Stanzl [25] show that there are arbitrage opportunities if the effect of trades on prices is permanent and the impact is non-linear; Gatheral [19] extends this analysis by showing that if the price impact function is non-linear, impact needs to decay in a particular way to exclude arbitrage. Bouchaud et al. [9] associated the decay of price impact of trades with limit orders, arguing that there is a “delicate interplay between two opposite tendencies: strongly correlated market orders that lead to super-diffusion (or persistence), and mean reverting limit orders that lead to sub-diffusion (or anti-persistence)”. This insight implies that looking solely at trades, without including the effect of limit orders amounts to ignoring an important part of the price formation mechanism.

There is ample evidence that limit orders play an important role in determining price dynamics. Arriving limit orders significantly reduce the impact of trades [44] and the concave shape of the price impact function changes depending on the contemporaneous limit order arrivals [41]. The outstanding limit orders (also known as market depth) significantly affect the impact of an individual trade ([30]) and low depth is associated with large price changes [45, 17]. Hasbrouck and Seppi [22] use depth as one of the factors that determine price impact. The emphasis in these studies remains, however, on trades and there are few empirical studies that focus on limit orders from the outset. Notable exceptions are Engle & Lunde [15], Hautsch and Huang [23] who perform an impulse-response analysis of limit and market orders, Hopman [24] who analyzes the impact of different order categories over 30 minute intervals and Bouchaud et al. [12] who examine the impact of market orders, limit orders and cancelations at the level of individual events.

1.1 Summary

We conduct in this study an empirical investigation of the impact of order book events –market orders, limit orders and cancelations– on equity prices. Although previous studies give a relatively complex description of this impact, we argue that, in fact, their impact on price dynamics may be modeled parsimoniously through a single variable, the order flow imbalance (OFI), which represents the net order flow at the bid and ask and tracks changes in the size of the bid and ask queues by

  • increasing every time the bid size increases, the ask size decreases or the bid/ask prices increase
  • decreases every time the bid size decreases, the ask size increases or the bid/ask prices decrease.

Interestingly, this variable treats a market sell and a cancel buy of the same size as equivalent, since they have the same effect on the size of the bid queue. We find that this aggregate variable explains mid-price changes over short time scales in a linear fashion, for a large sample of stocks, with an average R2 of 65%. The resulting price impact model relates prices, trades, limit orders and cancelations in a simple way: it is linear, requires the estimation of a single parameter and it is robust across stocks and across timescales.

The slope of this relation, which we call the price impact coefficient, exhibits intraday seasonality in line with known intraday patterns observed in spreads, market depth and price volatility [1, 4, 31, 34] which have been explained in terms of intraday shifts in information asymmetry [33] or informativeness of trades [21]. Motivated by a stylized model of the order book, we relate the intraday changes in the price impact coefficient to variations in market depth and show that price impact is inversely proportional to the depth of the order book. This allows us to explain intraday patterns in price impact and price volatility using only observable quantities – the order flow imbalance and the market depth, as opposed to unobservable parameters previously invoked in the literature, such as information asymmetry or informativeness of trades.

The intuition that “it takes volume to move prices”, though widely confirmed by empirical studies [27], is not easy to explain theoretically (see [37, Chapter 6.2]). In Section 4, we show that our price impact model, together with a scaling argument, leads to an apparent “square root” relation between price changes and trade volume, similar to some findings in the empirical literature [11, 40]. However, we argue that this relation is not robust and is a statistical artifact due to the aggregation of data.

1.2 Outline

The article is structured as follows. In Section 2, motivated by a stylized model of the order book, we specify a parsimonious model that links stock price changes, order flow imbalance and market depth. Section 3 describes the trades and quotes data and estimation results for our model. There, we also show how intraday patterns in depth and order flow imbalance generate intraday patterns in price impact and price volatility. In Section 4 we discuss the role of trading volume as an explanatory variable and show that order flow imbalance is more effective in explaining price moves than variables based on trades. We also derive a scaling relation between order flow imbalance and traded volume and show how the “square-root” price impact of volume follows from our model. We present our conclusions in Section 5.

2. A model for the price impact of orders

2.1 Variables

We focus on ‘Level I order book’: the limit orders sitting at the best bid and ask. Every observation of the bid and the ask consists of the bid price PB, the size qB of the bid queue (in number of shares), the ask price PA and the size qA of the ask queue (in number of shares):

where Pk is the mid-quote price at time tk and δ is the tick size (equal to 1 cent in our data).

2.2 A stylized model of the order book

Consider first a stylized model of the order book in which

  1. the number of shares at each price level beyond the best bid/ask is equal to D.
  2. limit orders arrivals and cancelations occur only at the best bid/ask.

We will show that under these assumptions a linear relation holds between order flow imbalance and price changes. Consider three scenarios, when only market buy orders, limit buy orders or limit sell cancels happen over some time interval [t,t + ∆t]:

  • Market sell orders remove Ms shares from the bid.
  • Market sell orders remove Ms shares from the bid, while limit buy orders add Lb shares to the bid.
  • Market sell orders and limit buy cancels remove Ms + Cb shares from the bid, while limit buy orders add Lb shares to the bid.

The three variables Mb, Cs and Ls for the ask can be defined analogously. Under the above assumptions, the impact of order book events at the bid (ask) side of the book is additive and only depends on their net effect on the bid (ask) queue size:

Pb = d(Lb Cb Ms)/De

Similarly, for the ask:

Pa = −d(Ls Cs Mb)/De

These relations are remarkably simple – they involve no parameters and incorporate the effects of all order book events on bid and ask prices. Although the following analysis can be carried for the bid and the ask prices separately, we take their average (the mid-price) to simplify the analysis:

2.3  Model specification

In reality, order books have complex dynamics and the relation (1) will only hold in a statistical sense. For example, limit orders and cancelations occur at all levels of the order book. The distribution of depth across price levels often has humps, gaps and is itself a separate object of study [39, 46]. Moreover, the depth is subject to important intraday fluctuations. Finally, there may be hidden orders in the book which are not reported in the data [5]. With these considerations, we suggest the following relation:

where c,λ are constants and νi is a noise term. Note that the stylized model exposed above corresponds to λ = 1.

The specification (2-3) may be regarded as a model of the instantaneous price impact over a short time interval [tk−1,tk]. An order, submitted at τ ∈ [tk−1,tk], has a contribution eτ and joins the aggregate order flow imbalance OFIk. If the order goes in the same direction as the majority of the orders (sgn(eτ) = sgn(OFIk)), it reinforces the concurrent order flow imbalance and can affect the price. If the order goes against the concurrent order flow imbalance (sgn(eτ) = −sgn(OFIk)), it is compensated by other orders and may have an instantaneous impact of zero. In our model all events (including trades) have a linear price impact, equal to β on average. Their realized impact, however, depends on the rest of the orders that arrive during the same time interval.

The idea that the concurrent limit order activity can make a difference in terms of trades’ impact was demonstrated by Stephens et al. [41], where authors show that the shape of the price impact function essentially depends on the contemporaneous limit order activity. Our approach can also be related to the model proposed by Bouchaud et al. [12]. where order book events have a linear impact on prices, which depends on their signs and types[2]. The major difference of our models lies in the aggregation across time and events. As argued in [12], order book events have complicated auto- and cross-correlation structures on the timescale of individual events, which typically vanish after 10 seconds. In our data the autocorrelations at a timescale of 10 seconds are small and quickly vanish as well (ACF plots for a representative stock are shown on Figure 1). Finally, Hasbrouck and Seppi [22] propose a model similar to (2, 3) for explaining the price impact of trades. Although their focus is on trades, they also allow the price impact coefficient to depend on contemporaneous liquidity factors and change through time.

However, the linear equation (2) is quite different from models of price impact that consider only the size of trades [18, 20, 29, 43, 38, 39]. Instead of modeling price impact of trades as a (nonlinear) function of trade size, we show that the price impact of all events (including trades) is a linear function of their size after events are aggregated into a single imbalance variable. In Section 4 we will argue that, first, the effect of trades on prices is adequately captured by the order flow imbalance and, second, that if one leaves out all events except trades, the relation 2 leads to an apparent concave relation between price changes and trade volume.

The next section provides an overview of the estimation results for our model.

Figure 1: ACF of the mid-price changes ∆Pk, the order flow imbalance OFIk and the 5% significance bounds for the Schlumberger stock (SLB).

3. Estimation and results

3.1 The trades and quotes (TAQ) data

Our data set consists of one calendar month (April, 2010) of trades and quotes (TAQ) data for 50 stocks. The stocks were selected by a random number generator from the S&P 500 constituents. The S&P 500 composition for that month was obtained from Compustat and the data for individual stocks was obtained from the TAQ consolidated quotes and TAQ consolidated trades databases. The data were obtained through Wharton Research Data Services (WRDS).

Consolidated quotes contains all changes in queue sizes at the best bid and ask. For each stock, a data update consists of a timestamp (rounded to the nearest second), bid price, bid size, ask price, ask size and exchange flag. Consolidated trades (or market orders) consist of a timestamp, a price and a size. These two data sets are often referred to as Level 1 data, as opposed to Level 2 data, which also includes quote updates deeper in the book.

Our reason for using TAQ data rather than Level 2 order book data, is that it is far more accessible, yet contains all events in the top order book (best bid and ask updates). We demonstrate that Level 1 TAQ data can be successfully used to study limit orders and we hope that more empirical studies of that subject will follow. We note that the ratio of the number of quote updates to the number trades is roughly 40 to 1 in our data. Many empirical studies have focused exclusively on trades rather than quotes, but the sheer ratio in the size of these data sets is a good indicator that more information may be conveyed by the quotes than by trades.

Using a procedure described in detail in the appendix, we aggregate all quote updates to estimate the National Best Bid and Offer sizes and prices (NBBO) at each quote update. Instead of aggregating all exchanges in this fashion, one may also simply filter by the exchange flag and study one exchange at the time. Focussing on one exchange at a time yields similar results.

We use a uniform grid in time {t0,…,tN} with a timescale tk tk−1 ≡ ∆t = 10 seconds to compute the price changes and the order flow imbalances. To test the robustness of our findings to the choice of the basic timescale, we repeated our calculations on a subsample of stocks for different values of ∆t, ranging from 10 quote updates (usually less than half of a second in our data) up to 10 minutes. The fit of our model generally increases with ∆t, but the rest of the results stays the same. Time aggregation serves two purposes: first, it alleviates the issue of data discreteness and second, it mitigates the errors due to the trade matching algorithm (described in the Appendix).

3.2  Empirical findings

We assume that the price impact coefficient β is constant over each half-hour interval [Ti,Ti+1] and estimate the model by ordinary least squares regression in each half-hour subsample for each stock:

                                                                  

Figure 2 presents a scatter plot of ∆Pk against OFIk for one of the half-hour subsamples. Table 2 reports regression outputs, averaged across time for each stock. This table provides strong evidence of a linear relation between order flow imbalance and price changes. The goodness of fit is surprisingly high for all of the stocks, suggesting that the model (2) performs well regardless of stock-specific features[3]. In addition to the high quality of fits, the regression coefficient βi is virtually always statistically significant (at a 95% level of the z-test), while the intercept is mostly insignificant. Figure 3 represents the histogram of excess kurtosis values of the residuals ˆk across subsamples: the relatively low level of kurtosis shows that the residuals are not predominantly associated with large price changes. Since the regression residuals demonstrate heteroscedasticity, we used White’s heteroscedasticity-consistent standard errors for the z-test. To check for higher order/nonlinear dependence we add a quadratic term ˆγQ,iOFIk|OFIk| to the regression. The increase in R2, from 65% to 68% on average, is barely noticeable and the coefficient ˆγQ,i is statistically insignificant in most samples.

Figure 2: Scatter plot of ∆Pk against OFIk for the Schlumberger stock (SLB), 04/01/2010 11:30-12:00pm.

Figure 3: Distribution of excess kurtosis of the residuals ˆk across stocks and time.

Table 1. Descriptive statistics

NameTickerPriceDaily volume,Number of best quoteNumber of tradesAverage Spread,Maximum spread,Best quote depth,
   sharesupdates centscentsshares
Advanced Micro DevicesAMD9.61208729964172046687111035
Apollo GroupAPOL62.92194933717294240952515
American ExpressAXP45.218678723559701774812479
AutozoneAZO179.032431974368210819357
Bank of AmericaBAC18.43164550168152939515008113208
Becton DickinsonBDX78.0711303626102929682515
Bank of New York MellonBK31.776310701285619551811122
Boston ScientificBSX7.13257467873094416768112965
Peabody Energy corpBTU47.14521064229861672671329
CaterpillarCAT67.20666489139249982241238
ChubbCB52.22195161814901036011243
CarnivalCCL40.16427591121542755031253
Cincinnati FinancialCINF29.416889145137315281242
CME GroupCME322.83418955385041412311035
CoachCOH41.91312646917679544581241
ConocoPhillipsCOP56.09964454442661486211284
Coventry Health CareCVH24.1611570227930522131238
Denbury ResourcesDNR17.885737740263173464311186
Devon EnergyDVN66.98326098217700658052418
EquifaxEFX35.347995056295719451339
EatonETN78.5317571366798935802613
FiservFISV52.5610383115830422081320
HasbroHAS39.4813220378604026721234
HCPHCP32.63287252121304543571248
Starwood HotelsHOT50.59316480715025251062422
Kohl’sKSS56.88306482112819649361327
L-3 CommunicationsLLL94.64670937728182141269
Lockheed MartinLMT84.1414160728825433332515
Macy’sM23.408324639491756646911176
MarriottMAR34.45501409823819054991265
McAfeeMFE40.04246932410907335611240
McGraw-HillMHP34.90195457610238932611242
Medco Health SolutionsMHS63.22279809810938246801325
MerckMRK36.0313930842448748799711231
Marathon OilMRO32.335035354341408552211143
MeadWestvacoMWV26.9610355479282523121337
Newmont MiningNEM53.43567371843529577171238
OmnicomOMC41.17335758515080043591265
MetroPCS CommunicationsPCS7.534424560107967290111523
PultegroupPHM11.806834683262420460411319
PerkinElmerPKI23.9812687747811421271272
Ryder SystemR44.016318894742220852511
Reynolds AmericanRAI54.447733875623620761422
SchlumbergerSLB67.949476060440839102861239
Teco EnergyTE16.52107081570318180711148
Time Warner CableTWC53.2117702348828635542322
WhirlpoolWHR97.73142426413415233484910
WindstreamWIN11.032508830104887293711798
Watson PharmaceuticalsWPI42.518959676309420241329
XTO EnergyXTO48.137219436612804504017225
Grand mean 51.757512376223232455226227

Table 1 presents the average mid-price, daily transaction volume, daily number of best quote updates, daily number of trades, spread and the depth at the best bid and ask for 50 randomly chosen U.S. stocks. All values are calculated from the filtered data, that consists of 21 trading day during April, 2010.

Table 2. Relation between price changes and order flow imbalance.

TickerAverage resultsHypothesis testing
αˆt(αˆ)βˆt(βˆ)γˆQt(γˆQ)R2{α 6= 0}{β 6= 0}{γQ 6= 0}
AMD-0.0032-0.170.00089.961.4E-070.6864%0%98%22%
APOL0.00380.100.055510.32-2.2E-04-1.1763%12%91%4%
AXP0.00190.080.008213.87-3.8E-06-0.8869%11%100%5%
AZO0.01010.330.16196.39-9.3E-04-0.8947%23%97%3%
BAC-0.0018-0.090.000218.361.9E-090.0179%1%100%8%
BDX-0.0008-0.060.053610.08-1.1E-04-0.3863%9%100%8%
BK-0.0078-0.190.006914.97-4.0E-06-0.5774%3%100%6%
BSX0.0000-0.010.00036.127.8E-081.1458%0%81%22%
BTU0.00480.120.024214.51-3.5E-05-1.2672%11%100%3%
CAT0.01470.230.019414.85-1.9E-05-1.1371%12%99%3%
CB-0.0086-0.070.019111.97-3.5E-070.0064%5%100%8%
CCL-0.0067-0.180.014013.88-1.2E-05-0.6470%3%99%7%
CINF-0.0030-0.020.026010.73-7.0E-060.2770%1%98%16%
CME0.05060.050.62624.98-7.2E-03-0.9935%15%94%2%
COH-0.0221-0.450.017912.75-1.7E-05-0.7769%2%100%3%
COP-0.00080.060.008412.50-5.8E-06-1.1768%10%100%3%
CVH-0.0034-0.060.021710.837.6E-060.2065%3%99%10%
DNR-0.0008-0.040.004512.76-1.3E-070.1969%1%99%13%
DVN0.01120.180.037011.48-1.0E-04-1.5965%17%97%0%
EFX-0.0032-0.040.02228.716.4E-050.6456%1%98%18%
ETN-0.00760.050.071210.51-2.3E-04-1.1465%14%98%1%
FISV-0.00020.060.039710.42-2.3E-05-0.1963%4%100%8%
HAS-0.0031-0.020.022211.454.7E-060.2167%3%100%16%
HCP-0.0078-0.170.015013.60-1.4E-05-0.4667%2%100%6%
HOT-0.00120.050.034512.64-7.2E-05-1.2168%10%99%2%
KSS-0.0030-0.040.031713.82-5.4E-05-0.8071%10%98%3%
LLL0.01600.320.100011.76-3.8E-04-0.7567%14%96%3%
LMT0.00060.000.052013.58-1.2E-04-0.9872%14%100%1%
M-0.00100.040.004315.828.8E-080.1375%0%100%12%
MAR-0.0039-0.020.012114.61-4.1E-06-0.2371%3%100%4%
MFE0.00870.160.020512.72-3.8E-05-0.3868%7%100%7%
MHP-0.0073-0.130.021111.625.8E-060.1468%2%99%11%
MHS-0.0055-0.160.033411.70-8.3E-05-1.1066%9%99%3%
MRK-0.0065-0.200.003212.53-5.4E-07-0.3869%1%100%8%
MRO0.00180.070.005813.67-3.6E-070.2269%5%100%13%
MWV-0.00110.010.020511.79-1.7E-05-0.2568%3%100%7%
NEM-0.0102-0.220.017013.81-1.9E-05-1.3671%8%100%2%
OMC-0.0099-0.280.014411.88-4.5E-06-0.0165%2%99%13%
PCS-0.0006-0.030.00155.211.8E-061.0153%0%79%24%
PHM0.00060.030.002710.338.4E-070.5566%1%98%21%
PKI-0.0004-0.030.01027.254.1E-051.1053%2%94%29%
R0.00060.030.066710.143.7E-050.0163%8%98%10%
RAI-0.0070-0.100.039610.402.6E-050.0166%5%100%11%
SLB-0.0077-0.150.019816.76-1.8E-05-1.1576%7%100%1%
TE0.00110.050.00496.661.4E-051.4554%2%86%30%
TWC-0.0130-0.130.038411.80-5.6E-05-0.4464%8%99%5%
WHR0.06280.630.127810.26-3.3E-04-0.8065%22%97%4%
WIN-0.0004-0.030.00093.121.5E-060.7644%1%60%15%
WPI-0.0090-0.210.027010.472.9E-050.2866%3%98%14%
XTO-0.0088-0.180.002913.282.7E-070.3065%0%100%18%
Average0.0002-0.020.039811.47-2.0E-04-0.2865%6%97%9%

Table 2 presents a cross-section of results (averaged across time) for the regressions:

where ∆Pk are the 10-second mid-price changes and OFIk are the contemporaneous order flow imbalances. These regressions were estimated using 273 half-hour subsamples (indexed by i) for each stock and their outputs were averaged across subsamples. Each subsample typically contains about 180 observations (indexed by k). The t-statistics were computed using White’s standard errors. For brevity, we report the R2, the average ˆαi and the average βˆi only for the first regression (with a single OFIk term). There is almost no difference between averages of estimates βˆi and βˆQi and the R2 in two regressions. The last three columns report the percentage of samples where the coefficient(s) passed the z-test at the 5%

significance level.

Both regressions are estimated using ordinary least squares. The results are presented in Table 3: the quality of these fits convincingly demonstrates that the instantaneous price impact (measured by βˆi) is inversely related to market depth. There are three stocks with bad fits (namely APOL, AZO and CME) and we note that they also have wide spreads and low values of depth. It is possible that for these stocks other factors, such as the presence of hidden orders and depth beyond the best price levels the order book may dominate the instantaneous price impact. The intercept αˆL,i is highly statistically significant (being an estimate of parameter c) and αM,iˆ , which is included to absorb the means, is mostly insignificant. Since the residuals of these regressions appear to be autocorrelated, the t-statistics and confidence intervals in Table 3 are computed with Newey-West standard errors. Coinciding with our intuition for (1), estimates λˆ are very close to 1 across stocks and the hypothesis {λ = 1} cannot be rejected for 35 out of 50 stocks. The restricted model (with λ = 1) also demonstrates a good quality of fit, making this a good approximation. However, the coefficient ˆc is generally different fromShape

Description automatically generated with medium confidence in (1). Lower values of ˆc mean that mid-prices are (on average) more resilient to the incoming orders than indicated by ADi (which is only a rough measure of market depth). In summary, λ = 1 appears to be a good approximation for most of the stocks and only the constant c needs to be calibrated to the data. The general case of regression (5) is illustrated on Figure 4 by a scatter plot for a representative stock.

Figure 4: Log-log scatter plot of the price impact coefficient estimate βˆi against average market depth ADi for the Schlumberger stock (SLB).

Table 3. Relation between the price impact coefficient and market depth.

TickerParameter estimates5% confidence intervals Fit measures
cˆλˆt(cˆ)t(λˆ)cˆlcˆuλˆlλˆuR2corr[β,ˆ βˆˆ]2corr[β,ˆ βˆˆ∗]2
AMD0.230.9427.7423.110.220.250.861.0278%86%86%
APOL0.270.364.431.050.150.39-0.321.042%30%31%
AXP0.140.8313.9526.480.120.160.770.8984%76%76%
AZO0.390.675.485.100.250.530.410.9213%17%16%
BAC0.270.9625.2719.740.250.290.901.0376%87%87%
BDX0.381.0422.8318.640.350.410.931.1571%68%68%
BK0.210.9217.5254.540.190.240.880.9593%91%90%
BSX0.350.9814.9824.550.310.400.901.0573%81%81%
BTU0.421.1240.9036.770.400.441.061.1887%83%83%
CAT0.290.9621.7016.870.270.320.851.0787%83%83%
CB0.321.0227.0849.610.300.340.981.0692%89%89%
CCL0.260.9624.3637.550.240.290.911.0187%83%83%
CINF0.310.9720.0547.390.280.340.931.0192%88%88%
CME1.270.502.551.990.292.240.010.992%4%3%
COH0.371.0515.2936.650.320.430.981.1277%75%75%
COP0.130.808.5215.950.100.160.700.8975%66%66%
CVH0.321.0326.5037.510.290.340.981.0889%89%89%
DNR0.230.9632.4440.900.220.240.921.0191%89%89%
DVN0.260.9113.5016.660.220.300.801.0245%56%56%
EFX0.300.9920.1626.130.270.330.921.0784%79%79%
ETN0.451.0711.5117.340.380.530.951.1960%56%56%
FISV0.341.0123.3530.700.310.360.941.0784%77%77%
HAS0.321.0026.3646.000.300.340.961.0589%83%83%
HCP0.190.8922.9351.270.170.210.860.9394%90%90%
HOT0.441.1219.5326.590.400.481.041.2082%80%79%
KSS0.391.0524.4033.170.360.420.991.1185%78%78%
LLL0.431.0113.2114.450.370.500.871.1451%58%58%
LMT0.501.147.3113.490.370.640.981.3160%52%52%
M0.190.9037.4157.390.180.200.870.9394%92%92%
MAR0.280.9822.5850.200.250.300.941.0292%88%88%
MFE0.311.0120.2846.200.280.340.961.0591%86%86%
MHP0.270.9419.6033.620.240.300.891.0082%74%74%
MHS0.531.1617.0334.250.470.591.101.2385%81%80%
MRK0.130.8118.0732.200.110.140.760.8687%81%81%
MRO0.230.9435.5449.680.210.240.910.9894%93%93%
MWV0.321.0528.0737.810.300.341.001.1090%85%85%
NEM0.260.9818.7925.970.230.280.911.0581%77%77%
OMC0.300.9629.4717.760.280.320.851.0683%85%85%
PCS0.301.0221.2718.730.270.330.901.1453%82%82%
PHM0.280.9836.4335.120.260.290.931.0486%90%90%
PKI0.301.0726.5938.350.280.321.001.1382%88%87%
R0.371.0218.5115.760.330.410.901.1557%58%58%
RAI0.351.0324.9440.460.320.380.981.0886%76%76%
SLB0.351.0618.9840.600.310.381.011.1291%88%88%
TE0.211.0016.1824.280.180.240.921.0970%86%86%
TWC0.371.0417.7015.960.330.420.911.1672%79%79%
WHR0.781.189.2411.540.610.940.981.3844%43%42%
WIN5.811.6016.0911.705.116.521.331.8728%71%71%
WPI0.270.9219.3328.990.240.300.860.9878%76%76%
XTO0.311.0430.8539.510.290.330.981.0989%91%91%
Grand mean0.450.9820.7429.530.380.520.881.0874%75%75%

Table 3 presents the results of regressions:

,

      Shape

Description automatically generated with medium confidence          ,

i

where βˆi is the price impact coefficient for the i-th half-hour subsample and ADi is the average market depth for that subsample. These regressions were estimated for each of the 50 stocks, using 273 estimates of βˆi for that stock, obtained from (4). The second regression uses estimates λˆ obtained from the first regression. The t-statistics and the confidence intervals were computed using Newey-West standard errors. Confidence intervals are built with normal critical values. The last three columns provide three alternative fit measures – the R2 of the linear regression (5), the squared correlation

3.3   Intraday patterns

The link that we established between the price impact and the market depth has an important implication. Since the market depth follows a predictable pattern of intraday seasonality ([1], [31]), the price impact coefficient must also have a predictable intraday pattern. To demonstrate it, we averaged βˆi for each stock and each half-hour interval across days, resulting in the intraday seasonality pattern for that stock, normalized these values by the average βˆi of that stock and averaged the normalized seasonality patterns across stocks. The same procedure was repeated for ADi and the results are shown on Figure 5.

Figure 5: Intraday patterns in the price impact coefficient βˆi and the average depth ADi.

Near the market open, depth is two times lower than it is on average, indicating that the order book is relatively shallow. In a shallow market, the incoming orders can easily affect the mid-price and the price impact coefficient is two times higher near the market open than on average. Moreover, price impact is five times higher at the market open compared to the market close.

The intraday pattern in price impact can be used to explain the intraday patterns in price volatility, observed by many researchers ([1], [4], [21], [33]). Similarly to the price impact coefficient and the market depth, we computed the intraday patterns in variances of ∆Pk and OFIk, using half-hour subsamples (indexed by i). Taking the variance on both sides of equation (2) demonstrates the link between var[∆Pk]i, var[OFIk]i and βi:

                                                           (7)

The average patterns are plotted on Figure 6. Notice that the price volatility has a sharp peak near the market open, while the volatility of order flow imbalance has a peak near the market close. This peak is, however, offset by a low price impact, which gradually declines throughout the day. For the i-th half-hour interval, the equation (7) implies that var[∆Pk]i βˆi2var[OFIk]i which is demonstrated on Figure 6[4].

Figure 6: Intraday seasonality in variances var[∆Pk]i, var[OFIk]i, the price impact coefficient βˆi and the expression βi2var[OFIk]i.

The intraday pattern in price variance was explained by Madhavan et al. [33] in terms of a structural model. They argued that the volatility is higher in the morning because of the higher inflow of both public and private information. Similarly, Hasbrouck [21] argued that the peak of price volatility at market open is mostly due to higher intensity of public information. Both studies agree that the impact of trades is larger in the morning. Our model contributes to this discussion by explaining the peak of price volatility using tangible quantities, rather than unobservable parameters. We also argue that the price impact of trades and the information asymmetry may be, in fact, two sides of the same coin.

First, we associate the higher volatility of order flow imbalance at market the open and close with a higher rate of trading, that is, higher inflow of public and private information. Second, if the bid-ask spread is small (it is mostly equal to 1 cent in our data), limit order traders may avoid being “picked off” only by lowering the number of submitted orders, reducing the depth. Therefore, if limit order traders are aware of information asymmetry in the morning, the low depth may simply indicate this asymmetry. In our model, low depth also implies a higher price impact, making the information advantages harder to realize at the market open.

4. Price impact of trades

4.1 Trade imbalance vs order flow imbalance

The previous section discussed the linear relation between price changes and OFIk – our measure of supply/demand imbalance. However, little has been said about trade imbalances, which are widely used in the academic literature [10, 20, 22, 24, 29, 38] and in practice [43]. The aim of this section is to compare the price impact of trades and order flow imbalance and show that the (nonlinear) price impact of trade volume may be derived from our linear model for the price impact of order flow.

For convenience we will call ‘buy trade’ a transaction initiated by a market buy order and ‘sell trade’ a transaction initiated by a market sell order. We define the trade imbalance during a time interval [tk−1,tk] as the difference between volumes of buy and sell trades during that interval:

                                                                           N(tk)                               N(tk)

TIk = X bn − X sn,

                                                                      n=N(tk1)+1                   n=N(tk1)+1

Here, bn is the size of a buyer-initiated trade that occurs at the n-th quote; bn = 0 if no buy trade occurs at that quote. Similarly, sn is the size of a sell trade that occurs at the n-th quote or zero. The procedure that matches trades with quotes and classifies them as buys or sells is described in the Appendix.

To compare the explanatory power of trade and order flow imbalances with respect to price changes, we perform the following regressions

The regressions are estimated separately for every half-hour subsample of data (indexed by i). If the effect of trades is included in the order flow imbalance, the coefficients θˆT,i in (8c) must be indistinguishable from zero. We note that regressions (8a-8c) contain only the linear terms, because we found no evidence of non-linear price impacts in our data (for neither OFIk nor TIk). The average results of these regressions are presented in Panel A of Table 4. Clearly, when OFIk and TIk are taken individually, each of them has a statistically significant influence on price changes. Comparing the two we observe that OFIk explains price changes better than TIk – the average R2 for order flow imbalance is 65% compared to 32% for the trade imbalance. When two variables are used together to explain price changes, the dependence on trade imbalance becomes questionable. The average t-statistic of TIk decreases by a factor of four and the coefficients θˆT,i are statistically significant in only 31% of subsamples. However, the dependence on OFIk remains convincingly strong. Our findings show that:

  1. The order flow imbalance OFIk explains price movements better than the imbalance of trades.
  2. The effect of trade imbalance is adequately included in OFIk, a more general measure of supply/demand imbalance.

Table 4. Comparison of order flow imbalance and trade imbalance.

Panel A: Detailed results for changes in mid prices   
TickerOrder flow imbalance Trade imbalance  Both covariates  
R2t(βˆ){β 6= 0}FR2t(βˆT){βT 6= 0}FR2    
 64%9.9698%38239%4.1586%14067%6.491.2693%34%214
 63%10.3291%39630%4.1484%8366%8.001.0989%26%211
 69%13.87100%44934%4.7283%10171%10.051.50100%44%241
 47%6.3997%17930%4.0990%8754%5.022.3496%68%118
 79%18.36100%77445%6.3196%15780%12.550.7299%19%397
 63%10.08100%36228%4.0282%7965%7.881.2397%34%195
 74%14.97100%61036%4.5881%11775%10.680.6899%17%313
 58%6.1281%33831%2.5754%10662%4.510.5773%12%189
 72%14.51100%52735%5.2188%10374%10.901.3199%32%277
 71%14.8599%49833%5.0186%9472%11.271.2899%38%262
 64%11.97100%37833%4.6688%10266%8.421.3499%37%202
 70%13.8899%47832%4.5585%9371%10.500.9899%26%247
 70%10.7398%55239%4.2687%14172%7.171.0196%27%297
 35%4.9894%11224%3.3975%6344%4.102.1892%59%78
 69%12.75100%45729%3.9182%8070%10.060.87100%22%238
 68%12.50100%45035%4.9284%10770%9.191.42100%40%240
 65%10.8399%41835%4.1084%11467%7.301.0197%25%222
 69%12.7699%47132%3.9881%10170%9.291.0197%24%246
 65%11.4897%41433%4.8388%9668%8.581.7093%48%226
 56%8.7198%28931%3.7280%10160%6.211.6496%43%167
 65%10.5198%38925%3.5971%6967%8.661.0498%29%209
 63%10.42100%38028%3.7981%7965%8.120.88100%25%201
 67%11.45100%42732%4.0484%9768%8.530.89100%24%223
 67%13.60100%41731%4.4382%9168%10.011.05100%32%217
 68%12.6499%43827%3.86Shape

Description automatically generated with medium confidence77%7470%9.941.1799%29%231
 71%13.8298%52531%4.4381%9172%10.830.9497%25%274
 67%11.7696%48536%5.0790%11770%8.581.6394%44%270
 72%13.58100%51635%4.8990%10573%10.191.5099%40%277
 75%15.82100%64035%4.4184%10876%11.380.97100%26%330
 71%14.61100%49834%4.7789%10572%10.451.05100%27%258
 68%12.72100%46331%4.1782%9369%9.060.7399%18%239
 68%11.6299%48931%3.8584%9670%8.920.7798%19%257
 66%11.7099%41428%4.0377%8068%9.101.1199%27%218
 69%12.53100%45131%4.0882%9370%9.200.76100%20%235
 69%13.67100%46535%4.6689%10470%9.730.91100%24%241
 68%11.79100%45234%4.3786%10269%8.630.80100%24%237
 71%13.81100%49034%4.9981%10072%10.241.5399%43%260
 65%11.8899%41130%4.1485%8867%8.990.9699%24%216
 53%5.2179%29735%2.6859%16958%3.440.8671%20%195
 66%10.3398%41635%3.8784%11568%7.280.9593%29%224
 53%7.2594%26328%3.0370%8957%5.391.2488%32%148
 63%10.1498%35227%3.9286%7165%8.071.2097%30%188
 66%10.40100%42236%4.6789%11168%7.521.1199%31%224
 76%16.76100%64432%4.5479%9477%13.021.24100%36%336
 54%6.6686%30137%3.2767%17560%4.341.3279%29%200
 64%11.8099%37731%4.2677%9366%8.461.3499%37%201
 65%10.2697%39429%4.2988%8567%8.171.4396%39%217
 44%3.1260%24341%2.6854%24958%1.781.3942%29%206
 66%10.4798%43732%3.9183%10068%7.821.0597%30%232
 65%13.28100%39921%3.0563%5466%10.721.05100%27%209
Grand mean65%11.4797%42932%4.1881%10367%8.491.1695%31%231
  Panel B: Averageresults for changes in transactionprices    
L = 2 trades14%15.74     98%        4641%2.6963%2615%14.17-2.5898%54%245
L = 5 trades38%19.42     98%        7538%4.5075%11339%16.85-0.2098%9%379
L = 10 trades51%17.78     98%        65513%4.5575%10051%14.970.5798%9%329

Table 4 presents the average results of regressions:

where ∆Pk are the 10-second mid-price changes (Panel A) or changes in trade prices between L trades (Panel B), OFIk are the contemporaneous order flow imbalances and TIk are the contemporaneous trade imbalances. For Panel A, these regressions were estimated using 273 half-hour subsamples (indexed by i) for each stock and their outputs were averaged across subsamples. Each subsample typically contains about 180 observations (indexed by k). For Panel B, data was pooled across half-hour subsamples, resulting in 13 subsamples for each stock.

The t-statistics were computed using White’s standard errors. For each of three regressions, Table 4 reports the average R2, the average tstatistic of the coefficient(s), the percentage of samples where the coefficient(s) passed the z-test at the 5% significance level and the F-statistic of the regression. The outputs for Panel B were averaged across stocks.

17

Interestingly, we found that the relation between ∆LPkt and OFIk is concave in some samples, and similarly for ∆LPkt and TIk. We estimated regressions (8a) and (8b) for transaction price changes with additional quadratic terms OFIk|OFIk| (respectively, TIk|TIk|) and found that they are significant in nearly half of the samples with t-statistics of -2.8 on average (-2.3 for TIk|TIk|). Sampling data at special times (trade times) may introduce biases to the right side of the regression. One possible explanation is that traders submit their orders when they expect their impact to be minimal, leading to a concave (sublinear) impact. Supporting this idea of sampling biases, we found that when mid-prices are sampled at trade times, the price impact of OFIk is again concave in some samples. On another hand, when we regressed last trade prices sampled at 1-minute frequency on OFIk, we observed the concave price impact once again. This suggests that using either trade times or trade prices may lead to non-linear price impact. However the quadratic term in our regressions is insignificant in about half of the samples and marginally significant in the the other half of the data.

The relation between price changes and volume is empirically confirmed by many authors (see [27] for a review). Recently, traded volume became an important metric for order execution algorithms – these algorithms often attempt to match a certain percentage of the total traded volume to reduce the price impact. However, it remains unclear whether the traded volume truly determines the magnitude of price moves and whether it is a good metric for price impact. Casting doubt on this assertion, Jones et al. [26] showed that the relation between the daily volatility and the daily volume is essentially due to the number of trades and not the volume per se (also see [?] for the discussion).

We extend this result in two ways. First, we show that even when prices are driven by order flow imbalance, an apparent (concave) dependence on traded volume may emerge as an artifact due to data aggregation. Second, we empirically confirm that the price-volume relation is an indirect one – it becomes statistically insignificant after accounting for the order flow imbalance.

5. Conclusion

We have introduced order flow imbalance, a variable that cumulates the sizes of order book events, treating the contributions of market, limit and cancel orders equally, and provided empirical and theoretical evidence for a linear relation between high-frequency price changes and order flow imbalance for individual stocks. We have shown that this linear model is robust across stocks and the impact coefficient is inversely proportional to market depth. These relations suggest that prices respond to changes in the supply and demand for shares at the best quotes, and that the impact coefficient fluctuates with the amount of liquidity provision, or depth, in the market. Moreover, we have demonstrated that order flow imbalance is a stronger driver of high-frequency price changes than standard measures of trade imbalance. Trades seem to carry little to no information about price changes after the simultaneous order flow imbalance is taken into account. If trades do not help to explain price changes after controlling for the order flow imbalance, it is highly possible that the relation between price changes and traded volume simply capture the noisy scaling relation between these variables.

Overall, these findings seem to give an intuitive picture of the price impact of order book events, which is somewhat simpler than the one conveyed by previous studies.

Table 5. Comparison of traded volume and order flow imbalance.

TickerAvg HˆStdev HˆOrder flow imbalance  Traded volume   Both covariates  
R2t(βˆO)βO 6= 0FR2t(βˆV )βV 6= 0FR2t(φˆO)t(φˆV )φO 6= 0φV 6= 0F
AMD0.060.0863%10.399%35614%4.583%3463%9.41.199%35%182
APOL0.240.0853%8.390%25825%6.899%6357%6.92.989%84%144
AXP0.160.0855%10.5100%24920%6.6100%4857%9.02.8100%81%133
AZO0.430.2239%5.596%13132%5.3100%9350%4.33.694%96%98
BAC0.090.0873%16.3100%56024%5.683%6174%13.91.296%35%285
BDX0.260.1055%8.499%26127%6.3100%7158%6.72.998%84%147
BK0.110.0768%13.1100%43719%6.697%4668%11.52.099%58%225
BSX-0.172.4168%8.4100%48614%3.395%3369%8.00.197%12%246
BTU0.240.0758%10.599%28323%6.899%5760%8.92.499%78%151
CAT0.220.0756%10.498%25019%6.098%4457%8.92.198%63%131
CB0.190.0956%10.199%26123%6.499%5858%8.22.699%74%141
CCL0.140.0760%11.3100%30919%6.699%4562%9.92.499%74%162
CINF0.130.1267%10.699%50530%6.198%8569%8.72.099%55%268
CME0.490.2428%4.194%7830%4.899%8342%3.23.686%94%71
COH0.190.0760%10.499%29922%6.599%5261%8.92.298%69%157
COP0.160.0756%9.8100%27720%6.096%4958%8.42.4100%70%145
CVH0.180.1062%10.2100%35227%5.999%7264%8.22.2100%70%189
DNR0.080.0764%12.099%37617%6.395%3865%10.71.899%55%193
DVN0.260.0752%8.693%23624%6.7100%5955%7.12.991%81%131
EFX0.200.1152%8.199%24126%5.499%6956%6.42.797%75%137
ETN0.260.1055%8.297%25227%6.499%7058%6.82.996%83%142
FISV0.190.1157%9.1100%28425%5.9100%6559%7.32.299%66%153
HAS0.200.0961%10.1100%32826%6.2100%6763%8.22.3100%73%175
HCP0.140.0757%11.1100%26821%7.099%5059%9.32.7100%79%143
HOT0.230.0857%9.798%26324%6.9100%6060%8.23.098%85%145
KSS0.240.0860%10.897%31825%6.699%6162%9.02.497%74%169
LLL0.330.1258%9.494%32334%6.9100%10163%7.13.091%86%188
LMT0.280.0961%10.799%32731%7.3100%8564%8.42.999%84%182
M0.110.0769%13.9100%46320%6.399%4669%12.22.0100%60%238
MAR0.150.0761%12.3100%32421%6.999%5062%10.42.4100%71%170
MFE0.160.0960%10.999%31824%7.198%6262%8.82.599%71%170
MHP0.200.1062%10.299%37725%5.999%6264%8.51.999%55%199
MHS0.230.0856%9.299%25824%6.6100%5858%7.72.698%77%139
MRK0.100.0762%11.0100%33017%5.499%4063%9.81.8100%55%170
MRO0.090.0661%11.8100%33316%6.395%3663%10.62.0100%54%172
MWV0.180.1062%10.3100%33028%6.7100%7564%8.22.4100%74%180
NEM0.200.0756%9.999%25320%6.199%4758%8.62.599%75%135
OMC0.150.0957%10.199%28620%6.498%4859%8.62.498%73%151
PCS0.110.1862%7.196%41118%3.797%5463%6.50.793%20%214
PHM0.070.0864%10.2100%38415%5.590%3465%9.41.299%40%195
PKI0.110.1155%7.899%26620%4.897%4757%6.71.898%53%141
R0.270.1156%8.698%25928%6.0100%7459%6.92.997%85%147
RAI0.250.1061%9.299%33428%5.7100%7363%7.62.499%71%182
SLB0.240.0762%12.099%33019%5.598%4663%10.61.799%51%171
TE0.091.6960%8.098%37118%4.485%4861%7.21.398%39%196
TWC0.250.1055%9.799%25327%6.6100%7358%7.63.099%81%142
WHR0.340.1156%8.297%27229%6.3100%7859%6.62.995%86%156
WIN0.060.2648%3.979%34010%2.850%3449%3.70.679%29%179
WPI0.220.1061%9.698%36128%5.8100%7564%7.72.298%71%196
XTO0.080.0653%10.9100%23815%6.5100%3255%9.62.7100%78%125
Grand mean0.180.1858%9.898%31323%6.097%5861%8.32.397%67%168

Table 5 presents the average results of regressions:

,

, ,

where ∆Pk are the 10-second mid-price changes, OFIk are the contemporaneous order flow imbalances and V OLk are the contemporaneous trade volumes. The exponents Hˆi were estimated in each subsample beforehand using a logarithmic regression: log|∆Pk| = logθˆ¯i + Hˆi logV OLk + logξˆk. These regressions were estimated using 273 half-hour subsamples (indexed by i) for each stock and their outputs were averaged across subsamples. Each subsample typically contains about 180 observations (indexed by k). The t-statistics were computed using White’s standard errors. For each of three regressions, Table 5 reports the average R2, the average t-statistic of the coefficient(s), the percentage of samples where the coefficient(s) passed the z-sest at the 5% significance level and the F-statistic of the regression.

SOLUTION:

{

  “cells”: [

    {

      “cell_type”: “markdown”,

      “source”: [

        “<h1 style=\”color:purple\”>Author</h1>\n”,

        “\n”,

        ”  \n”,

        “- Name:                      \n”,

        “- Student ID: \n”

      ],

      “metadata”: {

        “id”: “jgavCdIkFqci”

      }

    },

    {

      “cell_type”: “markdown”,

      “source”: [

        “## Introduction”

      ],

      “metadata”: {

        “id”: “9_lbTOJHFvti”

      }

    },

    {

      “cell_type”: “markdown”,

      “source”: [

        “Many studies have been conducted to describe the relationship between the trade activity(volume) and the price change. Ask (Sell) and Bid (Buy) orders on the order book might signal the direction of market movement. To  model the possible pattern between the order imbalance (between ask and bid sides) and price change, we will build new predictors and check the performance of multiple linear regression in paper trading (backtesting with historical data). \n”,

        “\n”

      ],

      “metadata”: {

        “id”: “zxpfm7a9Ft78”

      }

    },

    {

      “cell_type”: “markdown”,

      “source”: [

        “## Data”

      ],

      “metadata”: {

        “id”: “w1lbOpn_FzaX”

      }

    },

    {

      “cell_type”: “code”,

      “execution_count”: 1,

      “metadata”: {

        “id”: “Tjr4Fzs5FhHI”

      },

      “outputs”: [],

      “source”: [

        “import pandas as pd\n”,

        “import numpy as np\n”,

        “import os, math, pathlib\n”,

        “from os import listdir\n”,

        “from multiprocessing import Process\n”,

        “import warnings\n”,

        “warnings.filterwarnings(‘ignore’)”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 2,

      “metadata”: {

        “id”: “4apEYH9BFhHL”

      },

      “outputs”: [],

      “source”: [

        “df=pd.read_csv(‘/content/Data.csv’)”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 3,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”,

          “height”: 206

        },

        “id”: “Mszj398SFhHL”,

        “outputId”: “793f5c92-3e01-47e3-f40a-93d93c974040”

      },

      “outputs”: [

        {

          “output_type”: “execute_result”,

          “data”: {

            “text/plain”: [

              ”                Unnamed: 0  AskPrice  BidPrice  AskVolume  BidVolume\n”,

              “0  2020-12-21 09:00:00.500    4445.0    4419.0      467.0       87.0\n”,

              “1  2020-12-21 09:00:00.500    4445.0    4419.0      467.0       87.0\n”,

              “2  2020-12-21 09:00:00.500    4445.0    4419.0      467.0       87.0\n”,

              “3  2020-12-21 09:00:00.500    4445.0    4419.0      467.0       87.0\n”,

              “4  2020-12-21 09:00:00.500    4445.0    4419.0      467.0       87.0”

            ],

            “text/html”: [

              “\n”,

              ”  <div id=\”df-0e5ae9fa-2a73-45a5-9a3d-722fbe8b47df\”>\n”,

              ”    <div class=\”colab-df-container\”>\n”,

              ”      <div>\n”,

              “<style scoped>\n”,

              ”    .dataframe tbody tr th:only-of-type {\n”,

              ”        vertical-align: middle;\n”,

              ”    }\n”,

              “\n”,

              ”    .dataframe tbody tr th {\n”,

              ”        vertical-align: top;\n”,

              ”    }\n”,

              “\n”,

              ”    .dataframe thead th {\n”,

              ”        text-align: right;\n”,

              ”    }\n”,

              “</style>\n”,

              “<table border=\”1\” class=\”dataframe\”>\n”,

              ”  <thead>\n”,

              ”    <tr style=\”text-align: right;\”>\n”,

              ”      <th></th>\n”,

              ”      <th>Unnamed: 0</th>\n”,

              ”      <th>AskPrice</th>\n”,

              ”      <th>BidPrice</th>\n”,

              ”      <th>AskVolume</th>\n”,

              ”      <th>BidVolume</th>\n”,

              ”    </tr>\n”,

              ”  </thead>\n”,

              ”  <tbody>\n”,

              ”    <tr>\n”,

              ”      <th>0</th>\n”,

              ”      <td>2020-12-21 09:00:00.500</td>\n”,

              ”      <td>4445.0</td>\n”,

              ”      <td>4419.0</td>\n”,

              ”      <td>467.0</td>\n”,

              ”      <td>87.0</td>\n”,

              ”    </tr>\n”,

              ”    <tr>\n”,

              ”      <th>1</th>\n”,

              ”      <td>2020-12-21 09:00:00.500</td>\n”,

              ”      <td>4445.0</td>\n”,

              ”      <td>4419.0</td>\n”,

              ”      <td>467.0</td>\n”,

              ”      <td>87.0</td>\n”,

              ”    </tr>\n”,

              ”    <tr>\n”,

              ”      <th>2</th>\n”,

              ”      <td>2020-12-21 09:00:00.500</td>\n”,

              ”      <td>4445.0</td>\n”,

              ”      <td>4419.0</td>\n”,

              ”      <td>467.0</td>\n”,

              ”      <td>87.0</td>\n”,

              ”    </tr>\n”,

              ”    <tr>\n”,

              ”      <th>3</th>\n”,

              ”      <td>2020-12-21 09:00:00.500</td>\n”,

              ”      <td>4445.0</td>\n”,

              ”      <td>4419.0</td>\n”,

              ”      <td>467.0</td>\n”,

              ”      <td>87.0</td>\n”,

              ”    </tr>\n”,

              ”    <tr>\n”,

              ”      <th>4</th>\n”,

              ”      <td>2020-12-21 09:00:00.500</td>\n”,

              ”      <td>4445.0</td>\n”,

              ”      <td>4419.0</td>\n”,

              ”      <td>467.0</td>\n”,

              ”      <td>87.0</td>\n”,

              ”    </tr>\n”,

              ”  </tbody>\n”,

              “</table>\n”,

              “</div>\n”,

              ”      <button class=\”colab-df-convert\” onclick=\”convertToInteractive(‘df-0e5ae9fa-2a73-45a5-9a3d-722fbe8b47df’)\”\n”,

              ”              title=\”Convert this dataframe to an interactive table.\”\n”,

              ”              style=\”display:none;\”>\n”,

              ”        \n”,

              ”  <svg xmlns=\”http://www.w3.org/2000/svg\” height=\”24px\”viewBox=\”0 0 24 24\”\n”,

              ”       width=\”24px\”>\n”,

              ”    <path d=\”M0 0h24v24H0V0z\” fill=\”none\”/>\n”,

              ”    <path d=\”M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\”/><path d=\”M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\”/>\n”,

              ”  </svg>\n”,

              ”      </button>\n”,

              ”      \n”,

              ”  <style>\n”,

              ”    .colab-df-container {\n”,

              ”      display:flex;\n”,

              ”      flex-wrap:wrap;\n”,

              ”      gap: 12px;\n”,

              ”    }\n”,

              “\n”,

              ”    .colab-df-convert {\n”,

              ”      background-color: #E8F0FE;\n”,

              ”      border: none;\n”,

              ”      border-radius: 50%;\n”,

              ”      cursor: pointer;\n”,

              ”      display: none;\n”,

              ”      fill: #1967D2;\n”,

              ”      height: 32px;\n”,

              ”      padding: 0 0 0 0;\n”,

              ”      width: 32px;\n”,

              ”    }\n”,

              “\n”,

              ”    .colab-df-convert:hover {\n”,

              ”      background-color: #E2EBFA;\n”,

              ”      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n”,

              ”      fill: #174EA6;\n”,

              ”    }\n”,

              “\n”,

              ”    [theme=dark] .colab-df-convert {\n”,

              ”      background-color: #3B4455;\n”,

              ”      fill: #D2E3FC;\n”,

              ”    }\n”,

              “\n”,

              ”    [theme=dark] .colab-df-convert:hover {\n”,

              ”      background-color: #434B5C;\n”,

              ”      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n”,

              ”      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n”,

              ”      fill: #FFFFFF;\n”,

              ”    }\n”,

              ”  </style>\n”,

              “\n”,

              ”      <script>\n”,

              ”        const buttonEl =\n”,

              ”          document.querySelector(‘#df-0e5ae9fa-2a73-45a5-9a3d-722fbe8b47df button.colab-df-convert’);\n”,

              ”        buttonEl.style.display =\n”,

              ”          google.colab.kernel.accessAllowed ? ‘block’ : ‘none’;\n”,

              “\n”,

              ”        async function convertToInteractive(key) {\n”,

              ”          const element = document.querySelector(‘#df-0e5ae9fa-2a73-45a5-9a3d-722fbe8b47df’);\n”,

              ”          const dataTable =\n”,

              ”            await google.colab.kernel.invokeFunction(‘convertToInteractive’,\n”,

              ”                                                     [key], {});\n”,

              ”          if (!dataTable) return;\n”,

              “\n”,

              ”          const docLinkHtml = ‘Like what you see? Visit the ‘ +\n”,

              ”            ‘<a target=\”_blank\” href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>’\n”,

              ”            + ‘ to learn more about interactive tables.’;\n”,

              ”          element.innerHTML = ”;\n”,

              ”          dataTable[‘output_type’] = ‘display_data’;\n”,

              ”          await google.colab.output.renderOutput(dataTable, element);\n”,

              ”          const docLink = document.createElement(‘div’);\n”,

              ”          docLink.innerHTML = docLinkHtml;\n”,

              ”          element.appendChild(docLink);\n”,

              ”        }\n”,

              ”      </script>\n”,

              ”    </div>\n”,

              ”  </div>\n”,

              ”  “

            ]

          },

          “metadata”: {},

          “execution_count”: 3

        }

      ],

      “source”: [

        “df.head()”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 4,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”,

          “height”: 206

        },

        “id”: “VvczMB-kFhHN”,

        “outputId”: “ccc3d0b8-9205-4cfa-d308-8720cf5cfb02”

      },

      “outputs”: [

        {

          “output_type”: “execute_result”,

          “data”: {

            “text/plain”: [

              ”                      Unnamed: 0  AskPrice  BidPrice  AskVolume  BidVolume\n”,

              “3805830  2021-01-05 14:59:58.000    4398.0    4397.0      120.0      201.0\n”,

              “3805831  2021-01-05 14:59:58.500    4398.0    4397.0       92.0      164.0\n”,

              “3805832  2021-01-05 14:59:59.000    4398.0    4397.0       84.0       35.0\n”,

              “3805833  2021-01-05 14:59:59.500    4398.0    4397.0       47.0       46.0\n”,

              “3805834  2021-01-05 15:00:00.000    4398.0    4397.0       84.0       30.0”

            ],

            “text/html”: [

              “\n”,

              ”  <div id=\”df-79832f5e-73cd-4498-8ec4-7eeeb4f1038e\”>\n”,

              ”    <div class=\”colab-df-container\”>\n”,

              ”      <div>\n”,

              “<style scoped>\n”,

              ”    .dataframe tbody tr th:only-of-type {\n”,

              ”        vertical-align: middle;\n”,

              ”    }\n”,

              “\n”,

              ”    .dataframe tbody tr th {\n”,

              ”        vertical-align: top;\n”,

              ”    }\n”,

              “\n”,

              ”    .dataframe thead th {\n”,

              ”        text-align: right;\n”,

              ”    }\n”,

              “</style>\n”,

              “<table border=\”1\” class=\”dataframe\”>\n”,

              ”  <thead>\n”,

              ”    <tr style=\”text-align: right;\”>\n”,

              ”      <th></th>\n”,

              ”      <th>Unnamed: 0</th>\n”,

              ”      <th>AskPrice</th>\n”,

              ”      <th>BidPrice</th>\n”,

              ”      <th>AskVolume</th>\n”,

              ”      <th>BidVolume</th>\n”,

              ”    </tr>\n”,

              ”  </thead>\n”,

              ”  <tbody>\n”,

              ”    <tr>\n”,

              ”      <th>3805830</th>\n”,

              ”      <td>2021-01-05 14:59:58.000</td>\n”,

              ”      <td>4398.0</td>\n”,

              ”      <td>4397.0</td>\n”,

              ”      <td>120.0</td>\n”,

              ”      <td>201.0</td>\n”,

              ”    </tr>\n”,

              ”    <tr>\n”,

              ”      <th>3805831</th>\n”,

              ”      <td>2021-01-05 14:59:58.500</td>\n”,

              ”      <td>4398.0</td>\n”,

              ”      <td>4397.0</td>\n”,

              ”      <td>92.0</td>\n”,

              ”      <td>164.0</td>\n”,

              ”    </tr>\n”,

              ”    <tr>\n”,

              ”      <th>3805832</th>\n”,

              ”      <td>2021-01-05 14:59:59.000</td>\n”,

              ”      <td>4398.0</td>\n”,

              ”      <td>4397.0</td>\n”,

              ”      <td>84.0</td>\n”,

              ”      <td>35.0</td>\n”,

              ”    </tr>\n”,

              ”    <tr>\n”,

              ”      <th>3805833</th>\n”,

              ”      <td>2021-01-05 14:59:59.500</td>\n”,

              ”      <td>4398.0</td>\n”,

              ”      <td>4397.0</td>\n”,

              ”      <td>47.0</td>\n”,

              ”      <td>46.0</td>\n”,

              ”    </tr>\n”,

              ”    <tr>\n”,

              ”      <th>3805834</th>\n”,

              ”      <td>2021-01-05 15:00:00.000</td>\n”,

              ”      <td>4398.0</td>\n”,

              ”      <td>4397.0</td>\n”,

              ”      <td>84.0</td>\n”,

              ”      <td>30.0</td>\n”,

              ”    </tr>\n”,

              ”  </tbody>\n”,

              “</table>\n”,

              “</div>\n”,

              ”      <button class=\”colab-df-convert\” onclick=\”convertToInteractive(‘df-79832f5e-73cd-4498-8ec4-7eeeb4f1038e’)\”\n”,

              ”              title=\”Convert this dataframe to an interactive table.\”\n”,

              ”              style=\”display:none;\”>\n”,

              ”        \n”,

              ”  <svg xmlns=\”http://www.w3.org/2000/svg\” height=\”24px\”viewBox=\”0 0 24 24\”\n”,

              ”       width=\”24px\”>\n”,

              ”    <path d=\”M0 0h24v24H0V0z\” fill=\”none\”/>\n”,

              ”    <path d=\”M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\”/><path d=\”M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\”/>\n”,

              ”  </svg>\n”,

              ”      </button>\n”,

              ”      \n”,

              ”  <style>\n”,

              ”    .colab-df-container {\n”,

              ”      display:flex;\n”,

              ”      flex-wrap:wrap;\n”,

              ”      gap: 12px;\n”,

              ”    }\n”,

              “\n”,

              ”    .colab-df-convert {\n”,

              ”      background-color: #E8F0FE;\n”,

              ”      border: none;\n”,

              ”      border-radius: 50%;\n”,

              ”      cursor: pointer;\n”,

              ”      display: none;\n”,

              ”      fill: #1967D2;\n”,

              ”      height: 32px;\n”,

              ”      padding: 0 0 0 0;\n”,

              ”      width: 32px;\n”,

              ”    }\n”,

              “\n”,

              ”    .colab-df-convert:hover {\n”,

              ”      background-color: #E2EBFA;\n”,

              ”      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n”,

              ”      fill: #174EA6;\n”,

              ”    }\n”,

              “\n”,

              ”    [theme=dark] .colab-df-convert {\n”,

              ”      background-color: #3B4455;\n”,

              ”      fill: #D2E3FC;\n”,

              ”    }\n”,

              “\n”,

              ”    [theme=dark] .colab-df-convert:hover {\n”,

              ”      background-color: #434B5C;\n”,

              ”      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n”,

              ”      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n”,

              ”      fill: #FFFFFF;\n”,

              ”    }\n”,

              ”  </style>\n”,

              “\n”,

              ”      <script>\n”,

              ”        const buttonEl =\n”,

              ”          document.querySelector(‘#df-79832f5e-73cd-4498-8ec4-7eeeb4f1038e button.colab-df-convert’);\n”,

              ”        buttonEl.style.display =\n”,

              ”          google.colab.kernel.accessAllowed ? ‘block’ : ‘none’;\n”,

              “\n”,

              ”        async function convertToInteractive(key) {\n”,

              ”          const element = document.querySelector(‘#df-79832f5e-73cd-4498-8ec4-7eeeb4f1038e’);\n”,

              ”          const dataTable =\n”,

              ”            await google.colab.kernel.invokeFunction(‘convertToInteractive’,\n”,

              ”                                                     [key], {});\n”,

              ”          if (!dataTable) return;\n”,

              “\n”,

              ”          const docLinkHtml = ‘Like what you see? Visit the ‘ +\n”,

              ”            ‘<a target=\”_blank\” href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>’\n”,

              ”            + ‘ to learn more about interactive tables.’;\n”,

              ”          element.innerHTML = ”;\n”,

              ”          dataTable[‘output_type’] = ‘display_data’;\n”,

              ”          await google.colab.output.renderOutput(dataTable, element);\n”,

              ”          const docLink = document.createElement(‘div’);\n”,

              ”          docLink.innerHTML = docLinkHtml;\n”,

              ”          element.appendChild(docLink);\n”,

              ”        }\n”,

              ”      </script>\n”,

              ”    </div>\n”,

              ”  </div>\n”,

              ”  “

            ]

          },

          “metadata”: {},

          “execution_count”: 4

        }

      ],

      “source”: [

        “df.tail()”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 6,

      “metadata”: {

        “id”: “O_zMcI0UFhHO”

      },

      “outputs”: [],

      “source”: [

        “df1=df.reset_index()[‘BidVolume’]”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 7,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”

        },

        “id”: “b1RYWva7FhHO”,

        “outputId”: “01a8133a-4731-475a-8248-eb98de9a4e2a”

      },

      “outputs”: [

        {

          “output_type”: “execute_result”,

          “data”: {

            “text/plain”: [

              “0           87.0\n”,

              “1           87.0\n”,

              “2           87.0\n”,

              “3           87.0\n”,

              “4           87.0\n”,

              ”           …  \n”,

              “3805830    201.0\n”,

              “3805831    164.0\n”,

              “3805832     35.0\n”,

              “3805833     46.0\n”,

              “3805834     30.0\n”,

              “Name: BidVolume, Length: 3805835, dtype: float64”

            ]

          },

          “metadata”: {},

          “execution_count”: 7

        }

      ],

      “source”: [

        “df1”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 8,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”,

          “height”: 295

        },

        “id”: “lzR6i915FhHP”,

        “outputId”: “c8e8efbb-cc08-4ae2-dc24-b63cfd6b4498”

      },

      “outputs”: [

        {

          “output_type”: “execute_result”,

          “data”: {

            “text/plain”: [

              “[<matplotlib.lines.Line2D at 0x7fd552aa5110>]”

            ]

          },

          “metadata”: {},

          “execution_count”: 8

        },

        {

          “output_type”: “display_data”,

          “data”: {

            “text/plain”: [

              “<Figure size 432×288 with 1 Axes>”

            ],

            “image/png”: “”

          },

          “metadata”: {

            “needs_background”: “light”

          }

        }

      ],

      “source”: [

        “import matplotlib.pyplot as plt\n”,

        “plt.plot(df1)”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 9,

      “metadata”: {

        “id”: “J04-nL5FFhHP”

      },

      “outputs”: [],

      “source”: [

        “### LSTM are sensitive to the scale of the data. so we apply MinMax scaler “

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 10,

      “metadata”: {

        “id”: “doC4t0lpFhHQ”

      },

      “outputs”: [],

      “source”: [

        “import numpy as np”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 11,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”

        },

        “id”: “ask8cTjjFhHQ”,

        “outputId”: “d352140b-6600-47c2-8501-fa988be019d8”

      },

      “outputs”: [

        {

          “output_type”: “execute_result”,

          “data”: {

            “text/plain”: [

              “0           87.0\n”,

              “1           87.0\n”,

              “2           87.0\n”,

              “3           87.0\n”,

              “4           87.0\n”,

              ”           …  \n”,

              “3805830    201.0\n”,

              “3805831    164.0\n”,

              “3805832     35.0\n”,

              “3805833     46.0\n”,

              “3805834     30.0\n”,

              “Name: BidVolume, Length: 3805835, dtype: float64”

            ]

          },

          “metadata”: {},

          “execution_count”: 11

        }

      ],

      “source”: [

        “df1”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 12,

      “metadata”: {

        “id”: “TLTg9wdVFhHQ”

      },

      “outputs”: [],

      “source”: [

        “from sklearn.preprocessing import MinMaxScaler\n”,

        “scaler=MinMaxScaler(feature_range=(0,1))\n”,

        “df1=scaler.fit_transform(np.array(df1).reshape(-1,1))”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 13,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”

        },

        “id”: “AVv0VpaeFhHR”,

        “outputId”: “b27b64c2-5276-49ab-f797-58d5bcadef4f”

      },

      “outputs”: [

        {

          “output_type”: “stream”,

          “name”: “stdout”,

          “text”: [

            “[[0.0018373 ]\n”,

            ” [0.0018373 ]\n”,

            ” [0.0018373 ]\n”,

            ” …\n”,

            ” [0.00073915]\n”,

            ” [0.00097145]\n”,

            ” [0.00063355]]\n”

          ]

        }

      ],

      “source”: [

        “print(df1)”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 14,

      “metadata”: {

        “id”: “D-ipDoBSFhHR”

      },

      “outputs”: [],

      “source”: [

        “##splitting dataset into train and test split\n”,

        “training_size=int(len(df1)*0.65)\n”,

        “test_size=len(df1)-training_size\n”,

        “train_data,test_data=df1[0:training_size,:],df1[training_size:len(df1),:1]”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 15,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”

        },

        “id”: “f5LrV5sLFhHR”,

        “outputId”: “02460f05-4492-45cd-d941-139594b6b9c8”

      },

      “outputs”: [

        {

          “output_type”: “execute_result”,

          “data”: {

            “text/plain”: [

              “(2473792, 1332043)”

            ]

          },

          “metadata”: {},

          “execution_count”: 15

        }

      ],

      “source”: [

        “training_size,test_size”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 16,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”

        },

        “id”: “2iRbi6JKFhHS”,

        “outputId”: “b33be162-db61-4772-ef47-a38c2da6a17b”

      },

      “outputs”: [

        {

          “output_type”: “execute_result”,

          “data”: {

            “text/plain”: [

              “array([[0.0018373 ],\n”,

              ”       [0.0018373 ],\n”,

              ”       [0.0018373 ],\n”,

              ”       …,\n”,

              ”       [0.00069691],\n”,

              ”       [0.00069691],\n”,

              ”       [0.00069691]])”

            ]

          },

          “metadata”: {},

          “execution_count”: 16

        }

      ],

      “source”: [

        “train_data”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 17,

      “metadata”: {

        “id”: “J8JBYEXpFhHS”

      },

      “outputs”: [],

      “source”: [

        “import numpy\n”,

        “# convert an array of values into a dataset matrix\n”,

        “def create_dataset(dataset, time_step=1):\n”,

        “\tdataX, dataY = [], []\n”,

        “\tfor i in range(len(dataset)-time_step-1):\n”,

        “\t\ta = dataset[i:(i+time_step), 0]   ###i=0, 0,1,2,3—–99   100 \n”,

        “\t\tdataX.append(a)\n”,

        “\t\tdataY.append(dataset[i + time_step, 0])\n”,

        “\treturn numpy.array(dataX), numpy.array(dataY)”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 18,

      “metadata”: {

        “id”: “ZjQtYk8BFhHT”

      },

      “outputs”: [],

      “source”: [

        “# reshape into X=t,t+1,t+2,t+3 and Y=t+4\n”,

        “time_step = 100\n”,

        “X_train, y_train = create_dataset(train_data, time_step)\n”,

        “X_test, ytest = create_dataset(test_data, time_step)”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 19,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”

        },

        “id”: “L1Swq4icFhHT”,

        “outputId”: “9c9ebf25-0c4e-4bff-81a4-d8cd399d15ff”

      },

      “outputs”: [

        {

          “output_type”: “stream”,

          “name”: “stdout”,

          “text”: [

            “(2473691, 100)\n”,

            “(2473691,)\n”

          ]

        },

        {

          “output_type”: “execute_result”,

          “data”: {

            “text/plain”: [

              “(None, None)”

            ]

          },

          “metadata”: {},

          “execution_count”: 19

        }

      ],

      “source”: [

        “print(X_train.shape), print(y_train.shape)”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 20,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”

        },

        “id”: “ZswVkPi8FhHT”,

        “outputId”: “8a62c21e-f0d6-4522-ab13-85d8108b1660”

      },

      “outputs”: [

        {

          “output_type”: “stream”,

          “name”: “stdout”,

          “text”: [

            “(1331942, 100)\n”,

            “(1331942,)\n”

          ]

        },

        {

          “output_type”: “execute_result”,

          “data”: {

            “text/plain”: [

              “(None, None)”

            ]

          },

          “metadata”: {},

          “execution_count”: 20

        }

      ],

      “source”: [

        “print(X_test.shape), print(ytest.shape)”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 21,

      “metadata”: {

        “id”: “U6UM-8xqFhHU”

      },

      “outputs”: [],

      “source”: [

        “# reshape input to be [samples, time steps, features] which is required for LSTM\n”,

        “X_train =X_train.reshape(X_train.shape[0],X_train.shape[1] , 1)\n”,

        “X_test = X_test.reshape(X_test.shape[0],X_test.shape[1] , 1)”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 22,

      “metadata”: {

        “id”: “DgZz9Bs5FhHU”

      },

      “outputs”: [],

      “source”: [

        “### Create the Stacked LSTM model\n”,

        “from tensorflow.keras.models import Sequential\n”,

        “from tensorflow.keras.layers import Dense\n”,

        “from tensorflow.keras.layers import LSTM”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 23,

      “metadata”: {

        “id”: “Lk-9tSZOFhHU”

      },

      “outputs”: [],

      “source”: [

        “model=Sequential()\n”,

        “model.add(LSTM(50,return_sequences=True,input_shape=(100,1)))\n”,

        “model.add(LSTM(50,return_sequences=True))\n”,

        “model.add(LSTM(50))\n”,

        “model.add(Dense(1))\n”,

        “model.compile(loss=’mean_squared_error’,optimizer=’adam’)\n”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 24,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”

        },

        “id”: “NSmQcT3WFhHU”,

        “outputId”: “81dfb315-15ac-4082-aa78-c894890d4ce7”

      },

      “outputs”: [

        {

          “output_type”: “stream”,

          “name”: “stdout”,

          “text”: [

            “Model: \”sequential\”\n”,

            “_________________________________________________________________\n”,

            ” Layer (type)                Output Shape              Param #   \n”,

            “=================================================================\n”,

            ” lstm (LSTM)                 (None, 100, 50)           10400     \n”,

            ”                                                                 \n”,

            ” lstm_1 (LSTM)               (None, 100, 50)           20200     \n”,

            ”                                                                 \n”,

            ” lstm_2 (LSTM)               (None, 50)                20200     \n”,

            ”                                                                 \n”,

            ” dense (Dense)               (None, 1)                 51        \n”,

            ”                                                                 \n”,

            “=================================================================\n”,

            “Total params: 50,851\n”,

            “Trainable params: 50,851\n”,

            “Non-trainable params: 0\n”,

            “_________________________________________________________________\n”

          ]

        }

      ],

      “source”: [

        “model.summary()”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 25,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”

        },

        “id”: “TQf0GLgaFhHV”,

        “outputId”: “b03339b1-ad32-480b-9f5a-6fb0fe40f505”

      },

      “outputs”: [

        {

          “output_type”: “stream”,

          “name”: “stdout”,

          “text”: [

            “Model: \”sequential\”\n”,

            “_________________________________________________________________\n”,

            ” Layer (type)                Output Shape              Param #   \n”,

            “=================================================================\n”,

            ” lstm (LSTM)                 (None, 100, 50)           10400     \n”,

            ”                                                                 \n”,

            ” lstm_1 (LSTM)               (None, 100, 50)           20200     \n”,

            ”                                                                 \n”,

            ” lstm_2 (LSTM)               (None, 50)                20200     \n”,

            ”                                                                 \n”,

            ” dense (Dense)               (None, 1)                 51        \n”,

            ”                                                                 \n”,

            “=================================================================\n”,

            “Total params: 50,851\n”,

            “Trainable params: 50,851\n”,

            “Non-trainable params: 0\n”,

            “_________________________________________________________________\n”

          ]

        }

      ],

      “source”: [

        “model.summary()”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 25,

      “metadata”: {

        “id”: “uRPkrZayFhHV”

      },

      “outputs”: [],

      “source”: [

        “”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 28,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”

        },

        “id”: “XFNKu-fDFhHV”,

        “outputId”: “362d7d94-ceb9-4271-c6ce-35b5d20eb57e”

      },

      “outputs”: [

        {

          “output_type”: “execute_result”,

          “data”: {

            “text/plain”: [

              “<keras.callbacks.History at 0x7fd4c7fc8f50>”

            ]

          },

          “metadata”: {},

          “execution_count”: 28

        }

      ],

      “source”: [

        “model.fit(X_train,y_train,validation_data=(X_test,ytest),epochs=10,batch_size=64,verbose=1)”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 29,

      “metadata”: {

        “id”: “MP2F59k9FhHV”

      },

      “outputs”: [],

      “source”: [

        “import tensorflow as tf”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: 30,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”,

          “height”: 35

        },

        “id”: “IKxCtK6JFhHV”,

        “outputId”: “38984df0-9153-4024-e9c4-0cd1e57d6931”

      },

      “outputs”: [

        {

          “output_type”: “execute_result”,

          “data”: {

            “text/plain”: [

              “‘2.8.0′”

            ],

            “application/vnd.google.colaboratory.intrinsic+json”: {

              “type”: “string”

            }

          },

          “metadata”: {},

          “execution_count”: 30

        }

      ],

      “source”: [

        “tf.__version__”

      ]

    },

    {

      “cell_type”: “code”,

      “source”: [

        “### Lets Do the prediction and check performance metrics\n”,

        “train_predict=model.predict(X_train)\n”,

        “test_predict=model.predict(X_test)”

      ],

      “metadata”: {

        “id”: “ZYXRhHqihkQr”

      },

      “execution_count”: null,

      “outputs”: []

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “id”: “MM0AckqgFhHW”

      },

      “outputs”: [],

      “source”: [

        “##Transformback to original form\n”,

        “train_predict=scaler.inverse_transform(train_predict)\n”,

        “test_predict=scaler.inverse_transform(test_predict)”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “id”: “rU8PFC1vFhHW”

      },

      “outputs”: [],

      “source”: [

        “### Calculate RMSE performance metrics\n”,

        “import math\n”,

        “from sklearn.metrics import mean_squared_error\n”,

        “math.sqrt(mean_squared_error(y_train,train_predict))”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”

        },

        “id”: “GBrz0nPzFhHX”,

        “outputId”: “d6a5cc48-655e-4138-a617-717034db6306”

      },

      “outputs”: [

        {

          “output_type”: “execute_result”,

          “data”: {

            “text/plain”: [

              “237.19528904864237”

            ]

          },

          “metadata”: {},

          “execution_count”: 34

        }

      ],

      “source”: [

        “### Test Data RMSE\n”,

        “math.sqrt(mean_squared_error(ytest,test_predict))”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”,

          “height”: 265

        },

        “id”: “XZcCzkisFhHX”,

        “outputId”: “40802fcc-ee69-451f-a6de-0a729129feda”

      },

      “outputs”: [

        {

          “output_type”: “display_data”,

          “data”: {

            “text/plain”: [

              “<Figure size 432×288 with 1 Axes>”

            ],

            “image/png”: “”

          },

          “metadata”: {

            “needs_background”: “light”

          }

        }

      ],

      “source”: [

        “### Plotting \n”,

        “# shift train predictions for plotting\n”,

        “look_back=100\n”,

        “trainPredictPlot = numpy.empty_like(df1)\n”,

        “trainPredictPlot[:, :] = np.nan\n”,

        “trainPredictPlot[look_back:len(train_predict)+look_back, :] = train_predict\n”,

        “# shift test predictions for plotting\n”,

        “testPredictPlot = numpy.empty_like(df1)\n”,

        “testPredictPlot[:, :] = numpy.nan\n”,

        “testPredictPlot[len(train_predict)+(look_back*2)+1:len(df1)-1, :] = test_predict\n”,

        “# plot baseline and predictions\n”,

        “plt.plot(scaler.inverse_transform(df1))\n”,

        “plt.plot(trainPredictPlot)\n”,

        “plt.plot(testPredictPlot)\n”,

        “plt.show()”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”

        },

        “id”: “2-A3QifDFhHX”,

        “outputId”: “c3f8897c-6851-49d8-a2e2-a2ddd190888d”

      },

      “outputs”: [

        {

          “output_type”: “execute_result”,

          “data”: {

            “text/plain”: [

              “441”

            ]

          },

          “metadata”: {},

          “execution_count”: 36

        }

      ],

      “source”: [

        “len(test_data)”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “colab”: {

          “base_uri”: “https://localhost:8080/”

        },

        “id”: “ZcMbhA5NFhHX”,

        “outputId”: “58899205-2fa7-4acd-ec3f-06d96b5daff8”

      },

      “outputs”: [

        {

          “output_type”: “execute_result”,

          “data”: {

            “text/plain”: [

              “(1, 100)”

            ]

          },

          “metadata”: {},

          “execution_count”: 37

        }

      ],

      “source”: [

        “x_input=test_data[341:].reshape(1,-1)\n”,

        “x_input.shape\n”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “id”: “0vXOejOZFhHY”

      },

      “outputs”: [],

      “source”: [

        “”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “id”: “VawQjpVmFhHY”

      },

      “outputs”: [],

      “source”: [

        “”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “id”: “21IxQfiXFhHY”

      },

      “outputs”: [],

      “source”: [

        “temp_input=list(x_input)\n”,

        “temp_input=temp_input[0].tolist()”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “id”: “S0ivcO4TFhHY”,

        “outputId”: “6974538f-ba4a-45fd-de74-e7fd165bf911”

      },

      “outputs”: [

        {

          “data”: {

            “text/plain”: [

              “[0.8583551465000423,\n”,

              ” 0.8866418981676942,\n”,

              ” 0.8743139407244789,\n”,

              ” 0.8843198513890065,\n”,

              ” 0.8783669678290975,\n”,

              ” 0.8986321033521913,\n”,

              ” 0.925821160179009,\n”,

              ” 0.9287764924427933,\n”,

              ” 0.9567677108840666,\n”,

              ” 0.9386979650426415,\n”,

              ” 0.933040614709111,\n”,

              ” 0.9495060373216249,\n”,

              ” 0.9642404796082076,\n”,

              ” 0.9551211686228154,\n”,

              ” 0.9598919192772104,\n”,

              ” 0.9663514312251966,\n”,

              ” 0.9624672802499368,\n”,

              ” 0.9229502659799038,\n”,

              ” 0.9598497002448705,\n”,

              ” 0.9879253567508233,\n”,

              ” 0.985941062230854,\n”,

              ” 0.9253145317909315,\n”,

              ” 0.9217259140420504,\n”,

              ” 0.964747107996285,\n”,

              ” 0.9757240564046274,\n”,

              ” 0.9915984125643842,\n”,

              ” 0.9697289538123788,\n”,

              ” 0.9761462467280253,\n”,

              ” 0.9679557544541082,\n”,

              ” 1.0000000000000002,\n”,

              ” 0.9901629654648318,\n”,

              ” 0.9905007177235499,\n”,

              ” 0.9653803934813816,\n”,

              ” 0.9848855864223593,\n”,

              ” 0.9708688676855528,\n”,

              ” 0.9402600692392133,\n”,

              ” 0.8774803681499621,\n”,

              ” 0.8348391454867856,\n”,

              ” 0.8541332432660644,\n”,

              ” 0.7733682344000676,\n”,

              ” 0.7726927298826314,\n”,

              ” 0.8801401671873683,\n”,

              ” 0.8400743054969182,\n”,

              ” 0.8967322468969012,\n”,

              ” 0.8552731571392387,\n”,

              ” 0.8388499535590646,\n”,

              ” 0.7423372456303303,\n”,

              ” 0.8232711306256861,\n”,

              ” 0.7814320695769654,\n”,

              ” 0.6665963016127672,\n”,

              ” 0.7921557037912694,\n”,

              ” 0.6411804441442204,\n”,

              ” 0.6861437135860848,\n”,

              ” 0.6600101325677616,\n”,

              ” 0.6520307354555435,\n”,

              ” 0.5864223591995272,\n”,

              ” 0.5658616904500551,\n”,

              ” 0.660896732246897,\n”,

              ” 0.6551549438486872,\n”,

              ” 0.7097019336316812,\n”,

              ” 0.664527569028118,\n”,

              ” 0.6943764248923416,\n”,

              ” 0.692181035210673,\n”,

              ” 0.6356919699400492,\n”,

              ” 0.6526640209406402,\n”,

              ” 0.637802921557038,\n”,

              ” 0.7267162036646122,\n”,

              ” 0.7138816178333194,\n”,

              ” 0.7419150553069325,\n”,

              ” 0.7500211095161702,\n”,

              ” 0.7722283205268936,\n”,

              ” 0.8304905851557884,\n”,

              ” 0.8194291986827664,\n”,

              ” 0.8289706999915563,\n”,

              ” 0.8125474964113824,\n”,

              ” 0.7877649244279323,\n”,

              ” 0.7516254327450818,\n”,

              ” 0.7842607447437306,\n”,

              ” 0.7797433082833742,\n”,

              ” 0.8132652199611587,\n”,

              ” 0.8141096006079542,\n”,

              ” 0.7947310647639958,\n”,

              ” 0.8333614793548934,\n”,

              ” 0.8589884319851391,\n”,

              ” 0.8390188296884238,\n”,

              ” 0.8562864139153934,\n”,

              ” 0.8748627881448958,\n”,

              ” 0.887824031073208,\n”,

              ” 0.9009541501308793,\n”,

              ” 0.9279321117959978,\n”,

              ” 0.9485349995778098,\n”,

              ” 0.9333361479354896,\n”,

              ” 0.9174617917757326,\n”,

              ” 0.925441188887951,\n”,

              ” 0.9177151059697712,\n”,

              ” 0.9483239044161109,\n”,

              ” 0.9406400405302711,\n”,

              ” 0.9663514312251966,\n”,

              ” 0.9563033015283293,\n”,

              ” 0.964915984125644]”

            ]

          },

          “execution_count”: 440,

          “metadata”: {},

          “output_type”: “execute_result”

        }

      ],

      “source”: [

        “temp_input”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “id”: “ngNu6HSvFhHY”,

        “outputId”: “4c04f07f-a817-4a61-8421-cab32c6e5324”

      },

      “outputs”: [

        {

          “name”: “stdout”,

          “output_type”: “stream”,

          “text”: [

            “[0.94413203]\n”,

            “101\n”,

            “1 day input [0.8866419  0.87431394 0.88431985 0.87836697 0.8986321  0.92582116\n”,

            ” 0.92877649 0.95676771 0.93869797 0.93304061 0.94950604 0.96424048\n”,

            ” 0.95512117 0.95989192 0.96635143 0.96246728 0.92295027 0.9598497\n”,

            ” 0.98792536 0.98594106 0.92531453 0.92172591 0.96474711 0.97572406\n”,

            ” 0.99159841 0.96972895 0.97614625 0.96795575 1.         0.99016297\n”,

            ” 0.99050072 0.96538039 0.98488559 0.97086887 0.94026007 0.87748037\n”,

            ” 0.83483915 0.85413324 0.77336823 0.77269273 0.88014017 0.84007431\n”,

            ” 0.89673225 0.85527316 0.83884995 0.74233725 0.82327113 0.78143207\n”,

            ” 0.6665963  0.7921557  0.64118044 0.68614371 0.66001013 0.65203074\n”,

            ” 0.58642236 0.56586169 0.66089673 0.65515494 0.70970193 0.66452757\n”,

            ” 0.69437642 0.69218104 0.63569197 0.65266402 0.63780292 0.7267162\n”,

            ” 0.71388162 0.74191506 0.75002111 0.77222832 0.83049059 0.8194292\n”,

            ” 0.8289707  0.8125475  0.78776492 0.75162543 0.78426074 0.77974331\n”,

            ” 0.81326522 0.8141096  0.79473106 0.83336148 0.85898843 0.83901883\n”,

            ” 0.85628641 0.87486279 0.88782403 0.90095415 0.92793211 0.948535\n”,

            ” 0.93333615 0.91746179 0.92544119 0.91771511 0.9483239  0.94064004\n”,

            ” 0.96635143 0.9563033  0.96491598 0.94413203]\n”,

            “1 day output [[0.9379593]]\n”,

            “2 day input [0.87431394 0.88431985 0.87836697 0.8986321  0.92582116 0.92877649\n”,

            ” 0.95676771 0.93869797 0.93304061 0.94950604 0.96424048 0.95512117\n”,

            ” 0.95989192 0.96635143 0.96246728 0.92295027 0.9598497  0.98792536\n”,

            ” 0.98594106 0.92531453 0.92172591 0.96474711 0.97572406 0.99159841\n”,

            ” 0.96972895 0.97614625 0.96795575 1.         0.99016297 0.99050072\n”,

            ” 0.96538039 0.98488559 0.97086887 0.94026007 0.87748037 0.83483915\n”,

            ” 0.85413324 0.77336823 0.77269273 0.88014017 0.84007431 0.89673225\n”,

            ” 0.85527316 0.83884995 0.74233725 0.82327113 0.78143207 0.6665963\n”,

            ” 0.7921557  0.64118044 0.68614371 0.66001013 0.65203074 0.58642236\n”,

            ” 0.56586169 0.66089673 0.65515494 0.70970193 0.66452757 0.69437642\n”,

            ” 0.69218104 0.63569197 0.65266402 0.63780292 0.7267162  0.71388162\n”,

            ” 0.74191506 0.75002111 0.77222832 0.83049059 0.8194292  0.8289707\n”,

            ” 0.8125475  0.78776492 0.75162543 0.78426074 0.77974331 0.81326522\n”,

            ” 0.8141096  0.79473106 0.83336148 0.85898843 0.83901883 0.85628641\n”,

            ” 0.87486279 0.88782403 0.90095415 0.92793211 0.948535   0.93333615\n”,

            ” 0.91746179 0.92544119 0.91771511 0.9483239  0.94064004 0.96635143\n”,

            ” 0.9563033  0.96491598 0.94413203 0.93795931]\n”,

            “2 day output [[0.9286534]]\n”,

            “3 day input [0.88431985 0.87836697 0.8986321  0.92582116 0.92877649 0.95676771\n”,

            ” 0.93869797 0.93304061 0.94950604 0.96424048 0.95512117 0.95989192\n”,

            ” 0.96635143 0.96246728 0.92295027 0.9598497  0.98792536 0.98594106\n”,

            ” 0.92531453 0.92172591 0.96474711 0.97572406 0.99159841 0.96972895\n”,

            ” 0.97614625 0.96795575 1.         0.99016297 0.99050072 0.96538039\n”,

            ” 0.98488559 0.97086887 0.94026007 0.87748037 0.83483915 0.85413324\n”,

            ” 0.77336823 0.77269273 0.88014017 0.84007431 0.89673225 0.85527316\n”,

            ” 0.83884995 0.74233725 0.82327113 0.78143207 0.6665963  0.7921557\n”,

            ” 0.64118044 0.68614371 0.66001013 0.65203074 0.58642236 0.56586169\n”,

            ” 0.66089673 0.65515494 0.70970193 0.66452757 0.69437642 0.69218104\n”,

            ” 0.63569197 0.65266402 0.63780292 0.7267162  0.71388162 0.74191506\n”,

            ” 0.75002111 0.77222832 0.83049059 0.8194292  0.8289707  0.8125475\n”,

            ” 0.78776492 0.75162543 0.78426074 0.77974331 0.81326522 0.8141096\n”,

            ” 0.79473106 0.83336148 0.85898843 0.83901883 0.85628641 0.87486279\n”,

            ” 0.88782403 0.90095415 0.92793211 0.948535   0.93333615 0.91746179\n”,

            ” 0.92544119 0.91771511 0.9483239  0.94064004 0.96635143 0.9563033\n”,

            ” 0.96491598 0.94413203 0.93795931 0.92865342]\n”,

            “3 day output [[0.91987926]]\n”,

            “4 day input [0.87836697 0.8986321  0.92582116 0.92877649 0.95676771 0.93869797\n”,

            ” 0.93304061 0.94950604 0.96424048 0.95512117 0.95989192 0.96635143\n”,

            ” 0.96246728 0.92295027 0.9598497  0.98792536 0.98594106 0.92531453\n”,

            ” 0.92172591 0.96474711 0.97572406 0.99159841 0.96972895 0.97614625\n”,

            ” 0.96795575 1.         0.99016297 0.99050072 0.96538039 0.98488559\n”,

            ” 0.97086887 0.94026007 0.87748037 0.83483915 0.85413324 0.77336823\n”,

            ” 0.77269273 0.88014017 0.84007431 0.89673225 0.85527316 0.83884995\n”,

            ” 0.74233725 0.82327113 0.78143207 0.6665963  0.7921557  0.64118044\n”,

            ” 0.68614371 0.66001013 0.65203074 0.58642236 0.56586169 0.66089673\n”,

            ” 0.65515494 0.70970193 0.66452757 0.69437642 0.69218104 0.63569197\n”,

            ” 0.65266402 0.63780292 0.7267162  0.71388162 0.74191506 0.75002111\n”,

            ” 0.77222832 0.83049059 0.8194292  0.8289707  0.8125475  0.78776492\n”,

            ” 0.75162543 0.78426074 0.77974331 0.81326522 0.8141096  0.79473106\n”,

            ” 0.83336148 0.85898843 0.83901883 0.85628641 0.87486279 0.88782403\n”,

            ” 0.90095415 0.92793211 0.948535   0.93333615 0.91746179 0.92544119\n”,

            ” 0.91771511 0.9483239  0.94064004 0.96635143 0.9563033  0.96491598\n”,

            ” 0.94413203 0.93795931 0.92865342 0.91987926]\n”,

            “4 day output [[0.9128097]]\n”,

            “5 day input [0.8986321  0.92582116 0.92877649 0.95676771 0.93869797 0.93304061\n”,

            ” 0.94950604 0.96424048 0.95512117 0.95989192 0.96635143 0.96246728\n”,

            ” 0.92295027 0.9598497  0.98792536 0.98594106 0.92531453 0.92172591\n”,

            ” 0.96474711 0.97572406 0.99159841 0.96972895 0.97614625 0.96795575\n”,

            ” 1.         0.99016297 0.99050072 0.96538039 0.98488559 0.97086887\n”,

            ” 0.94026007 0.87748037 0.83483915 0.85413324 0.77336823 0.77269273\n”,

            ” 0.88014017 0.84007431 0.89673225 0.85527316 0.83884995 0.74233725\n”,

            ” 0.82327113 0.78143207 0.6665963  0.7921557  0.64118044 0.68614371\n”,

            ” 0.66001013 0.65203074 0.58642236 0.56586169 0.66089673 0.65515494\n”,

            ” 0.70970193 0.66452757 0.69437642 0.69218104 0.63569197 0.65266402\n”,

            ” 0.63780292 0.7267162  0.71388162 0.74191506 0.75002111 0.77222832\n”,

            ” 0.83049059 0.8194292  0.8289707  0.8125475  0.78776492 0.75162543\n”,

            ” 0.78426074 0.77974331 0.81326522 0.8141096  0.79473106 0.83336148\n”,

            ” 0.85898843 0.83901883 0.85628641 0.87486279 0.88782403 0.90095415\n”,

            ” 0.92793211 0.948535   0.93333615 0.91746179 0.92544119 0.91771511\n”,

            ” 0.9483239  0.94064004 0.96635143 0.9563033  0.96491598 0.94413203\n”,

            ” 0.93795931 0.92865342 0.91987926 0.91280973]\n”,

            “5 day output [[0.90777564]]\n”,

            “6 day input [0.92582116 0.92877649 0.95676771 0.93869797 0.93304061 0.94950604\n”,

            ” 0.96424048 0.95512117 0.95989192 0.96635143 0.96246728 0.92295027\n”,

            ” 0.9598497  0.98792536 0.98594106 0.92531453 0.92172591 0.96474711\n”,

            ” 0.97572406 0.99159841 0.96972895 0.97614625 0.96795575 1.\n”,

            ” 0.99016297 0.99050072 0.96538039 0.98488559 0.97086887 0.94026007\n”,

            ” 0.87748037 0.83483915 0.85413324 0.77336823 0.77269273 0.88014017\n”,

            ” 0.84007431 0.89673225 0.85527316 0.83884995 0.74233725 0.82327113\n”,

            ” 0.78143207 0.6665963  0.7921557  0.64118044 0.68614371 0.66001013\n”,

            ” 0.65203074 0.58642236 0.56586169 0.66089673 0.65515494 0.70970193\n”,

            ” 0.66452757 0.69437642 0.69218104 0.63569197 0.65266402 0.63780292\n”,

            ” 0.7267162  0.71388162 0.74191506 0.75002111 0.77222832 0.83049059\n”,

            ” 0.8194292  0.8289707  0.8125475  0.78776492 0.75162543 0.78426074\n”,

            ” 0.77974331 0.81326522 0.8141096  0.79473106 0.83336148 0.85898843\n”,

            ” 0.83901883 0.85628641 0.87486279 0.88782403 0.90095415 0.92793211\n”,

            ” 0.948535   0.93333615 0.91746179 0.92544119 0.91771511 0.9483239\n”,

            ” 0.94064004 0.96635143 0.9563033  0.96491598 0.94413203 0.93795931\n”,

            ” 0.92865342 0.91987926 0.91280973 0.90777564]\n”,

            “6 day output [[0.9047326]]\n”,

            “7 day input [0.92877649 0.95676771 0.93869797 0.93304061 0.94950604 0.96424048\n”,

            ” 0.95512117 0.95989192 0.96635143 0.96246728 0.92295027 0.9598497\n”,

            ” 0.98792536 0.98594106 0.92531453 0.92172591 0.96474711 0.97572406\n”,

            ” 0.99159841 0.96972895 0.97614625 0.96795575 1.         0.99016297\n”,

            ” 0.99050072 0.96538039 0.98488559 0.97086887 0.94026007 0.87748037\n”,

            ” 0.83483915 0.85413324 0.77336823 0.77269273 0.88014017 0.84007431\n”,

            ” 0.89673225 0.85527316 0.83884995 0.74233725 0.82327113 0.78143207\n”,

            ” 0.6665963  0.7921557  0.64118044 0.68614371 0.66001013 0.65203074\n”,

            ” 0.58642236 0.56586169 0.66089673 0.65515494 0.70970193 0.66452757\n”,

            ” 0.69437642 0.69218104 0.63569197 0.65266402 0.63780292 0.7267162\n”,

            ” 0.71388162 0.74191506 0.75002111 0.77222832 0.83049059 0.8194292\n”,

            ” 0.8289707  0.8125475  0.78776492 0.75162543 0.78426074 0.77974331\n”,

            ” 0.81326522 0.8141096  0.79473106 0.83336148 0.85898843 0.83901883\n”,

            ” 0.85628641 0.87486279 0.88782403 0.90095415 0.92793211 0.948535\n”,

            ” 0.93333615 0.91746179 0.92544119 0.91771511 0.9483239  0.94064004\n”,

            ” 0.96635143 0.9563033  0.96491598 0.94413203 0.93795931 0.92865342\n”,

            ” 0.91987926 0.91280973 0.90777564 0.90473258]\n”,

            “7 day output [[0.9033923]]\n”,

            “8 day input [0.95676771 0.93869797 0.93304061 0.94950604 0.96424048 0.95512117\n”,

            ” 0.95989192 0.96635143 0.96246728 0.92295027 0.9598497  0.98792536\n”,

            ” 0.98594106 0.92531453 0.92172591 0.96474711 0.97572406 0.99159841\n”,

            ” 0.96972895 0.97614625 0.96795575 1.         0.99016297 0.99050072\n”,

            ” 0.96538039 0.98488559 0.97086887 0.94026007 0.87748037 0.83483915\n”,

            ” 0.85413324 0.77336823 0.77269273 0.88014017 0.84007431 0.89673225\n”,

            ” 0.85527316 0.83884995 0.74233725 0.82327113 0.78143207 0.6665963\n”,

            ” 0.7921557  0.64118044 0.68614371 0.66001013 0.65203074 0.58642236\n”,

            ” 0.56586169 0.66089673 0.65515494 0.70970193 0.66452757 0.69437642\n”,

            ” 0.69218104 0.63569197 0.65266402 0.63780292 0.7267162  0.71388162\n”,

            ” 0.74191506 0.75002111 0.77222832 0.83049059 0.8194292  0.8289707\n”,

            ” 0.8125475  0.78776492 0.75162543 0.78426074 0.77974331 0.81326522\n”,

            ” 0.8141096  0.79473106 0.83336148 0.85898843 0.83901883 0.85628641\n”,

            ” 0.87486279 0.88782403 0.90095415 0.92793211 0.948535   0.93333615\n”,

            ” 0.91746179 0.92544119 0.91771511 0.9483239  0.94064004 0.96635143\n”,

            ” 0.9563033  0.96491598 0.94413203 0.93795931 0.92865342 0.91987926\n”,

            ” 0.91280973 0.90777564 0.90473258 0.90339231]\n”,

            “8 day output [[0.90332204]]\n”,

            “9 day input [0.93869797 0.93304061 0.94950604 0.96424048 0.95512117 0.95989192\n”,

            ” 0.96635143 0.96246728 0.92295027 0.9598497  0.98792536 0.98594106\n”,

            ” 0.92531453 0.92172591 0.96474711 0.97572406 0.99159841 0.96972895\n”,

            ” 0.97614625 0.96795575 1.         0.99016297 0.99050072 0.96538039\n”,

            ” 0.98488559 0.97086887 0.94026007 0.87748037 0.83483915 0.85413324\n”,

            ” 0.77336823 0.77269273 0.88014017 0.84007431 0.89673225 0.85527316\n”,

            ” 0.83884995 0.74233725 0.82327113 0.78143207 0.6665963  0.7921557\n”,

            ” 0.64118044 0.68614371 0.66001013 0.65203074 0.58642236 0.56586169\n”,

            ” 0.66089673 0.65515494 0.70970193 0.66452757 0.69437642 0.69218104\n”,

            ” 0.63569197 0.65266402 0.63780292 0.7267162  0.71388162 0.74191506\n”,

            ” 0.75002111 0.77222832 0.83049059 0.8194292  0.8289707  0.8125475\n”,

            ” 0.78776492 0.75162543 0.78426074 0.77974331 0.81326522 0.8141096\n”,

            ” 0.79473106 0.83336148 0.85898843 0.83901883 0.85628641 0.87486279\n”,

            ” 0.88782403 0.90095415 0.92793211 0.948535   0.93333615 0.91746179\n”,

            ” 0.92544119 0.91771511 0.9483239  0.94064004 0.96635143 0.9563033\n”,

            ” 0.96491598 0.94413203 0.93795931 0.92865342 0.91987926 0.91280973\n”,

            ” 0.90777564 0.90473258 0.90339231 0.90332204]\n”,

            “9 day output [[0.9040391]]\n”,

            “10 day input [0.93304061 0.94950604 0.96424048 0.95512117 0.95989192 0.96635143\n”,

            ” 0.96246728 0.92295027 0.9598497  0.98792536 0.98594106 0.92531453\n”,

            ” 0.92172591 0.96474711 0.97572406 0.99159841 0.96972895 0.97614625\n”,

            ” 0.96795575 1.         0.99016297 0.99050072 0.96538039 0.98488559\n”,

            ” 0.97086887 0.94026007 0.87748037 0.83483915 0.85413324 0.77336823\n”,

            ” 0.77269273 0.88014017 0.84007431 0.89673225 0.85527316 0.83884995\n”,

            ” 0.74233725 0.82327113 0.78143207 0.6665963  0.7921557  0.64118044\n”,

            ” 0.68614371 0.66001013 0.65203074 0.58642236 0.56586169 0.66089673\n”,

            ” 0.65515494 0.70970193 0.66452757 0.69437642 0.69218104 0.63569197\n”,

            ” 0.65266402 0.63780292 0.7267162  0.71388162 0.74191506 0.75002111\n”,

            ” 0.77222832 0.83049059 0.8194292  0.8289707  0.8125475  0.78776492\n”,

            ” 0.75162543 0.78426074 0.77974331 0.81326522 0.8141096  0.79473106\n”,

            ” 0.83336148 0.85898843 0.83901883 0.85628641 0.87486279 0.88782403\n”,

            ” 0.90095415 0.92793211 0.948535   0.93333615 0.91746179 0.92544119\n”,

            ” 0.91771511 0.9483239  0.94064004 0.96635143 0.9563033  0.96491598\n”,

            ” 0.94413203 0.93795931 0.92865342 0.91987926 0.91280973 0.90777564\n”,

            ” 0.90473258 0.90339231 0.90332204 0.90403908]\n”

          ]

        },

        {

          “name”: “stdout”,

          “output_type”: “stream”,

          “text”: [

            “10 day output [[0.9050924]]\n”,

            “11 day input [0.94950604 0.96424048 0.95512117 0.95989192 0.96635143 0.96246728\n”,

            ” 0.92295027 0.9598497  0.98792536 0.98594106 0.92531453 0.92172591\n”,

            ” 0.96474711 0.97572406 0.99159841 0.96972895 0.97614625 0.96795575\n”,

            ” 1.         0.99016297 0.99050072 0.96538039 0.98488559 0.97086887\n”,

            ” 0.94026007 0.87748037 0.83483915 0.85413324 0.77336823 0.77269273\n”,

            ” 0.88014017 0.84007431 0.89673225 0.85527316 0.83884995 0.74233725\n”,

            ” 0.82327113 0.78143207 0.6665963  0.7921557  0.64118044 0.68614371\n”,

            ” 0.66001013 0.65203074 0.58642236 0.56586169 0.66089673 0.65515494\n”,

            ” 0.70970193 0.66452757 0.69437642 0.69218104 0.63569197 0.65266402\n”,

            ” 0.63780292 0.7267162  0.71388162 0.74191506 0.75002111 0.77222832\n”,

            ” 0.83049059 0.8194292  0.8289707  0.8125475  0.78776492 0.75162543\n”,

            ” 0.78426074 0.77974331 0.81326522 0.8141096  0.79473106 0.83336148\n”,

            ” 0.85898843 0.83901883 0.85628641 0.87486279 0.88782403 0.90095415\n”,

            ” 0.92793211 0.948535   0.93333615 0.91746179 0.92544119 0.91771511\n”,

            ” 0.9483239  0.94064004 0.96635143 0.9563033  0.96491598 0.94413203\n”,

            ” 0.93795931 0.92865342 0.91987926 0.91280973 0.90777564 0.90473258\n”,

            ” 0.90339231 0.90332204 0.90403908 0.90509242]\n”,

            “11 day output [[0.906118]]\n”,

            “12 day input [0.96424048 0.95512117 0.95989192 0.96635143 0.96246728 0.92295027\n”,

            ” 0.9598497  0.98792536 0.98594106 0.92531453 0.92172591 0.96474711\n”,

            ” 0.97572406 0.99159841 0.96972895 0.97614625 0.96795575 1.\n”,

            ” 0.99016297 0.99050072 0.96538039 0.98488559 0.97086887 0.94026007\n”,

            ” 0.87748037 0.83483915 0.85413324 0.77336823 0.77269273 0.88014017\n”,

            ” 0.84007431 0.89673225 0.85527316 0.83884995 0.74233725 0.82327113\n”,

            ” 0.78143207 0.6665963  0.7921557  0.64118044 0.68614371 0.66001013\n”,

            ” 0.65203074 0.58642236 0.56586169 0.66089673 0.65515494 0.70970193\n”,

            ” 0.66452757 0.69437642 0.69218104 0.63569197 0.65266402 0.63780292\n”,

            ” 0.7267162  0.71388162 0.74191506 0.75002111 0.77222832 0.83049059\n”,

            ” 0.8194292  0.8289707  0.8125475  0.78776492 0.75162543 0.78426074\n”,

            ” 0.77974331 0.81326522 0.8141096  0.79473106 0.83336148 0.85898843\n”,

            ” 0.83901883 0.85628641 0.87486279 0.88782403 0.90095415 0.92793211\n”,

            ” 0.948535   0.93333615 0.91746179 0.92544119 0.91771511 0.9483239\n”,

            ” 0.94064004 0.96635143 0.9563033  0.96491598 0.94413203 0.93795931\n”,

            ” 0.92865342 0.91987926 0.91280973 0.90777564 0.90473258 0.90339231\n”,

            ” 0.90332204 0.90403908 0.90509242 0.90611798]\n”,

            “12 day output [[0.90686554]]\n”,

            “13 day input [0.95512117 0.95989192 0.96635143 0.96246728 0.92295027 0.9598497\n”,

            ” 0.98792536 0.98594106 0.92531453 0.92172591 0.96474711 0.97572406\n”,

            ” 0.99159841 0.96972895 0.97614625 0.96795575 1.         0.99016297\n”,

            ” 0.99050072 0.96538039 0.98488559 0.97086887 0.94026007 0.87748037\n”,

            ” 0.83483915 0.85413324 0.77336823 0.77269273 0.88014017 0.84007431\n”,

            ” 0.89673225 0.85527316 0.83884995 0.74233725 0.82327113 0.78143207\n”,

            ” 0.6665963  0.7921557  0.64118044 0.68614371 0.66001013 0.65203074\n”,

            ” 0.58642236 0.56586169 0.66089673 0.65515494 0.70970193 0.66452757\n”,

            ” 0.69437642 0.69218104 0.63569197 0.65266402 0.63780292 0.7267162\n”,

            ” 0.71388162 0.74191506 0.75002111 0.77222832 0.83049059 0.8194292\n”,

            ” 0.8289707  0.8125475  0.78776492 0.75162543 0.78426074 0.77974331\n”,

            ” 0.81326522 0.8141096  0.79473106 0.83336148 0.85898843 0.83901883\n”,

            ” 0.85628641 0.87486279 0.88782403 0.90095415 0.92793211 0.948535\n”,

            ” 0.93333615 0.91746179 0.92544119 0.91771511 0.9483239  0.94064004\n”,

            ” 0.96635143 0.9563033  0.96491598 0.94413203 0.93795931 0.92865342\n”,

            ” 0.91987926 0.91280973 0.90777564 0.90473258 0.90339231 0.90332204\n”,

            ” 0.90403908 0.90509242 0.90611798 0.90686554]\n”,

            “13 day output [[0.90720606]]\n”,

            “14 day input [0.95989192 0.96635143 0.96246728 0.92295027 0.9598497  0.98792536\n”,

            ” 0.98594106 0.92531453 0.92172591 0.96474711 0.97572406 0.99159841\n”,

            ” 0.96972895 0.97614625 0.96795575 1.         0.99016297 0.99050072\n”,

            ” 0.96538039 0.98488559 0.97086887 0.94026007 0.87748037 0.83483915\n”,

            ” 0.85413324 0.77336823 0.77269273 0.88014017 0.84007431 0.89673225\n”,

            ” 0.85527316 0.83884995 0.74233725 0.82327113 0.78143207 0.6665963\n”,

            ” 0.7921557  0.64118044 0.68614371 0.66001013 0.65203074 0.58642236\n”,

            ” 0.56586169 0.66089673 0.65515494 0.70970193 0.66452757 0.69437642\n”,

            ” 0.69218104 0.63569197 0.65266402 0.63780292 0.7267162  0.71388162\n”,

            ” 0.74191506 0.75002111 0.77222832 0.83049059 0.8194292  0.8289707\n”,

            ” 0.8125475  0.78776492 0.75162543 0.78426074 0.77974331 0.81326522\n”,

            ” 0.8141096  0.79473106 0.83336148 0.85898843 0.83901883 0.85628641\n”,

            ” 0.87486279 0.88782403 0.90095415 0.92793211 0.948535   0.93333615\n”,

            ” 0.91746179 0.92544119 0.91771511 0.9483239  0.94064004 0.96635143\n”,

            ” 0.9563033  0.96491598 0.94413203 0.93795931 0.92865342 0.91987926\n”,

            ” 0.91280973 0.90777564 0.90473258 0.90339231 0.90332204 0.90403908\n”,

            ” 0.90509242 0.90611798 0.90686554 0.90720606]\n”,

            “14 day output [[0.9071163]]\n”,

            “15 day input [0.96635143 0.96246728 0.92295027 0.9598497  0.98792536 0.98594106\n”,

            ” 0.92531453 0.92172591 0.96474711 0.97572406 0.99159841 0.96972895\n”,

            ” 0.97614625 0.96795575 1.         0.99016297 0.99050072 0.96538039\n”,

            ” 0.98488559 0.97086887 0.94026007 0.87748037 0.83483915 0.85413324\n”,

            ” 0.77336823 0.77269273 0.88014017 0.84007431 0.89673225 0.85527316\n”,

            ” 0.83884995 0.74233725 0.82327113 0.78143207 0.6665963  0.7921557\n”,

            ” 0.64118044 0.68614371 0.66001013 0.65203074 0.58642236 0.56586169\n”,

            ” 0.66089673 0.65515494 0.70970193 0.66452757 0.69437642 0.69218104\n”,

            ” 0.63569197 0.65266402 0.63780292 0.7267162  0.71388162 0.74191506\n”,

            ” 0.75002111 0.77222832 0.83049059 0.8194292  0.8289707  0.8125475\n”,

            ” 0.78776492 0.75162543 0.78426074 0.77974331 0.81326522 0.8141096\n”,

            ” 0.79473106 0.83336148 0.85898843 0.83901883 0.85628641 0.87486279\n”,

            ” 0.88782403 0.90095415 0.92793211 0.948535   0.93333615 0.91746179\n”,

            ” 0.92544119 0.91771511 0.9483239  0.94064004 0.96635143 0.9563033\n”,

            ” 0.96491598 0.94413203 0.93795931 0.92865342 0.91987926 0.91280973\n”,

            ” 0.90777564 0.90473258 0.90339231 0.90332204 0.90403908 0.90509242\n”,

            ” 0.90611798 0.90686554 0.90720606 0.90711629]\n”,

            “15 day output [[0.9066538]]\n”,

            “16 day input [0.96246728 0.92295027 0.9598497  0.98792536 0.98594106 0.92531453\n”,

            ” 0.92172591 0.96474711 0.97572406 0.99159841 0.96972895 0.97614625\n”,

            ” 0.96795575 1.         0.99016297 0.99050072 0.96538039 0.98488559\n”,

            ” 0.97086887 0.94026007 0.87748037 0.83483915 0.85413324 0.77336823\n”,

            ” 0.77269273 0.88014017 0.84007431 0.89673225 0.85527316 0.83884995\n”,

            ” 0.74233725 0.82327113 0.78143207 0.6665963  0.7921557  0.64118044\n”,

            ” 0.68614371 0.66001013 0.65203074 0.58642236 0.56586169 0.66089673\n”,

            ” 0.65515494 0.70970193 0.66452757 0.69437642 0.69218104 0.63569197\n”,

            ” 0.65266402 0.63780292 0.7267162  0.71388162 0.74191506 0.75002111\n”,

            ” 0.77222832 0.83049059 0.8194292  0.8289707  0.8125475  0.78776492\n”,

            ” 0.75162543 0.78426074 0.77974331 0.81326522 0.8141096  0.79473106\n”,

            ” 0.83336148 0.85898843 0.83901883 0.85628641 0.87486279 0.88782403\n”,

            ” 0.90095415 0.92793211 0.948535   0.93333615 0.91746179 0.92544119\n”,

            ” 0.91771511 0.9483239  0.94064004 0.96635143 0.9563033  0.96491598\n”,

            ” 0.94413203 0.93795931 0.92865342 0.91987926 0.91280973 0.90777564\n”,

            ” 0.90473258 0.90339231 0.90332204 0.90403908 0.90509242 0.90611798\n”,

            ” 0.90686554 0.90720606 0.90711629 0.90665382]\n”,

            “16 day output [[0.90592706]]\n”,

            “17 day input [0.92295027 0.9598497  0.98792536 0.98594106 0.92531453 0.92172591\n”,

            ” 0.96474711 0.97572406 0.99159841 0.96972895 0.97614625 0.96795575\n”,

            ” 1.         0.99016297 0.99050072 0.96538039 0.98488559 0.97086887\n”,

            ” 0.94026007 0.87748037 0.83483915 0.85413324 0.77336823 0.77269273\n”,

            ” 0.88014017 0.84007431 0.89673225 0.85527316 0.83884995 0.74233725\n”,

            ” 0.82327113 0.78143207 0.6665963  0.7921557  0.64118044 0.68614371\n”,

            ” 0.66001013 0.65203074 0.58642236 0.56586169 0.66089673 0.65515494\n”,

            ” 0.70970193 0.66452757 0.69437642 0.69218104 0.63569197 0.65266402\n”,

            ” 0.63780292 0.7267162  0.71388162 0.74191506 0.75002111 0.77222832\n”,

            ” 0.83049059 0.8194292  0.8289707  0.8125475  0.78776492 0.75162543\n”,

            ” 0.78426074 0.77974331 0.81326522 0.8141096  0.79473106 0.83336148\n”,

            ” 0.85898843 0.83901883 0.85628641 0.87486279 0.88782403 0.90095415\n”,

            ” 0.92793211 0.948535   0.93333615 0.91746179 0.92544119 0.91771511\n”,

            ” 0.9483239  0.94064004 0.96635143 0.9563033  0.96491598 0.94413203\n”,

            ” 0.93795931 0.92865342 0.91987926 0.91280973 0.90777564 0.90473258\n”,

            ” 0.90339231 0.90332204 0.90403908 0.90509242 0.90611798 0.90686554\n”,

            ” 0.90720606 0.90711629 0.90665382 0.90592706]\n”,

            “17 day output [[0.9050646]]\n”,

            “18 day input [0.9598497  0.98792536 0.98594106 0.92531453 0.92172591 0.96474711\n”,

            ” 0.97572406 0.99159841 0.96972895 0.97614625 0.96795575 1.\n”,

            ” 0.99016297 0.99050072 0.96538039 0.98488559 0.97086887 0.94026007\n”,

            ” 0.87748037 0.83483915 0.85413324 0.77336823 0.77269273 0.88014017\n”,

            ” 0.84007431 0.89673225 0.85527316 0.83884995 0.74233725 0.82327113\n”,

            ” 0.78143207 0.6665963  0.7921557  0.64118044 0.68614371 0.66001013\n”,

            ” 0.65203074 0.58642236 0.56586169 0.66089673 0.65515494 0.70970193\n”,

            ” 0.66452757 0.69437642 0.69218104 0.63569197 0.65266402 0.63780292\n”,

            ” 0.7267162  0.71388162 0.74191506 0.75002111 0.77222832 0.83049059\n”,

            ” 0.8194292  0.8289707  0.8125475  0.78776492 0.75162543 0.78426074\n”,

            ” 0.77974331 0.81326522 0.8141096  0.79473106 0.83336148 0.85898843\n”,

            ” 0.83901883 0.85628641 0.87486279 0.88782403 0.90095415 0.92793211\n”,

            ” 0.948535   0.93333615 0.91746179 0.92544119 0.91771511 0.9483239\n”,

            ” 0.94064004 0.96635143 0.9563033  0.96491598 0.94413203 0.93795931\n”,

            ” 0.92865342 0.91987926 0.91280973 0.90777564 0.90473258 0.90339231\n”,

            ” 0.90332204 0.90403908 0.90509242 0.90611798 0.90686554 0.90720606\n”,

            ” 0.90711629 0.90665382 0.90592706 0.90506458]\n”,

            “18 day output [[0.90419257]]\n”,

            “19 day input [0.98792536 0.98594106 0.92531453 0.92172591 0.96474711 0.97572406\n”,

            ” 0.99159841 0.96972895 0.97614625 0.96795575 1.         0.99016297\n”,

            ” 0.99050072 0.96538039 0.98488559 0.97086887 0.94026007 0.87748037\n”,

            ” 0.83483915 0.85413324 0.77336823 0.77269273 0.88014017 0.84007431\n”,

            ” 0.89673225 0.85527316 0.83884995 0.74233725 0.82327113 0.78143207\n”,

            ” 0.6665963  0.7921557  0.64118044 0.68614371 0.66001013 0.65203074\n”,

            ” 0.58642236 0.56586169 0.66089673 0.65515494 0.70970193 0.66452757\n”,

            ” 0.69437642 0.69218104 0.63569197 0.65266402 0.63780292 0.7267162\n”,

            ” 0.71388162 0.74191506 0.75002111 0.77222832 0.83049059 0.8194292\n”,

            ” 0.8289707  0.8125475  0.78776492 0.75162543 0.78426074 0.77974331\n”,

            ” 0.81326522 0.8141096  0.79473106 0.83336148 0.85898843 0.83901883\n”,

            ” 0.85628641 0.87486279 0.88782403 0.90095415 0.92793211 0.948535\n”,

            ” 0.93333615 0.91746179 0.92544119 0.91771511 0.9483239  0.94064004\n”,

            ” 0.96635143 0.9563033  0.96491598 0.94413203 0.93795931 0.92865342\n”,

            ” 0.91987926 0.91280973 0.90777564 0.90473258 0.90339231 0.90332204\n”,

            ” 0.90403908 0.90509242 0.90611798 0.90686554 0.90720606 0.90711629\n”,

            ” 0.90665382 0.90592706 0.90506458 0.90419257]\n”,

            “19 day output [[0.9034131]]\n”,

            “20 day input [0.98594106 0.92531453 0.92172591 0.96474711 0.97572406 0.99159841\n”,

            ” 0.96972895 0.97614625 0.96795575 1.         0.99016297 0.99050072\n”,

            ” 0.96538039 0.98488559 0.97086887 0.94026007 0.87748037 0.83483915\n”,

            ” 0.85413324 0.77336823 0.77269273 0.88014017 0.84007431 0.89673225\n”,

            ” 0.85527316 0.83884995 0.74233725 0.82327113 0.78143207 0.6665963\n”,

            ” 0.7921557  0.64118044 0.68614371 0.66001013 0.65203074 0.58642236\n”,

            ” 0.56586169 0.66089673 0.65515494 0.70970193 0.66452757 0.69437642\n”,

            ” 0.69218104 0.63569197 0.65266402 0.63780292 0.7267162  0.71388162\n”,

            ” 0.74191506 0.75002111 0.77222832 0.83049059 0.8194292  0.8289707\n”,

            ” 0.8125475  0.78776492 0.75162543 0.78426074 0.77974331 0.81326522\n”,

            ” 0.8141096  0.79473106 0.83336148 0.85898843 0.83901883 0.85628641\n”,

            ” 0.87486279 0.88782403 0.90095415 0.92793211 0.948535   0.93333615\n”,

            ” 0.91746179 0.92544119 0.91771511 0.9483239  0.94064004 0.96635143\n”,

            ” 0.9563033  0.96491598 0.94413203 0.93795931 0.92865342 0.91987926\n”,

            ” 0.91280973 0.90777564 0.90473258 0.90339231 0.90332204 0.90403908\n”,

            ” 0.90509242 0.90611798 0.90686554 0.90720606 0.90711629 0.90665382\n”,

            ” 0.90592706 0.90506458 0.90419257 0.90341312]\n”

          ]

        },

        {

          “name”: “stdout”,

          “output_type”: “stream”,

          “text”: [

            “20 day output [[0.90279734]]\n”,

            “21 day input [0.92531453 0.92172591 0.96474711 0.97572406 0.99159841 0.96972895\n”,

            ” 0.97614625 0.96795575 1.         0.99016297 0.99050072 0.96538039\n”,

            ” 0.98488559 0.97086887 0.94026007 0.87748037 0.83483915 0.85413324\n”,

            ” 0.77336823 0.77269273 0.88014017 0.84007431 0.89673225 0.85527316\n”,

            ” 0.83884995 0.74233725 0.82327113 0.78143207 0.6665963  0.7921557\n”,

            ” 0.64118044 0.68614371 0.66001013 0.65203074 0.58642236 0.56586169\n”,

            ” 0.66089673 0.65515494 0.70970193 0.66452757 0.69437642 0.69218104\n”,

            ” 0.63569197 0.65266402 0.63780292 0.7267162  0.71388162 0.74191506\n”,

            ” 0.75002111 0.77222832 0.83049059 0.8194292  0.8289707  0.8125475\n”,

            ” 0.78776492 0.75162543 0.78426074 0.77974331 0.81326522 0.8141096\n”,

            ” 0.79473106 0.83336148 0.85898843 0.83901883 0.85628641 0.87486279\n”,

            ” 0.88782403 0.90095415 0.92793211 0.948535   0.93333615 0.91746179\n”,

            ” 0.92544119 0.91771511 0.9483239  0.94064004 0.96635143 0.9563033\n”,

            ” 0.96491598 0.94413203 0.93795931 0.92865342 0.91987926 0.91280973\n”,

            ” 0.90777564 0.90473258 0.90339231 0.90332204 0.90403908 0.90509242\n”,

            ” 0.90611798 0.90686554 0.90720606 0.90711629 0.90665382 0.90592706\n”,

            ” 0.90506458 0.90419257 0.90341312 0.90279734]\n”,

            “21 day output [[0.9023812]]\n”,

            “22 day input [0.92172591 0.96474711 0.97572406 0.99159841 0.96972895 0.97614625\n”,

            ” 0.96795575 1.         0.99016297 0.99050072 0.96538039 0.98488559\n”,

            ” 0.97086887 0.94026007 0.87748037 0.83483915 0.85413324 0.77336823\n”,

            ” 0.77269273 0.88014017 0.84007431 0.89673225 0.85527316 0.83884995\n”,

            ” 0.74233725 0.82327113 0.78143207 0.6665963  0.7921557  0.64118044\n”,

            ” 0.68614371 0.66001013 0.65203074 0.58642236 0.56586169 0.66089673\n”,

            ” 0.65515494 0.70970193 0.66452757 0.69437642 0.69218104 0.63569197\n”,

            ” 0.65266402 0.63780292 0.7267162  0.71388162 0.74191506 0.75002111\n”,

            ” 0.77222832 0.83049059 0.8194292  0.8289707  0.8125475  0.78776492\n”,

            ” 0.75162543 0.78426074 0.77974331 0.81326522 0.8141096  0.79473106\n”,

            ” 0.83336148 0.85898843 0.83901883 0.85628641 0.87486279 0.88782403\n”,

            ” 0.90095415 0.92793211 0.948535   0.93333615 0.91746179 0.92544119\n”,

            ” 0.91771511 0.9483239  0.94064004 0.96635143 0.9563033  0.96491598\n”,

            ” 0.94413203 0.93795931 0.92865342 0.91987926 0.91280973 0.90777564\n”,

            ” 0.90473258 0.90339231 0.90332204 0.90403908 0.90509242 0.90611798\n”,

            ” 0.90686554 0.90720606 0.90711629 0.90665382 0.90592706 0.90506458\n”,

            ” 0.90419257 0.90341312 0.90279734 0.90238118]\n”,

            “22 day output [[0.9021694]]\n”,

            “23 day input [0.96474711 0.97572406 0.99159841 0.96972895 0.97614625 0.96795575\n”,

            ” 1.         0.99016297 0.99050072 0.96538039 0.98488559 0.97086887\n”,

            ” 0.94026007 0.87748037 0.83483915 0.85413324 0.77336823 0.77269273\n”,

            ” 0.88014017 0.84007431 0.89673225 0.85527316 0.83884995 0.74233725\n”,

            ” 0.82327113 0.78143207 0.6665963  0.7921557  0.64118044 0.68614371\n”,

            ” 0.66001013 0.65203074 0.58642236 0.56586169 0.66089673 0.65515494\n”,

            ” 0.70970193 0.66452757 0.69437642 0.69218104 0.63569197 0.65266402\n”,

            ” 0.63780292 0.7267162  0.71388162 0.74191506 0.75002111 0.77222832\n”,

            ” 0.83049059 0.8194292  0.8289707  0.8125475  0.78776492 0.75162543\n”,

            ” 0.78426074 0.77974331 0.81326522 0.8141096  0.79473106 0.83336148\n”,

            ” 0.85898843 0.83901883 0.85628641 0.87486279 0.88782403 0.90095415\n”,

            ” 0.92793211 0.948535   0.93333615 0.91746179 0.92544119 0.91771511\n”,

            ” 0.9483239  0.94064004 0.96635143 0.9563033  0.96491598 0.94413203\n”,

            ” 0.93795931 0.92865342 0.91987926 0.91280973 0.90777564 0.90473258\n”,

            ” 0.90339231 0.90332204 0.90403908 0.90509242 0.90611798 0.90686554\n”,

            ” 0.90720606 0.90711629 0.90665382 0.90592706 0.90506458 0.90419257\n”,

            ” 0.90341312 0.90279734 0.90238118 0.90216941]\n”,

            “23 day output [[0.90213937]]\n”,

            “24 day input [0.97572406 0.99159841 0.96972895 0.97614625 0.96795575 1.\n”,

            ” 0.99016297 0.99050072 0.96538039 0.98488559 0.97086887 0.94026007\n”,

            ” 0.87748037 0.83483915 0.85413324 0.77336823 0.77269273 0.88014017\n”,

            ” 0.84007431 0.89673225 0.85527316 0.83884995 0.74233725 0.82327113\n”,

            ” 0.78143207 0.6665963  0.7921557  0.64118044 0.68614371 0.66001013\n”,

            ” 0.65203074 0.58642236 0.56586169 0.66089673 0.65515494 0.70970193\n”,

            ” 0.66452757 0.69437642 0.69218104 0.63569197 0.65266402 0.63780292\n”,

            ” 0.7267162  0.71388162 0.74191506 0.75002111 0.77222832 0.83049059\n”,

            ” 0.8194292  0.8289707  0.8125475  0.78776492 0.75162543 0.78426074\n”,

            ” 0.77974331 0.81326522 0.8141096  0.79473106 0.83336148 0.85898843\n”,

            ” 0.83901883 0.85628641 0.87486279 0.88782403 0.90095415 0.92793211\n”,

            ” 0.948535   0.93333615 0.91746179 0.92544119 0.91771511 0.9483239\n”,

            ” 0.94064004 0.96635143 0.9563033  0.96491598 0.94413203 0.93795931\n”,

            ” 0.92865342 0.91987926 0.91280973 0.90777564 0.90473258 0.90339231\n”,

            ” 0.90332204 0.90403908 0.90509242 0.90611798 0.90686554 0.90720606\n”,

            ” 0.90711629 0.90665382 0.90592706 0.90506458 0.90419257 0.90341312\n”,

            ” 0.90279734 0.90238118 0.90216941 0.90213937]\n”,

            “24 day output [[0.9022528]]\n”,

            “25 day input [0.99159841 0.96972895 0.97614625 0.96795575 1.         0.99016297\n”,

            ” 0.99050072 0.96538039 0.98488559 0.97086887 0.94026007 0.87748037\n”,

            ” 0.83483915 0.85413324 0.77336823 0.77269273 0.88014017 0.84007431\n”,

            ” 0.89673225 0.85527316 0.83884995 0.74233725 0.82327113 0.78143207\n”,

            ” 0.6665963  0.7921557  0.64118044 0.68614371 0.66001013 0.65203074\n”,

            ” 0.58642236 0.56586169 0.66089673 0.65515494 0.70970193 0.66452757\n”,

            ” 0.69437642 0.69218104 0.63569197 0.65266402 0.63780292 0.7267162\n”,

            ” 0.71388162 0.74191506 0.75002111 0.77222832 0.83049059 0.8194292\n”,

            ” 0.8289707  0.8125475  0.78776492 0.75162543 0.78426074 0.77974331\n”,

            ” 0.81326522 0.8141096  0.79473106 0.83336148 0.85898843 0.83901883\n”,

            ” 0.85628641 0.87486279 0.88782403 0.90095415 0.92793211 0.948535\n”,

            ” 0.93333615 0.91746179 0.92544119 0.91771511 0.9483239  0.94064004\n”,

            ” 0.96635143 0.9563033  0.96491598 0.94413203 0.93795931 0.92865342\n”,

            ” 0.91987926 0.91280973 0.90777564 0.90473258 0.90339231 0.90332204\n”,

            ” 0.90403908 0.90509242 0.90611798 0.90686554 0.90720606 0.90711629\n”,

            ” 0.90665382 0.90592706 0.90506458 0.90419257 0.90341312 0.90279734\n”,

            ” 0.90238118 0.90216941 0.90213937 0.90225279]\n”,

            “25 day output [[0.90246403]]\n”,

            “26 day input [0.96972895 0.97614625 0.96795575 1.         0.99016297 0.99050072\n”,

            ” 0.96538039 0.98488559 0.97086887 0.94026007 0.87748037 0.83483915\n”,

            ” 0.85413324 0.77336823 0.77269273 0.88014017 0.84007431 0.89673225\n”,

            ” 0.85527316 0.83884995 0.74233725 0.82327113 0.78143207 0.6665963\n”,

            ” 0.7921557  0.64118044 0.68614371 0.66001013 0.65203074 0.58642236\n”,

            ” 0.56586169 0.66089673 0.65515494 0.70970193 0.66452757 0.69437642\n”,

            ” 0.69218104 0.63569197 0.65266402 0.63780292 0.7267162  0.71388162\n”,

            ” 0.74191506 0.75002111 0.77222832 0.83049059 0.8194292  0.8289707\n”,

            ” 0.8125475  0.78776492 0.75162543 0.78426074 0.77974331 0.81326522\n”,

            ” 0.8141096  0.79473106 0.83336148 0.85898843 0.83901883 0.85628641\n”,

            ” 0.87486279 0.88782403 0.90095415 0.92793211 0.948535   0.93333615\n”,

            ” 0.91746179 0.92544119 0.91771511 0.9483239  0.94064004 0.96635143\n”,

            ” 0.9563033  0.96491598 0.94413203 0.93795931 0.92865342 0.91987926\n”,

            ” 0.91280973 0.90777564 0.90473258 0.90339231 0.90332204 0.90403908\n”,

            ” 0.90509242 0.90611798 0.90686554 0.90720606 0.90711629 0.90665382\n”,

            ” 0.90592706 0.90506458 0.90419257 0.90341312 0.90279734 0.90238118\n”,

            ” 0.90216941 0.90213937 0.90225279 0.90246403]\n”,

            “26 day output [[0.90272856]]\n”,

            “27 day input [0.97614625 0.96795575 1.         0.99016297 0.99050072 0.96538039\n”,

            ” 0.98488559 0.97086887 0.94026007 0.87748037 0.83483915 0.85413324\n”,

            ” 0.77336823 0.77269273 0.88014017 0.84007431 0.89673225 0.85527316\n”,

            ” 0.83884995 0.74233725 0.82327113 0.78143207 0.6665963  0.7921557\n”,

            ” 0.64118044 0.68614371 0.66001013 0.65203074 0.58642236 0.56586169\n”,

            ” 0.66089673 0.65515494 0.70970193 0.66452757 0.69437642 0.69218104\n”,

            ” 0.63569197 0.65266402 0.63780292 0.7267162  0.71388162 0.74191506\n”,

            ” 0.75002111 0.77222832 0.83049059 0.8194292  0.8289707  0.8125475\n”,

            ” 0.78776492 0.75162543 0.78426074 0.77974331 0.81326522 0.8141096\n”,

            ” 0.79473106 0.83336148 0.85898843 0.83901883 0.85628641 0.87486279\n”,

            ” 0.88782403 0.90095415 0.92793211 0.948535   0.93333615 0.91746179\n”,

            ” 0.92544119 0.91771511 0.9483239  0.94064004 0.96635143 0.9563033\n”,

            ” 0.96491598 0.94413203 0.93795931 0.92865342 0.91987926 0.91280973\n”,

            ” 0.90777564 0.90473258 0.90339231 0.90332204 0.90403908 0.90509242\n”,

            ” 0.90611798 0.90686554 0.90720606 0.90711629 0.90665382 0.90592706\n”,

            ” 0.90506458 0.90419257 0.90341312 0.90279734 0.90238118 0.90216941\n”,

            ” 0.90213937 0.90225279 0.90246403 0.90272856]\n”,

            “27 day output [[0.90300757]]\n”,

            “28 day input [0.96795575 1.         0.99016297 0.99050072 0.96538039 0.98488559\n”,

            ” 0.97086887 0.94026007 0.87748037 0.83483915 0.85413324 0.77336823\n”,

            ” 0.77269273 0.88014017 0.84007431 0.89673225 0.85527316 0.83884995\n”,

            ” 0.74233725 0.82327113 0.78143207 0.6665963  0.7921557  0.64118044\n”,

            ” 0.68614371 0.66001013 0.65203074 0.58642236 0.56586169 0.66089673\n”,

            ” 0.65515494 0.70970193 0.66452757 0.69437642 0.69218104 0.63569197\n”,

            ” 0.65266402 0.63780292 0.7267162  0.71388162 0.74191506 0.75002111\n”,

            ” 0.77222832 0.83049059 0.8194292  0.8289707  0.8125475  0.78776492\n”,

            ” 0.75162543 0.78426074 0.77974331 0.81326522 0.8141096  0.79473106\n”,

            ” 0.83336148 0.85898843 0.83901883 0.85628641 0.87486279 0.88782403\n”,

            ” 0.90095415 0.92793211 0.948535   0.93333615 0.91746179 0.92544119\n”,

            ” 0.91771511 0.9483239  0.94064004 0.96635143 0.9563033  0.96491598\n”,

            ” 0.94413203 0.93795931 0.92865342 0.91987926 0.91280973 0.90777564\n”,

            ” 0.90473258 0.90339231 0.90332204 0.90403908 0.90509242 0.90611798\n”,

            ” 0.90686554 0.90720606 0.90711629 0.90665382 0.90592706 0.90506458\n”,

            ” 0.90419257 0.90341312 0.90279734 0.90238118 0.90216941 0.90213937\n”,

            ” 0.90225279 0.90246403 0.90272856 0.90300757]\n”

          ]

        },

        {

          “name”: “stdout”,

          “output_type”: “stream”,

          “text”: [

            “28 day output [[0.903272]]\n”,

            “29 day input [1.         0.99016297 0.99050072 0.96538039 0.98488559 0.97086887\n”,

            ” 0.94026007 0.87748037 0.83483915 0.85413324 0.77336823 0.77269273\n”,

            ” 0.88014017 0.84007431 0.89673225 0.85527316 0.83884995 0.74233725\n”,

            ” 0.82327113 0.78143207 0.6665963  0.7921557  0.64118044 0.68614371\n”,

            ” 0.66001013 0.65203074 0.58642236 0.56586169 0.66089673 0.65515494\n”,

            ” 0.70970193 0.66452757 0.69437642 0.69218104 0.63569197 0.65266402\n”,

            ” 0.63780292 0.7267162  0.71388162 0.74191506 0.75002111 0.77222832\n”,

            ” 0.83049059 0.8194292  0.8289707  0.8125475  0.78776492 0.75162543\n”,

            ” 0.78426074 0.77974331 0.81326522 0.8141096  0.79473106 0.83336148\n”,

            ” 0.85898843 0.83901883 0.85628641 0.87486279 0.88782403 0.90095415\n”,

            ” 0.92793211 0.948535   0.93333615 0.91746179 0.92544119 0.91771511\n”,

            ” 0.9483239  0.94064004 0.96635143 0.9563033  0.96491598 0.94413203\n”,

            ” 0.93795931 0.92865342 0.91987926 0.91280973 0.90777564 0.90473258\n”,

            ” 0.90339231 0.90332204 0.90403908 0.90509242 0.90611798 0.90686554\n”,

            ” 0.90720606 0.90711629 0.90665382 0.90592706 0.90506458 0.90419257\n”,

            ” 0.90341312 0.90279734 0.90238118 0.90216941 0.90213937 0.90225279\n”,

            ” 0.90246403 0.90272856 0.90300757 0.90327197]\n”,

            “29 day output [[0.90350425]]\n”,

            “[[0.9441320300102234], [0.9379593133926392], [0.9286534190177917], [0.9198792576789856], [0.9128097295761108], [0.9077756404876709], [0.9047325849533081], [0.9033923149108887], [0.9033220410346985], [0.9040390849113464], [0.9050924181938171], [0.9061179757118225], [0.9068655371665955], [0.9072060585021973], [0.9071162939071655], [0.9066538214683533], [0.9059270620346069], [0.905064582824707], [0.9041925668716431], [0.9034131169319153], [0.9027973413467407], [0.902381181716919], [0.902169406414032], [0.9021393656730652], [0.9022527933120728], [0.9024640321731567], [0.9027285575866699], [0.9030075669288635], [0.9032719731330872], [0.9035042524337769]]\n”

          ]

        }

      ],

      “source”: [

        “# demonstrate prediction for next 10 days\n”,

        “from numpy import array\n”,

        “\n”,

        “lst_output=[]\n”,

        “n_steps=100\n”,

        “i=0\n”,

        “while(i<30):\n”,

        ”    \n”,

        ”    if(len(temp_input)>100):\n”,

        ”        #print(temp_input)\n”,

        ”        x_input=np.array(temp_input[1:])\n”,

        ”        print(\”{} day input {}\”.format(i,x_input))\n”,

        ”        x_input=x_input.reshape(1,-1)\n”,

        ”        x_input = x_input.reshape((1, n_steps, 1))\n”,

        ”        #print(x_input)\n”,

        ”        yhat = model.predict(x_input, verbose=0)\n”,

        ”        print(\”{} day output {}\”.format(i,yhat))\n”,

        ”        temp_input.extend(yhat[0].tolist())\n”,

        ”        temp_input=temp_input[1:]\n”,

        ”        #print(temp_input)\n”,

        ”        lst_output.extend(yhat.tolist())\n”,

        ”        i=i+1\n”,

        ”    else:\n”,

        ”        x_input = x_input.reshape((1, n_steps,1))\n”,

        ”        yhat = model.predict(x_input, verbose=0)\n”,

        ”        print(yhat[0])\n”,

        ”        temp_input.extend(yhat[0].tolist())\n”,

        ”        print(len(temp_input))\n”,

        ”        lst_output.extend(yhat.tolist())\n”,

        ”        i=i+1\n”,

        ”    \n”,

        “\n”,

        “print(lst_output)”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “id”: “rCMFGynBFhHZ”

      },

      “outputs”: [],

      “source”: [

        “day_new=np.arange(1,101)\n”,

        “day_pred=np.arange(101,131)”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “id”: “u-3aeyzSFhHZ”

      },

      “outputs”: [],

      “source”: [

        “import matplotlib.pyplot as plt”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “id”: “xr-GXodRFhHZ”,

        “outputId”: “c68b7ce2-b48c-4975-8ad7-8d919e3f1543”

      },

      “outputs”: [

        {

          “data”: {

            “text/plain”: [

              “1258”

            ]

          },

          “execution_count”: 391,

          “metadata”: {},

          “output_type”: “execute_result”

        }

      ],

      “source”: [

        “len(df1)”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “id”: “bSHOMHMlFhHZ”

      },

      “outputs”: [],

      “source”: [

        “”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “id”: “HE1LZ8bdFhHZ”,

        “outputId”: “298538a8-fd73-456c-ca8f-b65dc5707c93”

      },

      “outputs”: [

        {

          “data”: {

            “text/plain”: [

              “[<matplotlib.lines.Line2D at 0x2d1b0f352b0>]”

            ]

          },

          “execution_count”: 444,

          “metadata”: {},

          “output_type”: “execute_result”

        },

        {

          “data”: {

            “image/png”: “”,

            “text/plain”: [

              “<Figure size 432×288 with 1 Axes>”

            ]

          },

          “metadata”: {

            “needs_background”: “light”

          },

          “output_type”: “display_data”

        }

      ],

      “source”: [

        “plt.plot(day_new,scaler.inverse_transform(df1[1158:]))\n”,

        “plt.plot(day_pred,scaler.inverse_transform(lst_output))”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “id”: “FURarpoqFhHa”,

        “outputId”: “596cbaff-e30c-4acd-955f-86a98793d303”

      },

      “outputs”: [

        {

          “data”: {

            “text/plain”: [

              “[<matplotlib.lines.Line2D at 0x2d1b0f55ac8>]”

            ]

          },

          “execution_count”: 446,

          “metadata”: {},

          “output_type”: “execute_result”

        },

        {

          “data”: {

            “image/png”: “”,

            “text/plain”: [

              “<Figure size 432×288 with 1 Axes>”

            ]

          },

          “metadata”: {

            “needs_background”: “light”

          },

          “output_type”: “display_data”

        }

      ],

      “source”: [

        “df3=df1.tolist()\n”,

        “df3.extend(lst_output)\n”,

        “plt.plot(df3[1200:])”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “id”: “XmAQQIBRFhHa”

      },

      “outputs”: [],

      “source”: [

        “df3=scaler.inverse_transform(df3).tolist()”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “id”: “ai7LK3BOFhHa”,

        “outputId”: “d101b8dd-e045-4e4c-fafa-47418bbf55b8”

      },

      “outputs”: [

        {

          “data”: {

            “text/plain”: [

              “[<matplotlib.lines.Line2D at 0x2d1a904c470>]”

            ]

          },

          “execution_count”: 396,

          “metadata”: {},

          “output_type”: “execute_result”

        },

        {

          “data”: {

            “image/png”: “”,

            “text/plain”: [

              “<Figure size 432×288 with 1 Axes>”

            ]

          },

          “metadata”: {

            “needs_background”: “light”

          },

          “output_type”: “display_data”

        }

      ],

      “source”: [

        “plt.plot(df3)”

      ]

    },

    {

      “cell_type”: “code”,

      “execution_count”: null,

      “metadata”: {

        “id”: “TAs1gSN7FhHa”

      },

      “outputs”: [],

      “source”: [

        “”

      ]

    }

  ],

  “metadata”: {

    “kernelspec”: {

      “display_name”: “Python 3”,

      “language”: “python”,

      “name”: “python3”

    },

    “language_info”: {

      “codemirror_mode”: {

        “name”: “ipython”,

        “version”: 3

      },

      “file_extension”: “.py”,

      “mimetype”: “text/x-python”,

      “name”: “python”,

      “nbconvert_exporter”: “python”,

      “pygments_lexer”: “ipython3”,

      “version”: “3.6.9”

    },

    “colab”: {

      “name”: “Updated_Solution_Project2_Paper.ipynb”,

      “provenance”: []

    }

  },

  “nbformat”: 4,

  “nbformat_minor”: 0

}


[1] Hopman [24] computes the supply/demand imbalance based on limit orders and trades, but not cancelations.

[2] Note that in our case all order book events have the same average impact, equal to βi, regardless of their type. As shown in [12], average impacts of different event types are empirically very similar, allowing to reasonably approximate them with a single number.

[3] We note that OFIk includes the contributions of price-changing order book events, leading to a possible tautology in the regression (4). This problem is inherent to all price impact modeling, because the explanatory variables (events or trades) can directly cause price changes. To test that the high R2 in our regressions is not due to this tautology, we estimated (4) on a subsample of stocks, excluding the price-changing events from OFIk. With this change the R2 declined, but remained in the 35%-60% region.

[4] βˆi2var[OFIk]i was computed from the average patterns of βˆi and var[OFIk]i

[5] The stocks tickers were BDX, CB, MHS, PHM and PKI. We computed price changes for L = 2,5,10 trades to mitigate the possible issues with trade and quote alignment in the TAQ data and we correspondingly computed order flow imbalances and trade imbalances during the time intervals between 2, 5 or 10 consecutive trades. To ensure that there is an ample amount of data for each regression, we pooled data across days for each stock and each time interval.

Share this post

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on whatsapp
WhatsApp

Related posts

Keep in touch with the trends