Validating and Configuring Your Trading Strategy

Check out our latest article that guides you through the essential steps of validating and configuring your trading strategy with AlgoBulls' Python Build.?

Validating and Configuring Your Trading Strategy

If you've ever tried creating a Python-based trading strategy, you know it can be a bumpy ride. Sometimes, things just don't go as planned. But worry not, because in this blog post, we're going to take you through the essential steps of validating and configuring your trading strategy using AlgoBulls’ Python Build.

Create Alpaca Account

It is very easy to create an account with Alpaca. Visit the Alpaca website to sign up for your Alpaca Account. Once the account is created, you are ready to bind your broker with AlgoBulls.

Setting up your Broker for US Markets

To start algorithmic trading for US market instruments, we need to first set up our broker details in your AlgoBulls Account. This process can be completed using the OAuth method:

For this, log in to your AlgoBulls account and select the “Broking Details” option from the navigation bar on the left-hand side. There you will find the feature to “Add Broker”. On clicking that button, a pop-up will appear where you should search for the broker “Alpaca”.

Select the option you want and click on “Next”. This will redirect you to the Alpaca website for authorisation. Click on “Allow” to establish a connection with your Alpaca Account’s APIs.

Configuration Parameters

Now, let's refine your strategy with ease by configuring its parameters. Whether you want to set limits on order counts, toggle between delivery and intraday modes, or explore additional features, the best part is that you won't need to explicitly handle any of these in your strategy code. Everything you need is readily available when you create a strategy using the AlgoBulls Python Build approach, making the entire process seamless and user-friendly.

Let's break it down into sections:

Instruments:

Select the segment (NASDAQ, NYSE, NSE, etc.) and instruments you want your strategy to work on. You can choose a single or multiple instruments from a chosen segment.

Strategy Settings:

We can select the candle size here. Here, candle size is the duration for which we extract the  Open-High-Low-Close data. It can also be interpreted as the frequency at which you will execute the strategy algorithms and functions. Candle sizes are available from 1-minute to 1-day. In this section, you can also pick between intraday and delivery modes. Intraday trading means buying and selling stocks on the same day while for delivery, you can hold the stocks for a longer duration of time.

Order Settings:

Now, let's dive into the Order Settings, where you have the power to adjust how your orders behave in crucial scenarios like when your strategy is 'Resumed' or 'Exited' and more. This section allows for precise customization, giving you control over your strategy's actions and risk management. Here's a breakdown of the parameters you can tweak:

Resume Positions from Start:

  • This option is your strategy's best friend when you're in DELIVERY mode and already have existing positions. It lets you continue your strategy without wiping out or overwriting any previous trades.
  • Recommended to keep this unchecked.

Exit Intraday Orders on Stop:

  • Designed for intraday trading enthusiasts, enabling this option ensures that your strategy automatically closes or squares off positions at the end of each trading day. It streamlines your intraday operations.
  • It is recommended that it should be kept checked

Max Order Count:

  • Set the maximum number of orders your strategy can execute per day with this parameter. Once this limit is reached, any new BUY or SELL signals generated by your strategy will be automatically ignored for the remainder of the day.
  • The default value given here is 100, but you can adjust that according to your needs

Crossover Accuracy Decimal:

  • This setting steps into the spotlight when you're running a crossover strategy. It defines how many decimal places the system considers when deciding whether to execute an upward cut, a downward cut, or no cut based on the underlying indicators.
  • The suggested value is 2, since the stock’s historical data which is received is also generally till two decimal places.

Credit Exposure Factor:

  • Specifically crafted for Live Trading, this parameter empowers you to set an exposure limit provided by your broker. The system calculates the available funds as the 'current fund balance multiplied by the credit exposure factor' for executing the strategy. It's a key player in managing your risk exposure.
  • Default setting is 1, but can be changed according to your need. Note, this factor has no effect for Backtesting or Paper Trading i.e. it is always taken as 1.

