Training with command line parameters

Posted By: ChaosTrader

Training with command line parameters - 11/13/23 11:59

Hi,
I want to train a script with different end dates by using a batch file and passing through the Enddate as a -i parameter. In the script, I replaced the end date value with Command[0].
Training is getting startet, but obviously the script sets the Endate to 0 instead of using the passed value of e.g. 20230930. For -run it is working perfectly as expected and the passed dates are being used. I feel that at the point where the training starts, the passed parameters are not yet initialized.
I am using Version 2.56 with S License.

It is a known bug or did I miss something in the script/batch?

Best regards,
CT
Posted By: AndrewAMD

Re: Training with command line parameters - 11/13/23 12:15

Use -u string instead so that you can manually set values inside the script. Happy parsing!

Edit: Also, -i number if you're only using numbers, so no parsing needed.
Posted By: TipmyPip

Re: Training with command line parameters - 11/26/23 08:42

The issue you're encountering, where the Command[0] parameter seems to be set to 0 instead of the passed value when training a script, might be related to the way command-line parameters are handled in Zorro, especially in different modes (like training versus running).

In Zorro, command-line parameters are accessible through the Command array in the script. However, there are some nuances to be aware of:

Initialization Timing: The command-line parameters are usually parsed and initialized before the run function is executed. However, if you're observing that the parameters are not correctly initialized during training, it could be a timing or initialization issue specific to the training mode.

Correct Parameter Index: Ensure that you're using the correct index for accessing the command-line parameters. Command[0] is the first command-line parameter, Command[1] is the second, and so on.

Parameter Parsing: Check if the command-line parameter is correctly parsed and converted to the desired data type. For instance, if you're passing a date like 20230930, you might need to convert it from a string to an integer or a specific date format that Zorro understands.

Batch File Syntax: Ensure the batch file is correctly formatted and passing the parameters as intended. The command should look something like this:

Code
Zorro.exe -run MyScript -i 20230930


Zorro Version: You mentioned using Zorro version 2.56 with an S License. It's worth checking the release notes or updates for your version to see if there are any known bugs or changes regarding command-line parameter handling.

Debugging: Use print statements to debug the script. Print out the value of Command[0] at different points in your script to check when it gets initialized and what value it holds.

Alternative Approach: As a workaround, you could try using a different method to pass the end date. For example, you could read the end date from a file at the start of your script if the direct command-line approach continues to pose issues.
© 2024 lite-C Forums