Skip to content

Upload your Strategy


Previously...

You have created a strategy by:

  • Coding the complete strategy from the Create page.

OR


Now...

You are now ready to upload your strategy into your AlgoBulls account for Backtesting, Paper Trading and/or Real Trading.


Before you start...

  • Make sure you have an active working AlgoBulls account ready to go!
  • Open a Jupyter Notebook.
  • If you have coded the strategy yourself and not used a ready strategy from the pyalgostrategypool package, then make sure your strategy file (.py) and the Jupyter Notebook are in the same folder.

Let's Start...

Run the following code snippets into the Jupyter Notebook one by one (or all together).


Import statements

import inspect
from pyalgotrading.algobulls import AlgoBullsConnection

  • Import a ready strategy

    from pyalgostrategypool.strategy_ema_regular_order import StrategyEMARegularOrder
    

  • Import your own strategy

    from strategy_sma_regular_order import StrategySMARegularOrder
    


Establish a connection to the AlgoBulls Platform

algobulls_connection = AlgoBullsConnection()
algobulls_connection.get_authorization_url()
The output of the above step is:

Please login to this URL with your AlgoBulls credentials and get your developer access token: https://app.algobulls.com/user/login

Get Developer Key

You will need to log in to your AlgoBulls account and fetch the access token from: (See How)
Settings -> General -> Developer Options

Once you have the access token, set it in the code as shown here:

algobulls_connection.set_access_token('4365817b795770ea31040a21ad29c8e78b63ad88')
Replace the token you have copied with the token in the code above.


You can print your strategy code once to verify if this is the correct code before uploading it to the platform. This step is optional.

print(inspect.getsource(StrategySMARegularOrder))


Upload your Strategy

Upload your strategy as shown in the code below.

algobulls_connection.create_strategy(StrategySMARegularOrder)


Re-upload your Strategy after modifications

If you are re-uploading your strategy after some changes, then use the overwrite switch as shown here.

algobulls_connection.create_strategy(StrategySMARegularOrder, overwrite=True)


What's Next...

You are now ready to test your uploaded strategy and perform Backtesting, Paper Trading and/or Real Trading with it.



Last update: 2024-08-03