Datasets

Alpha Vantage

Introduction

Instead of using the data from QuantConnect or your brokerage, you can use Alpha Vantage for historical data if you're deploying a local project. To use Alpha Vantage, you need to get a free or premium API key.

To view the implementation of the Alpha Vantage integration, see the Lean.DataSource.AlphaVantage repository.

Supported Datasets

Our Alpha Vantage integration supports US Equity securities.

Universe Selection

Universe Selection is available with the Alpha Vantage data provider if you download the data from the Dataset Market. The dataset listings show how to download the universe selection data with the CLI. For live trading, you'll need to periodically download the new data from QuantConnect Cloud, which you can automate with Python scripts. For example, the following tutorials explain how to download historical data and download daily updates:

Alternative Data

If you have licensed alternative data with QuantConnect, it works as expected with the Alpha Vantage data provider for research, backtesting, and live trading.

Research

To access Alpha Vantage data from the local Research Environment, open a terminal in your organization workspace and then run lean research <projectName> --data-provider-historical AlphaVantage --alpha-vantage-api-key <apiKey> --alpha-vantage-price-plan <pricePlan>.

$ lean research "My Project" --data-provider-historical AlphaVantage --alpha-vantage-api-key apiKey --alpha-vantage-price-plan Free

The --alpha-vantage-price-plan option must be one of the following values: Free, Plan30, Plan75, Plan150, Plan300, Plan600, or Plan1200. If you provide any of the preceding options, your Lean configuration file saves them so that you only need to run lean research <projectName> to open the Research Environment with the same options.

Backtesting

To run a local backtest with Alpha Vantage data, open a terminal in your organization workspace and then run lean backtest <projectName> --data-provider-historical AlphaVantage --alpha-vantage-api-key <apiKey> --alpha-vantage-price-plan <pricePlan>.

$ lean backtest "My Project" --data-provider-historical AlphaVantage --alpha-vantage-api-key apiKey --alpha-vantage-price-plan Free

The --alpha-vantage-price-plan option must be one of the following values: Free, Plan30, Plan75, Plan150, Plan300, Plan600, or Plan1200. If you provide any of the preceding options, your Lean configuration file saves them so that you only need to run lean backtest <projectName> to run another backtest with the same options.

Optimization

Follow these steps to run a local optimization job with Alpha Vantage data:

  1. Add some parameters to your project.
  2. Open a terminal in your organization workspace.
  3. Run lean optimize <projectName> --data-provider-historical AlphaVantage --alpha-vantage-api-key <apiKey> --alpha-vantage-price-plan <pricePlan>.
  4. $ lean optimize "My Project" --data-provider-historical AlphaVantage --alpha-vantage-api-key apiKey --alpha-vantage-price-plan Free

    The --alpha-vantage-price-plan option must be one of the following values: Free, Plan30, Plan75, Plan150, Plan300, Plan600, or Plan1200.

  5. Follow the steps in the interactive wizard to configure your optimization job settings.

The lean optimize command also accepts additional options so that you can select Alpha Vantage and run the command in non-interactive mode. If you provide any of the preceding options, your Lean configuration file saves them so that you only need to run lean optimize <projectName> to run another optimization job with the same options.

Live Trading

To deploy a local live algorithm that uses Alpha Vantage as the historical data provider, open a terminal in your organization workspace and then run lean live deploy <projectName> --data-provider-historical AlphaVantage --alpha-vantage-api-key <apiKey> --alpha-vantage-price-plan <pricePlan> --brokerage <brokerageName> <requiredBrokerageOptions>. Alpha Vantage doesn't support streaming live data. The paper trading brokerage also doesn't provide live data, so if you select it, you need to include --data-provider-live <liveDataProviderName> <requiredLivedataProviderOptions>.

$ lean live deploy "My Project" --data-provider-historical AlphaVantage --alpha-vantage-api-key apiKey --alpha-vantage-price-plan Free --brokerage "Paper Trading" --data-provider-live "Custom data only"

The --alpha-vantage-price-plan option must be one of the following values: Free, Plan30, Plan75, Plan150, Plan300, Plan600, or Plan1200. Depending on the brokerage you select, you may need to provide some additional required options. If you provide any of the preceding options, your Lean configuration file saves them so that you only need to run lean live deploy <projectName> --brokerage <brokerageName> to deploy another live algorithm with the same options.

Pricing

To view the prices of the Alpha Vantage API packages, see the Premium API Key page on the Alpha Vantage website.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: