Navigation

    Quantiacs Community

    • Register
    • Login
    • Search
    • Categories
    • News
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    1. Home
    2. Popular
    Log in to post
    • All categories
    • Support
    •      Request New Features
    • Strategy help
    • General Discussion
    • News and Feature Releases
    • All Topics
    • New Topics
    • Watched Topics
    • Unreplied Topics
    • All Time
    • Day
    • Week
    • Month
    • M

      Acess previous weights
      Support • • magenta.kabuto

      29
      0
      Votes
      29
      Posts
      1995
      Views

      V

      @blackpearl Hello. I don’t use machine learning in trading, and I don’t have similar examples. If you know Python and know how to develop such systems, or if you use ChatGPT (or similar tools) for development, you should not have difficulties modifying existing examples. You will need to change the model training and prediction functions.

      One of the competitive advantages of the Quantiacs platform is the ability to test machine learning models from a financial performance perspective.

      I haven’t encountered similar tools. Typically, models are evaluated using metrics like F1 score and cross-validation (for example, in the classification task of predicting whether the price will rise tomorrow).

      However, there are several problems:

      It is unclear how much profit this model can generate. In real trading, there will be commissions, slippage, data errors, and the F1 score doesn’t account for these factors. It is possible to inadvertently look into the future. For instance, data preprocessing techniques like standardization can leak future information into the past. If you subtract the mean or maximum value from each point in the time series, the maximum value reached in 2021 would be known in 2015, which is unacceptable.

      The Quantiacs platform provides a tool for evaluating models from a financial performance perspective.

      However, practice shows that finding a good machine learning model requires significant computational resources and time for training and testing. My results when testing strategies on real data have not been very good.

    • D

      Calculation of trading strategies
      Strategy help • • dark.pidgeot

      26
      0
      Votes
      26
      Posts
      1854
      Views

      D

      @jeppe_and Thanks for the reply, i'll check my code

    • A

      Q20 contest results
      News and Feature Releases • • azure.machamp

      26
      0
      Votes
      26
      Posts
      1863
      Views

      support

      @theflyingdutchman Hi, the Q20 had very few participants, less than 30, and no strategies are being traded at the moment according to the contest rules. Indeed we made no official announcement.

      However, the participants had the opportunity to submit the same code (provided it is correct) to the Q21 (in other words no correlations check are performed).

      It is very cumbersome to remove strategies from the web page, so they are currently displayed.

      If your strategy will continue to perform good and we believe it can be traded, we will contact you.

    • S

      Submission failure
      Support • • Sun-73

      21
      1
      Votes
      21
      Posts
      1771
      Views

      support

      @antinomy great! Sorry, there were many submissions on the last day.

    • S

      Please advise on p settings. Thanks.
      Strategy help • • spancham

      21
      1
      Votes
      21
      Posts
      1937
      Views

      S

      Hi @support
      Thank you, I'll try that.

    • M

      Backtesting
      Strategy help • • magenta.kabuto

      16
      1
      Votes
      16
      Posts
      1165
      Views

      support

      @stefanm Thank you!

    • M

      Missed Call to write output
      Strategy help • • magenta.kabuto

      16
      1
      Votes
      16
      Posts
      766
      Views

      M

      I finally resolved the issue, after lots of struggle. The custom layers, custom loss function and the function had to be serialized and deserialized correctly in order to save the architecture and weights as Json, rather than in a dictionary, like is suggested for pytorch in the Neural netowork template.
      It seems Pytorch is way more user friendly when it comes to saving and loading models.

    • magenta.grimer

      More color on contest rules
      General Discussion • • magenta.grimer

      16
      0
      Votes
      16
      Posts
      1073
      Views

      support

      @magenta-grimer Hello, the 34 M USD have been allocated to the winning strategies according to the contest rules.

      Other strategies have been funded, and agreements are in place between quantiacs, investors and quants. We cannot disclose more details now, sorry.

      5M USD is a reasonable capacity a strategy could handle, yes.

    • S

      Q21 submission
      Support • • Sun-73

      16
      0
      Votes
      16
      Posts
      966
      Views

      S

      @support Thank you!

    • S

      Announcement of updates to the Q21 contest
      Support • • Sun-73

      15
      0
      Votes
      15
      Posts
      848
      Views

      S

      @support Thank you very much once again!

    • illustrious.felice

      backtest_ml has too long a run time
      Strategy help • • illustrious.felice

      14
      1
      Votes
      14
      Posts
      833
      Views

      V

      @illustrious-felice

      Incorporating seed initialization into your PyTorch code ensures reproducibility by making the random number generation predictable. This involves setting seeds for the PyTorch engine, NumPy, and the Python random module if you're using it. Below, I'll show you how to integrate seed initialization into your existing code. Remember, while this can make your experiments more reproducible, it does not guarantee identical results across different hardware or PyTorch versions due to the inherent nondeterminism in some GPU operations.

      import xarray as xr # xarray for data manipulation import qnt.data as qndata # functions for loading data import qnt.backtester as qnbt # built-in backtester import qnt.ta as qnta # technical analysis library import numpy as np import pandas as pd import torch from torch import nn, optim import random # Seed initialization function def set_seed(seed_value=42): """Set seed for reproducibility.""" random.seed(seed_value) np.random.seed(seed_value) torch.manual_seed(seed_value) torch.cuda.manual_seed(seed_value) torch.cuda.manual_seed_all(seed_value) # if you are using multi-GPU. torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False # Set the seed for reproducibility set_seed(42) asset_name_all = ['NAS:AAPL', 'NAS:AMZN', 'NAS:MSFT'] class LSTM(nn.Module): """ Class to define our LSTM network. """ def __init__(self, input_dim=3, hidden_layers=64): super(LSTM, self).__init__() self.hidden_layers = hidden_layers self.lstm1 = nn.LSTMCell(input_dim, self.hidden_layers) self.lstm2 = nn.LSTMCell(self.hidden_layers, self.hidden_layers) self.linear = nn.Linear(self.hidden_layers, 1) def forward(self, y, future_preds=0): outputs = [] n_samples = y.size(0) h_t = torch.zeros(n_samples, self.hidden_layers, dtype=torch.float32) c_t = torch.zeros(n_samples, self.hidden_layers, dtype=torch.float32) h_t2 = torch.zeros(n_samples, self.hidden_layers, dtype=torch.float32) c_t2 = torch.zeros(n_samples, self.hidden_layers, dtype=torch.float32) for time_step in range(y.size(1)): x_t = y[:, time_step, :] # Ensure x_t is [batch, input_dim] h_t, c_t = self.lstm1(x_t, (h_t, c_t)) h_t2, c_t2 = self.lstm2(h_t, (h_t2, c_t2)) output = self.linear(h_t2) outputs.append(output.unsqueeze(1)) outputs = torch.cat(outputs, dim=1).squeeze(-1) return outputs def get_model(): model = LSTM(input_dim=3) return model def get_features(data): close_price = data.sel(field="close").ffill('time').bfill('time').fillna(1) open_price = data.sel(field="open").ffill('time').bfill('time').fillna(1) high_price = data.sel(field="high").ffill('time').bfill('time').fillna(1) log_close = np.log(close_price) log_open = np.log(open_price) features = xr.concat([log_close, log_open, high_price], "feature") return features def get_target_classes(data): price_current = data.sel(field='close') price_future = qnta.shift(price_current, -1) class_positive = 1 # prices goes up class_negative = 0 # price goes down target_price_up = xr.where(price_future > price_current, class_positive, class_negative) return target_price_up def load_data(period): return qndata.stocks.load_ndx_data(tail=period, assets=asset_name_all) def train_model(data): features_all = get_features(data) target_all = get_target_classes(data) models = dict() for asset_name in asset_name_all: model = get_model() target_cur = target_all.sel(asset=asset_name).dropna('time', 'any') features_cur = features_all.sel(asset=asset_name).dropna('time', 'any') target_for_learn_df, feature_for_learn_df = xr.align(target_cur, features_cur, join='inner') criterion = nn.MSELoss() optimiser = optim.LBFGS(model.parameters(), lr=0.08) epochs = 1 for i in range(epochs): def closure(): optimiser.zero_grad() feature_data = feature_for_learn_df.transpose('time', 'feature').values in_ = torch.tensor(feature_data, dtype=torch.float32).unsqueeze(0) out = model(in_) target = torch.zeros(1, len(target_for_learn_df.values)) target[0, :] = torch.tensor(np.array(target_for_learn_df.values)) loss = criterion(out, target) loss.backward() return loss optimiser.step(closure) models[asset_name] = model return models def predict(models, data): weights = xr.zeros_like(data.sel(field='close')) for asset_name in asset_name_all: features_all = get_features(data) features_cur = features_all.sel(asset=asset_name).dropna('time', 'any') if len(features_cur.time) < 1: continue feature_data = features_cur.transpose('time', 'feature').values in_ = torch.tensor(feature_data, dtype=torch.float32).unsqueeze(0) out = models[asset_name](in_) prediction = out.detach()[0] weights.loc[dict(asset=asset_name, time=features_cur.time.values)] = prediction return weights weights = qnbt.backtest_ml( load_data=load_data, train=train_model, predict=predict, train_period=55, retrain_interval=55, retrain_interval_after_submit=1, predict_each_day=False, competition_type='stocks_nasdaq100', lookback_period=55, start_date='2024-01-01', build_plots=True )

      I think I won't be available next week. If you have any more questions, don’t expect an answer from me next week.

    • S

      Strategy Funding
      General Discussion • • spancham

      13
      1
      Votes
      13
      Posts
      1108
      Views

      support

      @sheikh Hi,

      it simply means that your system should make a new global high before you are entitled for a payment. If your system makes 1000 at the end of January, 800 at the end of Februray, 900 at the end of March and 1100 at the end of April, your profit will be generated at the end of April and they will amount to 1100-100=100;

      no, once the system starts being traded, it will be traded in the form it was at submission time, i.e. the quant will not be allowed to update parameters/change details. Of course a submitted system can have an adaptive logic, by changing parameters according to the value of some meta-indicator. If the quant believes there is some big change to be made, it is ok to re-submit the changed system, but it will need again to accumulate a track record before being traded.

    • S

      Machine Learning Strategy
      Strategy help • • spancham

      13
      0
      Votes
      13
      Posts
      1033
      Views

      S

      @vyacheslav_b
      Thank you! 🎉 🎉

    • M

      Different Sharpe Ratios for Multipass-Backtest and Quantiacs Mulipass Backtest
      Support • • magenta.kabuto

      13
      1
      Votes
      13
      Posts
      984
      Views

      support

      @vyacheslav_b thank you!

    • D

      Struggle creating local dev environment
      Support • • dark.shark

      13
      0
      Votes
      13
      Posts
      759
      Views

      V

      @dark-pidgeot Hi! After the release of version qnt “0.0.402” the issue with data loading in the local environment has been resolved. The library now uses newer dependencies, including pandas version 2.2.2.

    • support

      Share the state between iterations
      Request New Features • • support

      13
      1
      Votes
      13
      Posts
      1148
      Views

      S

      @support
      ok I did what @antinomy said below and the 'state' strategy worked.
      https://quantiacs.com/community/topic/46/macroeconomic-data-with-quantiacs/3?_=1619554449031

      However, it broke my old strategies. So he further suggested to:
      https://quantiacs.com/community/topic/46/macroeconomic-data-with-quantiacs/5?_=1619556376479
      And my old strategies are running again.

      Ok, so looks like for now for all strategies without a state I have to output and pass None to weights for the state & pass a state variable to the strategy.
      Will keep you updated. Thanks for looking into the issue.

    • news-quantiacs

      The Q20 Contest Started
      News and Feature Releases • • news-quantiacs

      13
      1
      Votes
      13
      Posts
      1319
      Views

      support

      @magenta-grimer hi, you can find one very simple example here:

      https://quantiacs.com/documentation/en/data/fundamental.html

      best regards

    • news-quantiacs

      The Q16 Contest is open!
      News and Feature Releases • • news-quantiacs

      12
      2
      Votes
      12
      Posts
      966
      Views

      support

      @antinomy In the end we followed your advise and changed a little bit the algorithm for adding data, once a cryptocurrency is in the top10 we include it with its past history and go on with the update (now DASH and XMR are being updated). Of course once the crypto is not among the top 10, the liquidity tag for the filter is "zero". Thank you!

    • S

      Suggestions for the Q17 contest.
      News and Feature Releases • • Sun-73

      12
      2
      Votes
      12
      Posts
      1147
      Views

      support

      @pillocktailor Thank you for the interesting proposal.

    • A

      Different Sharpe ratios in backtest and competition filter
      Support • • antinomy

      12
      2
      Votes
      12
      Posts
      913
      Views

      C

      @support Thank you very much for the clarification, and once again congratulations for the great job you are doing 😉

    • Documentation
    • About
    • Career
    • My account
    • Privacy policy
    • Terms and Conditions
    • Cookies policy
    Home
    Copyright © 2014 - 2021 Quantiacs LLC.
    Powered by NodeBB | Contributors