Validation

Local validation before submission (Optional)

Why Validate?

Before submitting your alpha model, it's highly recommended to use the validation feature. This step ensures that there are no issues with your model algorithm, as the submission process includes several validation checks.

  • Catch Errors Early: It allows you to identify and fix any issues with your algorithm beforehand, reducing the chances of submission rejection.

  • Understand the Process: By validating, you become more familiar with the submission checks. This knowledge helps you prepare your model better for the production environment.

  • Minimize Submission Errors: Validation helps reduce the likelihood of encountering errors due to discrepancies between your local development data and the production data.

Note

The validation feature only simulates a part of the actual submission process and may not catch all errors that could occur in a live production environment.


Validate with FINTER

FINTER provides a ValidationHelper class that allows you to perform this validation locally. Below, we will go through the process of setting up the environment and executing the validation steps.

Setting Up the Environment

First, we need to set up our environment by providing the FINTER API key. This key is essential for authenticating and accessing the FINTER services.

import os

# Replace YOUR_FINTER_API_KEY with your actual FINTER API key
os.environ['FINTER_API_KEY'] = FINTER_API_KEY

Importing ValidationHelper

Next, we import the ValidationHelper class from the finter.framework_model module. This class will be used to perform the validation of our portfolio model.

from finter.framework_model import ValidationHelper

Defining Model Information

We define the model information, which includes details about the exchange, universe, instrument type, frequency, position type, and model type. This information is required for the validation process.

model_info = {
    "exchange": "krx", 
    "universe": "krx",
    "instrument_type": "stock",
    "freq": "1d",
    "position_type": "target",
    "type": "portfolio"
}

Understanding ValidationHelper

Before we proceed with the validation, let's understand what ValidationHelper does by printing its documentation.

print(ValidationHelper.__doc__) # This will print the documentation for the ValidationHelper class

Performing Validation

Now, we will create an instance of ValidationHelper with our portfolio model name (e.g., "sample") and the model information. We will then call the validate method to perform the validation.

# Replace SAMPLE_DIRECTORY with your actual model directory
model_directory = SAMPLE_DIRECTORY

# Perform the validation
validation_result = ValidationHelper(model_directory, model_info).validate()
print(validation_result)

Checking End Dependency

We can also check for end dependency in our portfolio model using the validate_end_dependency method.

# Check for end dependency
end_dependency_result = ValidationHelper(model_directory, model_info).validate_end_dependency()
print(end_dependency_result)

Checking Start Dependency

Similarly, we can check for start dependency using the validate_start_dependency method.

# Check for start dependency
start_dependency_result = ValidationHelper(model_directory, model_info).validate_start_dependency()
print(start_dependency_result)

By executing these steps, you can validate your portfolio model locally and ensure that it is ready for deployment in a live trading environment. Remember to replace SAMPLE_DIRECTORY with your actual portfolio model name and YOUR_FINTER_API_KEY with your actual FINTER API key.

Last updated