These settings are your toolkit for tailoring your trading strategy's behaviour and risk management according to your unique preferences and requirements. So, go ahead, explore, and fine-tune your strategy to match your trading style!

User Parameters:

In the final phase, update the user parameters in your Python code's constructor method (__init__ method). Check that the values in "strategy_parameters" align with your desired User Parameters. This flexibility simplifies adjustments without constant code modifications.

Like in the above figure, the strategy parameter dictionary has its values stored in the following keys: ”TIME_PERIOD”, “OVERBOUGHT_VALUE” and “OVERSOLD_VALUE”.

Now to give these keys their values, we need to add them inside the “User Parameter” section. Simply click “Add New Parameter” and in the left-side input box, type the name of that parameter and on the right-side input box type its value.

Remember to save your configurations before moving ahead.

Executing the Strategy

With your strategy finely tuned and validated, it's time to put it to work. Here's how it goes:

  • Click "Save & Start," opening the execution modal.
  • In the modal, set the start and end times for your strategy, define the quantity of instruments, and choose between Live Trading, Backtesting, or Paper Trading.
  • If you are running for Backtesting or Paper Trading, you can define the initial virtual funds in the AlgoBulls Virtual Broker. For Live Trading this value will be taken from your underlying broker.
  • Review your "Strategy Configurations" to ensure everything's in order.
  • Finally, hit the "Execute" button, and you're off to the trading races!

In Conclusion: Your Path to Success

Congratulations, you've made it through the process of validating and configuring your trading strategy with Python Build. It's a journey that might seem intricate, but it's designed to optimise your trading operations, save you time, and enhance your trading experience.

If this is the first blog post you are reading related to Python Build, we recommend you to start reading the first blog post of this series “Exploring Trading Strategies with AlgoBulls' Python Build” for better understanding of Python Build and seamless algorithmic trading.

We're thrilled about the potential of your strategies, and we hope you are too. Our platform is here to empower traders like you, supercharging your trading strategies. If you have any questions or want to explore our platform's features further, please reach out to us.

Thank you for choosing to embark on this journey with us. Here's to a future filled with successful and profitable trading endeavours!


Options trading is not suitable for all investors due to its inherent high risk, which can potentially result in significant losses. Please read Characteristics and Risks of Standardized Options before investing in options.

Alpaca Securities LLC and AlgoBulls are not affiliated and neither are responsible for the liabilities of the other.

Please note that this article is for educational and informational purposes only. All screenshots are for illustrative purposes only. The views and opinions expressed are those of the author and do not reflect or represent the views and opinions of Alpaca. Alpaca does not recommend any specific securities or investment strategies.

Alpaca does not prepare, edit, or endorse Third Party Content. Alpaca does not guarantee the accuracy, timeliness, completeness or usefulness of Third Party Content, and is not responsible or liable for any content, advertising, products, or other materials on or available from third party sites.

Securities brokerage services are provided by Alpaca Securities LLC ("Alpaca Securities"), member FINRA/SIPC, a wholly-owned subsidiary of AlpacaDB, Inc. Technology and services are offered by AlpacaDB, Inc.

This is not an offer, solicitation of an offer, or advice to buy or sell securities or open a brokerage account in any jurisdiction where Alpaca Securities are not registered or licensed, as applicable.

All investments involve risk and the past performance of a security, or financial product does not guarantee future results or returns. There is no guarantee that any investment strategy will achieve its objectives. Please note that diversification does not assure a profit, or protect against loss. There is always the potential of losing money when you invest in securities, or other financial products. Investors should consider their investment objectives and risks carefully before investing.

The Paper Trading API is offered by AlpacaDB, Inc. and does not require real money or permit a user to transact in real securities in the market. Providing use of the Paper Trading API is not an offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, given or in any manner endorsed by AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate and the information made available through Paper Trading is not an offer or solicitation of any kind in any jurisdiction where AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate is not authorized to do business.