Comment
Author: Admin | 2025-04-27
Application is set up, creating an instance of the Flask class which is our WSGI application. The API key for accessing the CoinGecko API, a comprehensive cryptocurrency API that provides access to a wide range of data, is defined. Defining the Main Route: The main route (/) is defined, which supports both GET and POST methods. When a GET request is made, it fetches the list of available coins from the CoinGecko API. This is done by making a GET request to the CoinGecko API endpoint, which returns a list of all available cryptocurrencies. Handling POST Requests: If a POST request is made, it gets the coin_id and days from the form data. If the coin_id is valid, it calls the get_market_chart function with coin_id and days as parameters. This function fetches the market chart data for the given coin over the specified number of days. Defining the get_market_chart Function: This function does several things, namely, it calculates the start and end timestamps based on the number of days, fetches the OHLC (Open, High, Low, Close) data for the given coin_id and days, and fetches the historical data for a specific date and the current market data from the CoinGecko API. Next, it prepares the feature matrix X and target vector y for the linear regression model, and scales the data using MinMaxScaler, a feature scaling technique that transforms features by scaling each feature to a given range. Thereafter, it trains the LinearRegression model with X and y and makes
Add Comment