-
Notifications
You must be signed in to change notification settings - Fork 0
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
48 feature eval computation #55
base: main
Are you sure you want to change the base?
Changes from 5 commits
ede06a3
a326575
c8bef3c
e3756da
b6c6b97
aaa2a89
ad5d6c1
ecdff32
ab17c71
5c98818
9737da2
b14ad15
9661015
fc3dcaf
d76fb97
fc49fb9
f677bb1
69260d1
a33e628
92c27c0
ad439e2
2be86a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from pysrc.adapters.kraken.historical.historical_data_client import HistoricalDataClient | ||
from datetime import datetime | ||
from dateutil.rrule import rrule, DAILY | ||
from pysrc.util.types import TradeMessage, Asset | ||
from pysrc.signal.base_feature_generator import BaseFeatureGenerator | ||
import numpy as np | ||
|
||
|
||
class Evaluator: | ||
|
||
def __init__(self, features: list[str], asset: Asset, start: datetime, end: datetime): | ||
self.features = features | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prefix with underscore pls There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prefix the helpers? are you talking about calculate_features() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mb i meant like self._features = features |
||
self.asset = asset | ||
self.start = start | ||
self.end = end | ||
pass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. del There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
def _get_data_daterange(self, start: datetime, end: datetime) -> list[TradeMessage]: | ||
hist_client = HistoricalDataClient() | ||
res = [] | ||
for date in rrule(DAILY, dtstart=start, until=end): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we do all the path manip with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not anything wrong with using but was there a reason you used rrule instead of doing this manually There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i was dumb |
||
res.extend(hist_client.get_trades(self.coin, date, "")) | ||
return res | ||
|
||
def calculate_features(self) -> dict[str, list[float]]: | ||
trades = self._get_data_daterange(self.start, self.end) | ||
# ^ this returns a list[TradeMessage], but on_tick expects dict[str, TradeMessage] | ||
# What is key? | ||
kyeoul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
snapshots = {} | ||
kyeoul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# ^ how to get snapshots? | ||
generator_client = BaseFeatureGenerator() | ||
feature_dict = generator_client.on_tick(snapshots, trades) | ||
return feature_dict[self.asset] | ||
|
||
# Suppose that returns is passed to evaluate_features | ||
def evaluate_features(self, target: list[float]): | ||
calc_features = self.calculate_features() | ||
input_matrix = [] | ||
for feature in self.features: | ||
input_matrix.append(calc_features[feature]) | ||
input_matrix.append(target) | ||
return np.corrocoef(input_matrix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why r we using dateutil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im stupid, removed and iterating with regular datetime