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

      Jupyter/Jupyter Lab are not working for code editing/running
      Support • • AlgoQuant

      4
      0
      Votes
      4
      Posts
      769
      Views

      support

      @captain-nidoran Fixed, sorry for issue

    • M

      Why we need to limit the time to process the strategy ?
      Support • • multi_byte.wildebeest

      4
      0
      Votes
      4
      Posts
      383
      Views

      support

      @multi_byte-wildebeest Hi, these limitations refer to the processing time per point in time, not for the full strategy.

      If it takes 10 minutes per historical day, and the simulation has to take into account 250 days for let us say 10 years, the multi-pass simulation would process 6 days per hour, 144 days per real day, that means 2 weeks of processing time for the full submission, it is a lot of time.

    • S

      Stocks strategy
      Strategy help • • spancham

      4
      0
      Votes
      4
      Posts
      526
      Views

      support

      @sheikh Hi, when it comes to stocks and historical simulations, the biggest issue is dealing with survivorship bias. The stock universe must include also stocks which have been delisted and we need to define trading rules which allow for trading instruments which make sense at each point in time. This week we are announing a new contest which is preparing the ground for stocks.

    • magenta.grimer

      Optimizer for simple MA crypto strategy
      Strategy help • • magenta.grimer

      4
      0
      Votes
      4
      Posts
      520
      Views

      A

      There is a way to use the optimizer with a (stateful) mulit pass algo, but depending on the total number of changed parameters it can take a very long time. However, if it runs on a local computer with many workers this can still be useful.

      We could run the backtester with the multi pass algo to get all the weights for the test period and pass these weights to the optimizer.
      There's just one problem with this: you can't pass changed parameters to the strategy using the backtester.
      In order to solve this I created a nested function where the outer function takes the changed parameters from the optimizer. The inner function is the actual multi pass strategy and doesn't define the params but just uses the ones from the outer function. Still within the outer function we run the backtester with one set of params, get the weights it returns and return them to the optimizer.

      The time it takes to run the optimization would roughly be
      (time for 1 multi pass backtest) x (total number of parameter changes) / (number of workers that are able to run)
      So if one multi pass takes 1 minute, you want to optimize 10 parameter changes and can run 5 workers it would take about 2 minutes.

      Here's an example based on the one above with 2 parameter changes and 2 workers:

      import qnt.data as qndata import qnt.ta as qnta import qnt.optimizer as qnop import qnt.backtester as qnbt import xarray as xr def load_data(period): """Loads the BTC Futures data for the BTC Futures contest""" return qndata.cryptofutures.load_data(tail=period, dims=("time", "field", "asset")) def multi_pass_strategy(data, ma_slow_param=50, ma_fast_param=10): """The outer function gets called by the optimizer with changed params, the inner function gets passed to the backtester.""" def strategy(data, state): # The state isn't used in this example, this is just to show that it can be used while optimizing. if state is None: state = 0 state += 1 close = data.sel(field="close") ma_slow = qnta.lwma(close, ma_slow_param).isel(time=-1) ma_fast = qnta.lwma(close, ma_fast_param).isel(time=-1) weights = xr.zeros_like(close.isel(time=-1)) weights[:] = 1 if ma_fast > ma_slow else -1 return weights, state """The backtester returns all weights for the test period which will then be returned to the optimizer""" weights, state = qnbt.backtest( strategy=strategy, competition_type="cryptofutures", load_data=load_data, lookback_period=700, start_date='2014-01-01', build_plots=False, ) return weights data = qndata.cryptofutures.load_data(min_date='2014-01-01') result = qnop.optimize_strategy( data, multi_pass_strategy, qnop.full_range_args_generator( ma_slow_param=range(50, 60, 5), # min, max, step # ma_fast_param=range(5, 100, 5) # min, max, step ), workers=2 # you can set more workers on your PC ) print("---") print("Best iteration:") print(result['best_iteration']) qnop.build_plot(result)

      There might be more efficient ways to do this, so if anyone has one feel free to post it here.

    • O

      Can I use astronomical data as features for my machine learning model?
      Support • • omohyoid

      4
      0
      Votes
      4
      Posts
      496
      Views

      O

      @support Thx for ur reply

    • S

      Pairs trading with states iterations
      Strategy help • • spancham

      4
      0
      Votes
      4
      Posts
      511
      Views

      S

      @support
      Cool, thanks very much! 👍

    • magenta.grimer

      Importing external data
      General Discussion • • magenta.grimer

      4
      1
      Votes
      4
      Posts
      534
      Views

      support

      @penrose-moore Thank you for the idea. For the Bitcoin Futures contest we are indeed patching the Bitcoin Futures data with the BTC spot price to build a meaningful time series. For the other Futures contracts, for the moment we will keep the futures histories only, but add spot prices + patching with spot prices to increase the length of the time series to our to-do list.

    • news-quantiacs

      New futures data and next-to-front contracts
      News and Feature Releases • • news-quantiacs

      4
      1
      Votes
      4
      Posts
      502
      Views

      support

      @magenta-grimer Hello, we updated the documentation.

      Now there are 78 futures contracts. Yes, we allow allocating to only 1 asset. If you trade more assets, then you can go long on some of them and short others.

      Using more assets helps in increasing the Sharpe ratio, as the mean return grows linearly with the number of assets, and the volatility in the denominator with the square root of the number of assets if there are no correlation terms.

      Using uncorrelated assets would then lead to a scaling of the Sharpe ratio with the square root of the number of assets. In practice, however, correlation terms are decreasing this growth.

      Stated more simply, it is a good idea to avoid putting all your eggs in the same basket...

    • A

      Submission Logic Questions
      Support • • auxiliary.snail

      4
      0
      Votes
      4
      Posts
      924
      Views

      support

      @auxiliary-snail Hi,

      unfortunately, this is not allowed and in accordance with the rules. Using hard-coded time periods in which trading algorithm will work differently, is not a quantitative method (just like manual asset selection, e.g. "trade only Apple or Microsoft"). We still haven't implemented a mechanism for automatic recognition of such behaviors in trading strategies, and even though a strategy could be successfully submitted, it will not be eligible for prize winning.
      What we are searching for, is well performing strategy over entire in_sample period (SR>0.7), robust to all market movements 2006-2025, so we can expect it will perform well in future, too.

    • S

      Error for importing quantiacs module
      Support • • steel.camel

      3
      0
      Votes
      3
      Posts
      881
      Views

      support

      @steel-camel Sorry for the issue, it has been fixed.

    • L

      Error message when enter JupyterLab
      Support • • lemonpie

      3
      0
      Votes
      3
      Posts
      180
      Views

      L

      @support Thanks. Works fine now.

    • V

      Strategy Checking
      Support • submission • • violet.mewtwo

      3
      0
      Votes
      3
      Posts
      3611
      Views

      support

      @violet-mewtwo Dear violet-mewtwo, your submissions are processed correctly, it just needs some more time because of the big submission queue currently on our side. Thank you for your patience.

    • O

      I can't find why the submission failed
      Support • • omohyoid

      3
      0
      Votes
      3
      Posts
      269
      Views

      O

      @support
      Actually, I've write the weights to the output function.
      螢幕擷取畫面 2024-04-24 235034.png
      I think the reason might be that the data was out-of-date when the strategy received at the weekend. After the data update in the next day, it failed to pass the test.

    • V

      Getting logged out of account
      Support • • vg2001

      3
      0
      Votes
      3
      Posts
      406
      Views

      support

      @vg2001 Dear vg2001,
      There were some problems with the servers, thank you for your patience.
      Regards

    • A

      Clarification regarding execution time
      Support • • anshul96go

      3
      0
      Votes
      3
      Posts
      408
      Views

      support

      @anshul96go Dear Anshul, it means that the weights for each day have to be generated in less than 10 minutes of time per day.

      Note that all submissions are processed on the server after submission using a muti-pass approach (not single-pass).

      10 minutes per day, times 250 days, times 10 years, that is more than 400 hours of running time.

    • A

      notebook for googlecolab not working
      Support • • alfredaita

      3
      1
      Votes
      3
      Posts
      266
      Views

      A

      @support Thanks seems fine

    • N

      Use of Technical indicators
      Support • • noka'sworld

      3
      0
      Votes
      3
      Posts
      204
      Views

      N

      @support that is really useful! thank you very much!

    • A

      Output the results in an excel or other format file
      Support • • anshul96go

      3
      1
      Votes
      3
      Posts
      574
      Views

      A

      @anshul96go
      To get the actual statistics you currently have to calculate them like so:

      import qnt.stats as qns data = qndata.cryptodaily_load_data(min_date="2014-01-01") # or whenever your backtest started stats = qns.calc_stat(data, weights)

      And if you really need them as xls file you can do:

      stats.to_pandas().to_excel('stats.xls') # I got a ModuleNotFoundError the first time - pip install did the trick.

      Allthough I can't recommend xls because at least LibreOffice becomes very slow / unresponsive when handling such a file.

      Getting the statistics after a backtest could be a little simpler, which brings me to a feature request:
      @support
      Do you think you could add a parameter to the backtester which makes it return the statistics? They get calculated anyway by default, but we only see a truncated printout or the plots and can't use them for further analysis.
      .
      In my local environment I did it like this in qnt.backtester.py:

      Add the parameter return_stats: bool = False to the parameters of the backtest function From line 353 onward my backtester now looks like this: qnout.write(result) qnstate.write(state) if return_stats: analyze = True out = [result] if analyze: log_info("---") stats = analyze_results(result, data, competition_type, build_plots, start_date) if return_stats: out.append(stats) if args_count > 1: out.append(state) if len(out) == 1: out = out[0] return out finally: qndc.set_max_datetime(None) And of course I made analyze_results return the statistics like so (line 458 in the original): if not build_plots: log_info(stat_global.to_pandas().tail()) return stat_global # here log_info("---") log_info("Calc stats per asset...") stat_per_asset = qnstat.calc_stat(data, output, per_asset=True) stat_per_asset = stat_per_asset.loc[output.time.values[0]:] if is_notebook(): build_plots_jupyter(output, stat_global, stat_per_asset) else: build_plots_dash(output, stat_global, stat_per_asset) return stat_global # and there

      This might not be the most elegant solution but you get the idea.
      Now I can get the statistics immediately after the backtest with

      weights, stats = backtest(...return_stats=True)

      and can do further analysis.
      For instance, I started to calculate the correlations between my strategies to avoid uploading more of the same to the contest.

      It would be nice to have this feature in a future version, so I don't have to mess with the backtester after each update 😉

      Best regards

    • cespadilla

      Leaderboard not updating again
      Support • • cespadilla

      3
      1
      Votes
      3
      Posts
      302
      Views

      support

      @cespadilla It is fine now. We announced the Q15 winners and changed some details, sorry for the problems.

    • A

      Erroneous Data?
      Support • • antinomy

      3
      1
      Votes
      3
      Posts
      616
      Views

      support

      @antinomy Hello, sorry for delay again. We found a problem with the data provider, sorry.

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