Skip to content

Commit

Permalink
add builtins
Browse files Browse the repository at this point in the history
  • Loading branch information
robswc committed Mar 23, 2023
1 parent 165462a commit a6c6b87
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/components/strategy/builtins/ta/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from components.strategy.builtins.ta.sma import *
from components.strategy.builtins.ta.correlation import *
from components.strategy.builtins.ta.logic import Logic as logic
12 changes: 12 additions & 0 deletions app/components/strategy/builtins/ta/correlation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import numpy as np

from components.strategy import Series


def correlation_coefficient(x: Series, y: Series, period: int) -> Series:
""" Calculate the correlation coefficient between two lists """
x = np.array(x)
y = np.array(y)

# Calculate the correlation coefficient
return Series(np.corrcoef(x, y)[0, 1])

0 comments on commit a6c6b87

Please sign in to comment.