1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-11 23:06:58 +08:00
Signed-off-by: unknown <lv.linlang@qq.com>
This commit is contained in:
SunsetWolf
2021-12-31 22:14:47 +08:00
committed by GitHub
parent f59cfe51e0
commit dfc0ed3c01
56 changed files with 92 additions and 92 deletions

View File

@@ -18,8 +18,8 @@ class SepDataFrame:
"""
(Sep)erate DataFrame
We usually concat multiple dataframe to be processed together(Such as feature, label, weight, filter).
However, they are usally be used seperately at last.
This will result in extra cost for concating and spliting data(reshaping and copying data in the memory is very expensive)
However, they are usually be used separately at last.
This will result in extra cost for concatenating and splitting data(reshaping and copying data in the memory is very expensive)
SepDataFrame tries to act like a DataFrame whose column with multiindex
"""

View File

@@ -38,11 +38,11 @@ def _get_position_value_from_df(evaluate_date, position, close_data_df):
def get_position_value(evaluate_date, position):
"""sum of close*amount
get value of postion
get value of position
use close price
postions:
positions:
{
Timestamp('2016-01-05 00:00:00'):
{

View File

@@ -56,7 +56,7 @@ class HFLGBModel(ModelFT, LightGBMFInt):
def hf_signal_test(self, dataset: DatasetH, threhold=0.2):
"""
Test the sigal in high frequency test set
Test the signal in high frequency test set
"""
if self.model == None:
raise ValueError("Model hasn't been trained yet")

View File

@@ -446,7 +446,7 @@ class TabNet(nn.Module):
Args:
n_d: dimension of the features used to calculate the final results
n_a: dimension of the features input to the attention transformer of the next step
n_shared: numbr of shared steps in feature transfomer(optional)
n_shared: numbr of shared steps in feature transformer(optional)
n_ind: number of independent steps in feature transformer
n_steps: number of steps of pass through tabbet
relax coefficient:
@@ -479,7 +479,7 @@ class TabNet(nn.Module):
out = torch.zeros(x.size(0), self.n_d).to(x.device)
for step in self.steps:
x_te, l = step(x, x_a, priors)
out += F.relu(x_te[:, : self.n_d]) # split the feautre from feat_transformer
out += F.relu(x_te[:, : self.n_d]) # split the feature from feat_transformer
x_a = x_te[:, self.n_d :]
sparse_loss.append(l)
return self.fc(out), sum(sparse_loss)

View File

@@ -232,7 +232,7 @@ class TRAModel(Model):
choice_all.append(pd.DataFrame(choice.detach().cpu().numpy(), index=index))
decay = self.rho ** (self.global_step // 100) # decay every 100 steps
lamb = 0 if is_pretrain else self.lamb * decay
reg = prob.log().mul(P).sum(dim=1).mean() # train router to predict OT assignment
reg = prob.log().mul(P).sum(dim=1).mean() # train router to predict TO assignment
if self._writer is not None and not is_pretrain:
self._writer.add_scalar("training/router_loss", -reg.item(), self.global_step)
self._writer.add_scalar("training/reg_loss", loss.item(), self.global_step)
@@ -663,7 +663,7 @@ class TRA(nn.Module):
"""Temporal Routing Adaptor (TRA)
TRA takes historical prediction erros & latent representation as inputs,
TRA takes historical prediction errors & latent representation as inputs,
then routes the input sample to a specific predictor for training & inference.
Args:

View File

@@ -33,5 +33,5 @@ def count_parameters(models_or_parameters, unit="m"):
elif unit == "gb" or unit == "g":
counts /= 2 ** 30
elif unit is not None:
raise ValueError("Unknow unit: {:}".format(unit))
raise ValueError("Unknown unit: {:}".format(unit))
return counts

View File

@@ -36,7 +36,7 @@ def save_instance(instance, file_path):
save(dump) an instance to a pickle file
Parameter
instance :
data to te dumped
data to be dumped
file_path : string / pathlib.Path()
path of file to be dumped
"""

View File

@@ -47,7 +47,7 @@ class SoftTopkStrategy(WeightStrategyBase):
Return the proportion of your total value you will used in investment.
Dynamically risk_degree will result in Market timing
"""
# It will use 95% amoutn of your total value by default
# It will use 95% amount of your total value by default
return self.risk_degree
def generate_target_weight_position(self, score, current, trade_start_time, trade_end_time):

View File

@@ -24,7 +24,7 @@ class TWAPStrategy(BaseStrategy):
NOTE:
- This TWAP strategy will celling round when trading. This will make the TWAP trading strategy produce the order
ealier when the total trade unit of amount is less than the trading step
earlier when the total trade unit of amount is less than the trading step
"""
def reset(self, outer_trade_decision: BaseTradeDecision = None, **kwargs):
@@ -43,8 +43,8 @@ class TWAPStrategy(BaseStrategy):
def generate_trade_decision(self, execute_result=None):
# NOTE: corner cases!!!
# - If using upperbound round, please don't sell the amount which should in next step
# - the coordinate of the amount between steps is hard to be dealed between steps in the same level. It
# is easier to be dealed in upper steps
# - the coordinate of the amount between steps is hard to be dealt between steps in the same level. It
# is easier to be dealt in upper steps
# strategy is not available. Give an empty decision
if len(self.outer_trade_decision.get_decision()) == 0:

View File

@@ -69,7 +69,7 @@ class BaseSignalStrategy(BaseStrategy):
Return the proportion of your total value you will used in investment.
Dynamically risk_degree will result in Market timing.
"""
# It will use 95% amoutn of your total value by default
# It will use 95% amount of your total value by default
return self.risk_degree

View File

@@ -90,7 +90,7 @@ class QLibTuner(Tuner):
def objective(self, params):
# 1. Setup an config for a spcific estimator process
# 1. Setup an config for a specific estimator process
estimator_path = self.setup_estimator_config(params)
self.logger.info("Searching params: {} ".format(params))