AlgoB – Cryptocurrency price prediction system using LSTM
Shreyas Ingle, Naman Kumar, Vinay Bichave, Vishwadish DesaleStudent, Dept. of Information Technology, Atharva
College
of Engineering Student, Dept. of Information Technology, Atharva College of Engineering Student, Dept. of Information Technology, Atharva College of Engineering Student, Dept. of Information Technology, Atharva College of Engineering
Abstract - With the increased availability of mobile devices and personal computers to all the people around the world, trading in stocks and cryptocurrency has become much easier than it was a decade ago. But a lot of people don’t have much knowledge on how to trade, they don’t know when it is the right to buy a cryptocurrency and when they should sell it. As a result, a lot of people lose money while trading and they stop doing it completely. But if you know how to trade then there’s a lot of money which can be made doing this.
Predicting the accurate cryptocurrency price has been the aim of investors since forever, Billions of dollars of trading happens every single day, and every trader hopes to earn profit from his/her investments. Once an automated price prediction system is developed, investors can take a slightly hands-off approach to trading as they won’t need to invest a lot of their time in deciding when to buy or sell. Cryptocurrency prices could be accurately predicted using the LSTM (Long ShortTerm Memory) model.
Key Words: Trading, Stocks, Cryptocurrency, Prediction, Price Prediction System.
1.INTRODUCTION
A Price prediction system uses an algorithm to analyse a cryptocurrency based on its demand, whitepaper, tokenomics,people’sopinionaboutthecryptocurrencyand currentmarkettrendsandonceanalyseditusesthepatterns and trends identified to predict the future price of the cryptocurrency.
Thecomputerprogramwillpredictthefuturepricebasedon technical analysis, advanced statistical and mathematical computations,orinputfrom other electronicsources.The algorithmwillalsotaketheinputofpreviouspricechanges and trends and extract useful data from it. Once the predictionsystemisdeveloped,investorscantakeaslightly morehands-offapproach,astheywon’tneedtoinvestalot oftheirtimeindecidingwhentobuyorsell.
InthefieldofAI(ArtificialIntelligence),MachineLearningis atypeofAIthatcanforecastfuturepricesbyanalysingand identifyingpatternsinthepresentandpastdata.Research has shown that the model-based forecasting models have manyadvantagesascomparedtootherforecastingmodels. Thelong-termpricepredictionachievesbetterresultthan theshort-termonebothinMLPandRNN. Long-termprice
prediction shows high accuracy in cryptocurrency price predictionwithresultofaccuracyinrange of60-80% [2] They can produce results that are nearly the same as the actual results thereby improving upon the accuracy and precision of the models. Due to the volatility of cryptocurrencyprices,predictingthemisextremelydifficult andtime-consuming.
1.1 Need
Tradingincryptocurrencyissomethingthateveryonefrom young to old generation wants to try . In recent times as people have realized that the stock and cryptocurrency tradinghasgiventhemostROIascomparedtootherformsof investment.Butalotofpeopleareunawareofhowtoexactly makesenseofthedifferentfactorsthatinfluencethepriceof acryptocurrencyandhencetheylosemoney.
Price Prediction system using deep learning helps you discover the future value of cryptocurrency and other financialassetstradedonanexchange.Theentireideaofa predictionsystemistogainsignificantprofitsandthissystem helpsachieveyourgoals.
Humans cannot predict cryptocurrency prices with high accuracysincethereisamultitudeoffactorsresponsiblefor changesinprice.Factorsinvolvedintheprediction,suchas physical and psychological factors, rational and irrational behavior, current trends and so on combine to make cryptocurrencypricesdynamicandvolatile.Andweallknow that the crypto market is especially known for its high volatility.Ahumancannotpossiblyinterpretallthesefactors buta pricepredictionsystemcanmakeanaccuratefuture pricepredictionbycombiningallthesefactors.
1.2 Scope
This prediction system can be used by average and new tradersaliketohelpthemunderstandhowthemarketworks andrespondstodifferentnewsandcanalsohelpthemearn money without investing much of their time in manual predictions using the indicators provided by different trading platforms. This system isn’t only applicable to cryptocurrency but also to stocks by making just some minimal changes like using a different API (Application ProgrammingInterface)tofetchcurrentpricesandmaking somechangestotheparameters.
Thispredictionsystemensuresanon-emotionalprediction of price. Time is money and when it comes to price prediction,manualpredictionstakealotoftimeandeven thentheyarenotaccurateastheyarepronetohumanerrors andemotions.Thecryptocurrencymarketishighlyvolatile, which is why a prudent trading strategy should include a correctpredictionofprices,andonewaytoensurethatisto run and implement this price prediction system. This predictionsystemeffectivelycapturesthechangingmarket conditionsandcanincorporatethatinrealtimetoprovide accurate predictions. The accurate prediction of cryptocurrency price movement will lead to more profit investorscanmake.
2. SOFTWARE REQUIREMENT SPECIFICATION
Thepricepredictionmodelwillbasicallytakethetime-series sequenceofpastpricesofacryptocurrencyandprovideitas aninputtotheLSTMmodel.LSTMwillthenextractfeatures fromthissequenceanddecidewhichinformationtostorein its cell state which is a long term memory of LSTM. This storedinformationwillthenbeusedbythemodeltomake future predictions and it can also be updated at regular intervalstoimprovethemodel’saccuracy.
The model will provide its predictions to the user within secondsandalsoplotthispredictiononchartstoincreaseits interpretability.Theinputparametersaretheintegervalues of prices of cryptocurrency from past days to the current day,LSTMLayers,EpochandDropoutValue.Onthebasisof thatinformationourmodelwillpredicttheoutcome.Itwill do the operation on the values present in the dataset and predictthecurrentdayorthefuturedaypredictionwith7580%accuracy.
The quality attributes of the model include - Availability : Theusershouldbeabletoperformthepredictionsatany timetheywant,Correctness:Thepredictionsmademustbe ofhighaccuracyandUsability:Themodelshouldbeeasyto useandsatisfyamaximumnumberofuser’sneeds.
3. REQUIREMENT ANALYSIS
Thearchitecturalanddesignrequirementsfortheprediction modelareLabellingtheXandYaxisofthechartaccurately, Providingtheabilitytozoominandoutofthechart,anda save buttonto save the prediction price chart. Thesystem andintegrationrequirementsincludePredictionshouldtime asminimaltimeaspossibleandshouldbecomputationally efficientandthedatatransferfromandtotheAPIshouldbe encrypted.
3.1 Software Used
The software technology used for implementing the prediction model are NumPy, Pandas, TensorFlow and Matplotlib.
Table -1: Softwareused
NumPy It guarantees efficient calculations with arraysandmatrices.
Pandas Pandasismainlyusedfordataanalysisand associatedmanipulationoftabulardatain DataFrames.
Matplotlib Itisadatavisualizationandplottinglibrary forPython.
TensorFlow TensorFlow is an open-source library which is used for deep learning applications.
Sklearn This library contains efficient tools for machinelearning(ML).
Pickletools Helps in shrinking the size and faster loadingofPicklefiles.
BinanceAPI Itisafunctionwhichallows toconnectto the Binance servers via Python allowing youtoautomateyourtrading.
VSCode It is an Integrated Development Environment(IDE).
4. METHODOLOGY
Get the dataset from the Yahoo Finance API to train the model for a particular asset. Implement the LSTM model Algorithm.GettheclientAPIkeyandclientsecretkey.Then useittoretrievedatafromtheYahooFinanceAPI.Usethe historyofsomehoursordaysthenusethemodeltopredict thefuture,oncefinished,outputthepredictedpriceinthe formofachart.
LSTMisatypeofRecurrentNeuralNetwork.RNNbasically stores previous output as input and then predicts output basedonit.Itgivesveryaccuratepredictionsworkingwith Shorttermmemory,butforlongterm,it’snotthatefficient. To avoid this long-term dependency of RNN, LSTM was createdwhichbydefaultcanretaininformationdataintoits memory.
LSTMisspecificallydesignedtoworkonsequentialdata,like time-series, speech and text. It is capable of learning long termdependenciesofsequentialdatawhichmakesitideal forspeechrecognitionandtime-seriespredictions.RNNhasa single hidden state which is passed through time, which makes it difficult to use for long-term dependencies. To efficiently solve this problem, LSTM has introduced a memory cell that can hold onto information for a longer periodoftime.
Memory cell in LSTM has three gates that decide what informationneedstobeadded,removedorgiveoutput.The
threegatesare:TheInputGatecontrolswhatinformation needstobeaddedinsidethememorycell.Theinformationis regulatedusingSigmoidfunctionandfilterthevaluestobe stored.Itisdonebyusingtwoinputs‘A’(inputatparticular time)and‘B’(previouscelloutput).Then,avectoriscreated whichgivesanoutputfrom-1to+1,whichcontainsallthe values from ‘A’ to ‘B’, The Forget Gate which removes the informationthatis nolongerrequired.Again,wetaketwo inputs‘A’and‘B’thatarefedtothegateandmultipliedwith theweightmatricesfollowedbyadditionbias.Theresultis then passed through an activation function which gives a binaryoutput.Iftheoutputis0foracell,theninformationis forgotten, if it is 1 then information is retained and The Output Gate which extracts the useful information from current cell state to be used as output. It is done slightly differentthantheinputgatewhereVectorwascreatedlater, here first a vector is created using tan function using the Sigmoidfunctionandfilterthevaluesby‘A’and‘B’.Atthe end,thevaluesaremultipliedtobesentasoutputandInput inthenextcell
4.1 Training the model
WeretrievethedatasetfromYahooFinanceAPIagainstthe USDollars,weevenspecifyatimeframetohaveastartand an endpoint. We create a min-max scalar with the feature rangeof0and1tofitthedatainit.Thenfitthedatainthe scalar transform then we specify prediction days then we reshapethedataasperrequired. Thenwecreateaneural network using Sequential Model. Create the Sequential ModelandthenweaddLSTMlayers(i.e.LongShort-Term Memory Layers) and then Dropout layers, we have used LSTMlayersbecausetheselayersarepowerfulandtheycan memorizeimportantinformationandfeeddatabackintoa neuralnetwork.Wepreventtheoverfittingofthenetwork byusingDropoutlayersthenwecompilethemodel(Train theModel).
4.2 Evaluation of the model
Theinputparametersaretheintegervaluesofpricesof cryptocurrency from past days to the current day, LSTM Layers,DropoutValueandEpoch Epochsarethenumberof times the algorithm will work through the training set Dropout reduces overfitting and improves model performance A very high dropout rate will slow the convergencerateofthemodel,andruinfinalperformance. Too low a rate may yield few or no improvements on generalizationperformance.Ideallythedropoutratesshould besetseparatelyforeachlayerandalsoduringtheseveral trainingstages.MoreLSTMlayersmaybebetteroverallbut alsohardertotrain Thenumberoflayerschosendepends upon the complexity of the dataset, the data generating process, and the accuracy required for the use case. The numberofmemorycellswilldependonthenumberoflayers
Ifthegoalistobeatthebestmodel,ingeneral,youwillneed
moreLSTMcells.However,ifthegoalisofcomingupwitha reasonableprediction,then,fewerLSTMcellswillbeneeded.
Onthebasisoftheseparametersourmodelwillpredictthe outcome.Itwilldotheoperationonthevaluespresentinthe dataset and predict the current day or the future day prediction with 75-80% accuracy. The model is evaluated against the prices in real time to predict the accuracy. By doingthisithelpsthetraderstogetthecurrentpositionof thatparticularcryptofortrade.
REFERENCES
[1] A. -A. Encean and D. Zinca, "Cryptocurrency Price Prediction Using LSTM and GRU Networks," 2022 International Symposium on Electronics and Telecommunications (ISETC), Timisoara, Romania, 2022,pp.1-4,doi:10.1109/ISETC56213.2022.10010329.
[2] R.AlbariqiandE.Winarko,“Predictionofbitcoinprice change using neural networks,” in 2020 International Conference on Smart Technology and Applications (ICoSTA),2020,pp.1–4.
[3] D. Mahayana, E. Shan, and M. Fadhl’Abbas, “Deep Reinforcement Learning to Automate Cryptocurrency Trading,” IEEE Xplore, Oct. 01, 2022. https://ieeexplore.ieee.org/document/10010940 (accessedMar.29,2023).
[4] A.N.Sihananto,A.P.Sari,M.E.Prasetyo,M.Y.Fitroni,W. N.Gultom,andH.E.Wahanani,“ReinforcementLearning for Automatic Cryptocurrency Trading,” IEEE Xplore, Oct.01,2022.https://ieeexplore.ieee.org/document/100 10206(accessedMar.29,2023).
– 4 : BNBPricepredictionchart
5. CONCLUSION
Thepredictionsystemthatwehavebuiltnotonlypredicts thefuturepriceofacryptocurrencybutitalsodoesitwitha highaccuracy.Ourmodelisabletoachievesuchresultsby employingtheuse ofLong-Short TermMemoryNetworks whichareaspecialtypeofRecurrentNeuralNetworksince rememberinginformationforalongperiodoftimeistheir specialtyandnotsomethingtheystrugglewith.Thedropout valueandLSTMlayersbothparametershavebeensetsuch thatthemodelgiveanaccuratepredictionwhileconsuming minimum computing resources and time. The final predictions are represented graphically using matplotlib libraryofpythontofurtherincreasetheinterpretabilityof thepredictionmade.
Whencomparedwithmodelswhichemployregressionsand trees models whose accuracy is about 50% our model achievesamuchbetteraccuracyofaround80%.
ACKNOWLEDGEMENT
Wewouldliketoexpressourspecialthankstoourproject guideandMajorprojectcoordinatorProf.AmrutaSankhefor hertimeandtheeffortssheprovidedthroughouttheyear. Your advice and suggestions were really supportive to us duringtheproject’scompletion.Inthisaspect,wearereally gratefultoyou.
[5] Q. Wang, “Cryptocurrencies asset pricing via machine learning: Extended abstract,” in 2020 IEEE 7th InternationalConferenceonDataScienceandAdvanced Analytics(DSAA),2020,pp.789–790.
[6] F.Atlan,I.Pence,andM.S.Cesmeli,“Onlinefiyattahmin modeli online price forecasting model using artificial intelligence for cryptocurrencies as bitcoin, ethereum and ripple,” in 2020 28th Signal Processing and CommunicationsApplicationsConference(SIU),2020, pp.1–4.
[7] F. Sabry, W. Labda, A. Erbad, and Q. Malluhi, “CryptocurrenciesandArtificialIntelligence:Challenges and Opportunities,” IEEE Access, vol. 8, pp. 175840–175858,2020.
[8] M.WimalagunaratneandG.Poravi,“Apredictivemodel for the global cryptocurrency market: A holistic approachtopredictingcryptocurrencyprices,”in2018 8th International Conference on Intelligent Systems, ModellingandSimulation(ISMS),2018,pp.78–83.