Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Algorithm Exception Handler #8239

Open
4 tasks done
AlexCatarino opened this issue Aug 1, 2024 · 4 comments
Open
4 tasks done

Adds Algorithm Exception Handler #8239

AlexCatarino opened this issue Aug 1, 2024 · 4 comments
Labels

Comments

@AlexCatarino
Copy link
Member

Expected Behavior

Be able to take action when a runtime exception is raised.

Actual Behavior

If a runtime error occurs, we cannot take actions such as close positions and open orders.

Potential Solution

Add IAlgorithm.OnError method.

Reproducing the Problem

from AlgorithmImports import *
class FormalFluorescentYellowPenguin(QCAlgorithm):
    def initialize(self):
        self.set_start_date(2024, 6, 30)
        self.add_crypto("BTCUSD")
    def on_data(self, data):
        x=1/0
    def on_end_of_algorithm(self):
        self.liquidate()

In this case, on_end_of_algorithm is not called, so we cannot close positions and open orders if we want to.

Checklist

  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue
@keshavdalmia10
Copy link
Contributor

Hi @AlexCatarino, @Martin-Molinero I have raised the pull request for this issue.

@AlexCatarino
Copy link
Member Author

Hi @keshavdalmia10,
Before you work on an issue, I suggest adding comments to show that you understand what needs to be done and what you will do, then wait for feedback.
When someone (e.g. me) opens a GitHub issue for a feature request, they may not know what needs to be done or the best way to do it.

By the way, your #8266 doesn't have a unit and/or a regression test to show it solves the issue.

@keshavdalmia10
Copy link
Contributor

Hi @keshavdalmia10, Before you work on an issue, I suggest adding comments to show that you understand what needs to be done and what you will do, then wait for feedback. When someone (e.g. me) opens a GitHub issue for a feature request, they may not know what needs to be done or the best way to do it.

By the way, your #8266 doesn't have a unit and/or a regression test to show it solves the issue.

I had pinged you on Discord for it.

@keshavdalmia10
Copy link
Contributor

Hi @Martin-Molinero , can you guide a little over here on how to make the test case for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants