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

Jesse strategy break point debugging in vscode. #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

qwpto
Copy link

@qwpto qwpto commented Jul 23, 2022

As a developer I'd be nowhere without breakpoint debugging, and I wanted to bring the other people I'm collaborating with up to speed on developing software so they needed this capability to learn how to write python. I'm using vscode to develop with Jesse. So I've forked the project-template and updated it to work automatically with vscode which means it will provide the user prompts to install docker, open in a container, etc. It also gives them a single button press to start debugging the code. It will work for both docker (in linux and windows) and with the jesse app natively in windows and linux.

Note: https://code.visualstudio.com/docs/containers/docker-compose
"In Python projects, you have the Dockerfile, .dockerignore, docker-compose*.yml files all in the root folder of the workspace. When you add another app or service, move the Dockerfile into the app's folder."

…docker/linux

It should be possible to add mac following the windows and linux patterns.

See also: https://code.visualstudio.com/docs/containers/docker-compose

"In Python projects, you have the Dockerfile, .dockerignore, docker-compose*.yml files all in the root folder of the workspace. When you add another app or service, move the Dockerfile into the app's folder."
remove duplicate .vscode, and add backtest-mode folder
@qwpto
Copy link
Author

qwpto commented Aug 7, 2022

The workflow is:

  • (OPTIONAL) follow the desired setup instructions for your jesse environment (you can skip this if you just want to use docker as vscode will prompt you through all the setup)
  • install vscode
  • Create a new strategy project from this template
  • open this new project in vscode as a folder
  • vscode will then prompt you through the remaining steps (eg opening the project in the dev-container, installing python, etc)

Once you're ready to debug a strategy:

  • open the file of the strategy in vscode
  • insert a break point by clicking in the left margin (near the line numbers)
  • navigate to the debugging tab as shown in the image (1)
  • choose your debugging environment as shown in the image (2) eg jesse docker debug
  • then just click play to start debugging as showing in the image (3)

you can inspect the program flow, variable values, and start experimenting with your strategy in the debug console against the candle data. oh and poke around at the internals of jesse if that's what you're into.

alt text
alt text
alt text

@qwpto
Copy link
Author

qwpto commented Aug 7, 2022

Worth noting for this one, it's really useful to edit the break point for a specific candle you're debugging eg:
datetime.utcfromtimestamp(self.time/1000).strftime('%Y-%m-%d %H:%M:%S') == '2021-07-20 02:47:00'
alt

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

Successfully merging this pull request may close these issues.

1 participant