Learn how to use TimeGPT for financial time series forecasting with Bitcoin price and market data.

Introduction

Forecasting time series is a foundational task in finance, supporting decisions for trading, risk management, and strategic planning. However, predicting future asset prices can be complicated due to market volatility. TimeGPT helps streamline this process by providing robust forecasting capabilities for professionals who need accurate financial predictions.

This guide demonstrates Bitcoin price prediction using TimeGPT, including uncertainty quantification for risk management and informed decision-making.

Why Forecast Bitcoin Prices

Bitcoin is the first decentralized digital currency, recorded on a public ledger known as the blockchain. It is widely traded, and its price is highly volatile, making accurate forecasting a valuable tool for financial analysis, trading strategies, and risk management.

What You'll Learn

• How to load and prepare Bitcoin price data
• How to generate short-term forecasts with TimeGPT
• How to visualize and interpret forecast results
• How to detect anomalies and add exogenous variables

The procedures in this tutorial apply to many financial asset forecasting scenarios, not just Bitcoin.

Tutorial Outline

1

Load Bitcoin Price Data

2

Get Started with TimeGPT

3

Visualize the Data

4

Forecast with TimeGPT

5

Extend Bitcoin Price Analysis with TimeGPT

6

Understand the Model Limitations

7

References and Additional Material


1. Load Bitcoin Price Data

Bitcoin (₿) is the first decentralized digital currency, with transactions recorded on a public ledger called the blockchain. Bitcoins are created through mining—solving cryptographic tasks—and are used for payments, trading, and long-term investment.

For convenience, we’ll rename columns to match TimeGPT’s expected ds (date) and y (target) format.

import pandas as pd

df = pd.read_csv(
    'https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/bitcoin_price_usd.csv',
    sep=','
)

df.head()

This dataset includes daily Bitcoin closing prices (in USD) from 2020-01-01 to 2023-12-31. While Bitcoin trades continuously, “closing price” here refers to a specific daily time rather than a traditional market close.

# Rename the columns for convenience
df.rename(columns={'Date': 'ds', 'Close': 'y'}, inplace=True)

2. Get Started with TimeGPT

Initialize the NixtlaClient with your Nixtla API key.

from nixtla import NixtlaClient

nixtla_client = NixtlaClient(
    api_key='my_api_key_provided_by_nixtla'
)

When using Azure AI, you must also specify base_url in the NixtlaClient.

from nixtla import NixtlaClient

nixtla_client = NixtlaClient(
api_key="my_api_key_provided_by_nixtla"
)

You can learn more about API keys in the Nixtla Authentication Guide.


3. Visualize the Data

TimeGPT’s client offers a convenient plot method to visualize your data:

nixtla_client.plot(df)

Bitcoin Price Data

If you did not rename the columns, specify them explicitly:

nixtla_client.plot(
    df,
    time_col='Date Column',
    target_col='Close Column'
)

4. Forecast with TimeGPT

Forecast the next 7 days using TimeGPT:

level = [50, 80, 90]

fcst = nixtla_client.forecast(
    df,
    h=7,
    level=level
)

fcst.head()

Visualize the forecast with historical data:

nixtla_client.plot(df, fcst, level=level)

Panel view of historical data with future forecasts


5. Extend Bitcoin Price Analysis with TimeGPT


6. Understand the Model Limitations

Forecasting financial assets, especially cryptocurrencies, is inherently challenging. High volatility and market sentiment can lead to rapid price swings that limit model reliability.

TimeGPT offers:
• Point forecasts
• Uncertainty quantification
• In-sample forecasting
• Anomaly detection
• Exogenous variable integration

However, it cannot guarantee future accuracy. For questions about advanced use cases, visit the
TimeGPT Documentation.


7. References and Additional Material

Pro Tip

Financial time series often exhibit random walk behavior, especially cryptocurrencies. Evaluate your models thoroughly with statistical metrics and domain knowledge to make informed decisions.

Congratulations! You have successfully learned how to forecast Bitcoin prices using TimeGPT. For more information and advanced configuration of open source alternatives, visit the
Nixtla Documentation.