Skip to content

wsxrfv9090/Quantitative-Investment-Algorithms

Repository files navigation

Usage

  1. Set absolute directory to your clone destinations. e.g: d:\Important Files\Repositories\Quantitative-Investment-Algorithms'

To do list

1. CAPM algorithms

  • 1. Get the test data
  • 2. Preprocess test data
  • 3. Compute R_i, R_m, R_f
  • 4. Compute Excessive Returns for both the stock and market
  • Improvements to be made:
  • 1. Eliminate redundant work
  • 2. Swap out statsmodels for a closed‑form beta: Use vectorized closed‑form formulas
  • 3. Parallelize at the “file” level: with multiprocessing.Pool (or joblib) rather than threads.
  • 4. When (and when not) to consider GPU
  • 5. Isolate different code parts to make it more readable.

2. Get the data

3. K means clustering to get labels for svm

  • 1. Randomly choose k points as centroids
  • 2. Assign points to their closest centroids
  • 3. Calculate the mean of each cluster as new centroids
  • 4. Repeat until the clusters doesn't change within tolerance
  • 5. Evaluate the clustering with the total variation as evaluator
  • 6. Repeat to find the minimum total variation
  • 7. Elbow plot

4. SVM using pytorch algorithm, this draws the line for binary classification

  • Finding best fit support vector classifier
  • 1. Shuffle the data
  • 2. Calculate signed distances, reflecting the witch side each point is on, and it's euclidean distance to the SVC
  • 3. Define hinge loss
  • 4. Minimize the hinge loss function using iterations and gradient descent
  • 5. Output it's weights and bias
  • Improvments to be made:
  • 1. Change datatype as a deployable parameter
  • 2. Pack functions better
  • 3. Design a batch option

5. OVO using pytorch algorithm, do one by one voting system, this uses the SVM function for each 2 clusters clustered by the k means cluster

  • OVO classification (multiclass classification) implementation
  • 1. Add k means cluster output as datas labels
  • 2. Run SVC and do the classification
  • 3. Reallocate it's class by a voting system

6. (Optional) if the data is not linearly seperatable by svm, inplement kernel tricks using polynomial or other method to seperate it.

7. Choose class index as risk free rate then calculate alpha and beta for each stock within the class

8. Evaluate combinations

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors