New Strategy API endpoints

Good news for user who have wanted to automate the process of running simulations! Five new Strategy API endpoints have been added:

/strategy/{id}/rerun
Rerun a Simulated Strategy backtest.

/strategy/{id}/book-rerun
Rerun a book simulation.

/strategy/{id}/trading-system
Retrieve the current settings of a strategy/book trading system.

/strategy/{id}/trading-system
Update the trading system settings of a live strategy.

/strategy/{id}/book-trading-system
Update the trading system settings of a live book.

There are now a total of 12 endpoints related to Strategies and Books. See Swagger for the details: https://api.portfolio123.com/docs/index.html#/
These endpoints will be added to the documentation in the Knowledge base soon.

5 Likes

Dan are all of these in the P123 client.py wrapper?

I see it was last updated 7 months ago.

Thanks

Tony

Hi Tony,
I was not involved during the dev and test phase for those new Strategy endpoints, so I don't know the dates. But they are in the wrapper if you have installed the latest update (pip install --upgrade p123api).

1 Like

Dan, there appears to be no way to set the slippage with this endpoint.
Am I overlooking it?

Thanks

Tony

Hi Tony,
Unfortunately, slippage is not a configurable option in that endpoint. The endpoint was intentionally scoped to cover only the simulation settings where users typically need to test a large number of variations — slippage fell outside that subset.

1 Like

For the API to be really useful it must cover all settings that are available in P123 interface. What about PIT method?
Seems like the Swagger may not cover all options and some are hidden

The only Strategy API endpoint that accepts 'PIT Method' is POST /strategy/{id}/rebalance

If 'PIT Method' is specified for POST /strategy/{id}/rerun, it is ignored.

Thank you Walter.
I still don’t understand why we do not have access to all fields. This is a huge limitation to automate things.

These were design decisions. If there's demand for expanding the API request options, I think we would explore the task.

@Danp,, there may be a bug with this endpoint.
It works fine until I use a long running sim, maybe 30 min or longer, then it never returns a confirmation that the sim was complete, even though I can see that it completed on the website. It just keeps running until the timeout param is met, which I have set to: client.set_timeout(4200)

This is how I am calling the method:
rerun_result = client.strategy_rerun(strategy_id=STRATEGY_ID, params=params)

Where Params: {'startDt': '2000-01-01', 'endDt': '2026-05-01'}

I’m not sure how else to troubleshoot it on my end.

Thanks

Tony

@azouz110 I know at least one param is not mentioned in the docs that works: {'vendor': 'FactSet'}
There may be others.

Hi Tony. We are looking into this.