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
    • X

      Combining classifiers
      Strategy help • • xiaolan

      6
      0
      Votes
      6
      Posts
      912
      Views

      support

      @xiaolan That is correct, but the logic can be easily re-used. The only novel element will be the introduction of the liquidity filter at intermediate stages/at the final stage for the selection of the weights.

    • M

      Futures data issues
      Support • • Msant14

      6
      1
      Votes
      6
      Posts
      656
      Views

      A

      @support I have done that twice before my post, but now F_RY looks fine. There are several directories with scripts and notebooks I use with qnt, so maybe I deleted the wrong data-cache before...
      Thanks for fixing the data!

    • E

      Q17 Neural Networks Algo Template; is there an error in train_model()?
      Strategy help • • EDDIEE

      6
      1
      Votes
      6
      Posts
      1613
      Views

      V

      Hello colleagues.

      The solution in case of predicting one financial instrument can be the following (train_period changed)

      def load_data(period): return qndata.cryptodaily_load_data(tail=period, assets=['BTC']) def train_model(data): """ train the LSTM network """ asset_name = 'BTC' features_all = get_features(data) target_all = get_target_classes(data) model = get_model() # drop missing values: target_cur = target_all.sel(asset=asset_name).dropna('time', 'any') features_cur = features_all.sel(asset=asset_name).dropna('time', 'any') # align features and targets: target_for_learn_df, feature_for_learn_df = xr.align(target_cur, features_cur, join='inner') criterion = nn.MSELoss() # define loss function optimiser = optim.LBFGS(model.parameters(), lr=0.08) # we use an LBFGS solver as optimiser epochs = 1 # how many epochs for i in range(epochs): def closure(): # reevaluates the model and returns the loss (forward pass) optimiser.zero_grad() # input tensor in_ = torch.zeros(1, len(feature_for_learn_df.values)) in_[0, :] = torch.tensor(np.array(feature_for_learn_df.values)) # output out = model(in_) # target tensor target = torch.zeros(1, len(target_for_learn_df.values)) target[0, :] = torch.tensor(np.array(target_for_learn_df.values)) # evaluate loss loss = criterion(out, target) loss.backward() return loss optimiser.step(closure) # updates weights return model weights = qnbt.backtest_ml( load_data=load_data, train=train_model, predict=predict, train_period=1 * 365, # the data length for training in calendar days retrain_interval=365, # how often we have to retrain models (calendar days) retrain_interval_after_submit=1, # how often retrain models after submission during evaluation (calendar days) predict_each_day=False, # Is it necessary to call prediction for every day during backtesting? # Set it to true if you suspect that get_features is looking forward. competition_type='crypto_daily_long_short', # competition type lookback_period=365, # how many calendar days are needed by the predict function to generate the output start_date='2014-01-01', # backtest start date build_plots=True # do you need the chart? )
    • magenta.grimer

      Optimize the Trend Following strategy with custom args
      Strategy help • • magenta.grimer

      6
      0
      Votes
      6
      Posts
      1032
      Views

      support

      Hello.

      I checked this problem. The script which cut "###DEBUG###" cells was incorrect. I fixed this and resent your strategies (filtered by time out) to checking.

      Regards.

    • M

      Strategy takes a long time to get verified
      Support • • magenta.muskrat

      6
      0
      Votes
      6
      Posts
      2366
      Views

      S

      @support, thank you for the clarifications. Regards.

    • S

      Balance, order size, stop loss, open and close position price
      Support • • ScalpingAF

      6
      0
      Votes
      6
      Posts
      641
      Views

      support

      @scalpingaf Correct, all trades (buy or sell) are taken at the open of the next day you take the decision.

    • I

      Getting started with local dev.
      Support • • iron.tentacruel

      6
      0
      Votes
      6
      Posts
      748
      Views

      support

      @iron-tentacruel Sorry for the delay in the answer. We recommend conda as we can better track dependencies. With conda you can create locally an environment which mirrors the one on the Quantiacs server and you can work locally as you would on the server. If you need a specific version of a package, please let us know.

    • A

      Weights different in testing and submission
      Support • • anshul96go

      6
      0
      Votes
      6
      Posts
      1178
      Views

      support

      @antinomy thanks!

    • N

      Q21 contest results
      News and Feature Releases • • neural.exeggutor

      6
      0
      Votes
      6
      Posts
      10594
      Views

      support

      @theflyingdutchman Hi, sorry for the delay, yes, all fine, more details by e-mail

    • S

      Q16 where to put is_liquid in ML template
      Strategy help • • Sheikh

      6
      0
      Votes
      6
      Posts
      1537
      Views

      S

      Hi @support,
      Thanks for getting back. No worries, I was able to get 6 strategies into the Q16 competition so far.
      qnt3.PNG

    • illustrious.felice

      Translating code from Quantiacs Legacy
      Support • • illustrious.felice

      6
      0
      Votes
      6
      Posts
      734
      Views

      illustrious.felice

      @vyacheslav_b Thank you so much

    • illustrious.felice

      Sharpe decreases when submitting strategy
      Support • • illustrious.felice

      6
      0
      Votes
      6
      Posts
      601
      Views

      illustrious.felice

      @vyacheslav_b Thank you so much

    • A

      How are models ranked on the leaderboard before the live period?
      General Discussion • • antinomy

      6
      1
      Votes
      6
      Posts
      1364
      Views

      S

      @support
      oh I see now what you mean.
      15 strategies PER USER are selected.
      At first, I thought you were only going to select 15 strategies total for all users.
      Thanks.

    • C

      Setup an environment at Google Colab
      Support • • cortezkwan

      5
      2
      Votes
      5
      Posts
      768
      Views

      C

      @support Great help! Thank you so much!

    • C

      Multi-pass Backtesting
      Strategy help • • cyan.gloom

      5
      0
      Votes
      5
      Posts
      1897
      Views

      V

      @eddiee

      Hello.

      This code looks to the future.
      It is needed to train the model.
      Pay attention to the name of the variable.

    • E

      Q17 Contest
      General Discussion • • EDDIEE

      5
      0
      Votes
      5
      Posts
      834
      Views

      support

      @theflyingdutchman Yes, we are integrating new data sources for a new asset class, once we are done (next week) the data and leaderboard updates will start again.

    • X

      Pandas and xarray
      Strategy help • • xiaolan

      5
      1
      Votes
      5
      Posts
      794
      Views

      support

      @xiaolan Ok, but please note that you can work all the time with xarray, the documentation is very good:

      http://xarray.pydata.org/en/stable/

    • L

      Fundamental data loading does not work
      Support • • lookman

      5
      0
      Votes
      5
      Posts
      1649
      Views

      V

      @lookman Hello. Try cloning your strategy and running it again. It should work correctly with the new version of the qnt library.

      import qnt.data as qndata import qnt.data.secgov_fundamental as fundamental market_data = qndata.stocks.load_spx_data(min_date="2005-01-01") indicators_data = fundamental.load_indicators_for(market_data, indicator_names=['roe']) display(indicators_data.sel(field="roe").to_pandas().tail(2)) display(indicators_data.sel(asset='NAS:AAPL').to_pandas().tail(2)) display(indicators_data.sel(asset=['NAS:AAPL']).sel(field="roe").to_pandas().tail(2))

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

    • A

      Has my strategy been rejected from Q23?
      Support • • antinomy

      5
      0
      Votes
      5
      Posts
      536
      Views

      A

      And what if a strategy uses the following rules to select assets to trade:

      the primary exchange is NAS the sector is not finance has price data for at least the previous 3 months has an average daily trading volume of at least 200 k based on the previous 3 months belongs to the top 100 of the thus far selected assets in terms of market capitalization

      Would you say any of these rules violate the contest rules?

      Because these are the selection criteria for the N100 constituents. The only difference in my strategy is that I'm using qnt.data.stocks_load_ndx_data.sel(field='is_liquid') instead.
      Sure, the first of the rules above manually selects the exchange and the second one manually excludes a sector. But still none of these manually select assets and neither does the filter is_liquid from another dataset.

      Also, lets take a look why you prohibited manual asset selection in the first place. Wasn't this to avoid lookahead bias? And isn't this also the reason for the existence of the field is_liquid in any of your datasets? Are you saying that the exact field you introduced to avoid lookahead bias is now the reason you disqualify a strategy because of lookahead bias just because it's from a dataset other than the one for the contest?

    • illustrious.felice

      Strategy trades illiquid instruments
      Support • • illustrious.felice

      5
      0
      Votes
      5
      Posts
      2707
      Views

      V

      @illustrious-felice Hello. The reason you're still seeing a large number of tickers (e.g., around 300) even after applying the filter is that the "best" instrument by Sharpe ratio changes over time. The rank_assets_by function returns a time-dependent mask, selecting the top N assets at each time step. So the total number of unique assets that were selected at any point in time may be much larger than top_assets.

      This is expected behavior.

      To illustrate this more clearly, let's consider a minimal working example that selects only 1 top asset at each point in time and shows all the intermediate steps:

      import qnt.data as qndata import qnt.ta as qnta import qnt.stats as qnstats import qnt.output as qnout import qnt.filter as qnfilter import xarray as xr import pandas as pd top_assets = 1 data = qndata.stocks.load_spx_data(min_date="2005-06-01") weights = data.sel(field="is_liquid") stats_per_asset = qnstats.calc_stat(data, weights, per_asset=True) sharpe_ratio = stats_per_asset.sel(field="sharpe_ratio") asset_filter = qnfilter.rank_assets_by(data, sharpe_ratio, top_assets, ascending=False) weights = weights * asset_filter stats = qnstats.calc_stat(data, weights.sel(time=slice("2005-06-01", None))) display(asset_filter.to_pandas().tail()) display(stats.to_pandas().tail()) display(sharpe_ratio.to_pandas().tail()) display(weights.to_pandas().tail())

      If you want to see which asset was the best on specific dates, you can do something like this:

      dates = ["2015-01-15", "2020-01-15", "2025-01-15"] records = [] for date_str in dates: best_mask = asset_filter.sel(time=date_str) assets = best_mask.where(best_mask > 0, drop=True).asset.values srs = sharpe_ratio.sel(time=date_str, asset=assets).values for a, s in zip(assets, srs): records.append({"time": date_str, "asset": a.item(), "sharpe_ratio": float(s)}) df = pd.DataFrame(records).set_index("time") display(df) asset sharpe_ratio time 2025-05-22 NYS:HRL 1.084683 2025-05-22 NAS:KDP 1.093528 2025-05-22 NAS:AAPL 0.968039

      Or simply for a single date:

      date = "2020-05-22" best_mask = asset_filter.sel(time=date) best_assets = best_mask.where(best_mask > 0, drop=True).asset best_sr = sharpe_ratio.sel(time=date, asset=best_assets) print(best_sr.to_pandas())

      This shows clearly that only one asset is selected at each time step, but over the full time range, many different assets can appear in the top list depending on how their Sharpe ratios change.

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