Hi guys,
I have a question about strategy funding.
I read somewhere that if you give out a $1M of funding, let's say the strategy developer wins a contest, then the strat dev will earn a percentage (e.g. 10%) of the quarterly earnings if the strat makes a profit for that quarter and so on. And if the strat loses for the quarter then the dev does not make any money but does not lose any money either.
My question is this:
If you guys are able to get investors for the dev's strat, let's say $10M hypothetically, will the dev get to share in the greater amount of earnings percentage wise from the $10M, or will the dev only get a percentage of earnings from the $1M?
That was long winded but I hope you understand my question.
Thanks.
Best posts made by spancham
-
Strategy Funding
-
RE: Strategy Funding
@support
Thank you. That is the level of detail I was looking for.
I presume you meant though the quant would receive a fixed management fee of $10K per month for $1M of funding on a 1.0 Sharpe Ratio strategy? -
RE: Strategy Funding
@support
Thank you for responding.- Can you give me an idea pls what is the monthly $ amount a quant can make from the fixed fee? Just a ballpark range.
- What is a 'long track record'? How much time would the strategy have to be running?
-
RE: Strategy Funding
@support
What if I or my family members wanted to invest in my own strategy?
Where can I find information on Quantiacs 'live' hedge fund services please?
Is that a different company? I cannot find a tab for investors on the site?
Thanks. -
Please advise on p settings. Thanks.
Hello, first of all, thanks for your great platform. Beats having to build my own backtester so I am trying to learn it.
I am attempting a simple pairs trading strategy for the WTI vs Brent Crude spread, code below.
For some reason, it does not stop running & also does not plot the Equity chart. I don't believe I am understanding correctly how to set the position exposure.And the following warning is given:
C:\Users\sheikh\anaconda3\lib\site-packages\quantiacsToolbox\quantiacsToolbox.py:881: RuntimeWarning: invalid value encountered in true_divide
position = position / np.sum(abs(position))import numpy as np import pandas as pd def mySettings(): settings = {} settings['markets'] = ['F_CL', 'F_BC'] settings['beginInSample'] = '20171115' settings['endInSample'] = '20210201' settings['lookback'] = 84 settings['budget'] = 10**6 settings['slippage'] = 0.05 settings['zthreshold'] = 1.75 settings['p'] = np.array([0., 0.]) settings['count'] = 0 return settings def myTradingSystem(DATE, CLOSE, exposure, equity, settings): s1 = pd.Series(CLOSE[-settings['lookback']:,0]) s2 = pd.Series(CLOSE[-settings['lookback']:,1]) # Compute mean of the spread up to now mvavg = np.mean(np.log(s1/s2)) # Compute stdev of the spread up to now stdev = np.std(np.log(s1/s2)) # Compute spread current_spread = np.log(CLOSE[-1,0] / CLOSE[-1,1]) # Compute z-score zscore = (current_spread - mvavg) / stdev if stdev > 0 else 0 p = settings['p'] if zscore >= settings['zthreshold']: p = np.array([-0.5,0.5]) settings['p'] = p elif zscore <= -settings['zthreshold']: p = np.array([0.5,-0.5]) settings['p'] = p else: p = settings['p'] settings['count'] += 1 if settings['count'] % 50 == 0: print(settings['count'], equity, exposure) return p, settings
-
RE: Please advise on p settings. Thanks.
Hi again @support
I read through everything and all the examples but to be honest the new format is not straightforward to me. I was wondering if there are Quantiacs developers available that you can recommend or put me in contact with to help convert my pairs strategy from the legacy toolbox format to the new format. I do not mind paying for their services.Once I see how it's done using my strategy, I think I can understand how to set up my other strategies from there on.
Thanks for your help.
Sheikh -
Optimizer still running
Hi @ support (Stefano)
Thank you for your message. No, I was not able to resolve the issue. If you figured out a solution, kindly post it here. If you want me to post my code again, let me know pls.
I decided to go back and try to get the original Quantiacs example itself to run but alas that too has been running for several hours 6+ now. Screenshot below. I tried using 20 workers, I don't know what's reasonable but my PC is pretty powerful. It's still running.
This is your example found in your documentation, no change. As you can see the first part ran & printed out ok. -
RE: Machine Learning Strategy
@support
ok guys, I tried what you suggested and I am running into all sorts of problems.
I want to pass several features altogether in one dataframe.
Are you guys thinking that I want to 'test' one feature at a time and that is why you are suggesting working with more than one dataframe?
Here is an example of some code I tried, but I would still have to merge the dataframes in order to pass the feature set to the classifier:def get_features(data): # let's come up with features for machine learning # take the logarithm of closing prices def remove_trend(prices_pandas_): prices_pandas = prices_pandas_.copy(True) assets = prices_pandas.columns print(assets) for asset in assets: print(prices_pandas[asset]) prices_pandas[asset] = np.log(prices_pandas[asset]) return prices_pandas # Feature 1 price = data.sel(field="close").ffill('time').bfill('time').fillna(0) # fill NaN price_df = price.to_dataframe() # Feature 2 vol = data.sel(field="vol").ffill('time').bfill('time').fillna(0) # fill NaN vol_df = vol.to_dataframe() # Merge dataframes for_result = pd.merge(price_df, vol_df, on='time') for_result = for_result.drop(['field_x', 'field_y'], axis=1) features_no_trend_df = remove_trend(for_result) return features_no_trend_df
Can you help with some code as to what you are suggesting?
Thanks -
RE: Share the state between iterations
Hi @support
Thanks but I tried that and it still did not work.
Just so you understand, I do NOT work locally, I only work in the Quantiacs online cloud Jupyter env.
I ran the update you suggested in my Quantiacs online Jupyter and it still did not work. I'm guessing you guys keep the env updated though.
I'm still getting the same error:
TypeError: backtest() got an unexpected keyword argument 'collect_all_states'Any suggestions pls?
Latest posts made by spancham
-
RE: Strategy Funding
@support
What if I or my family members wanted to invest in my own strategy?
Where can I find information on Quantiacs 'live' hedge fund services please?
Is that a different company? I cannot find a tab for investors on the site?
Thanks. -
Pairs trading with states iterations
Hi @support
I am trying to merge my pairs strategy with the Quantiacs states iterations example.
It runs but I am still not certain if my code is correct however.
Can you have a look at my code below please and see if the implementation is correct?
What corrections would you make?
Don't be concerned that I am posting it here, these are not all the parameters or the futures contracts that I would use.import xarray as xr import numpy as np import qnt.data as qndata import qnt.backtester as qnbt def load_data(period): data = qndata.futures_load_data(tail=period) return data def strategy(data, state): zthreshold = 1.25 lookback_trading_days = 60 markets = ['F_GC', 'F_SI'] close = data.sel(field='close', asset=markets).transpose('time', 'asset') last_close = close.ffill('time').isel(time=-1) # state may be null, so define a default value if state is None: state = { "zscore": last_close, "zscore_prev": last_close, "output": xr.zeros_like(last_close) } zscore_prev = state['zscore'] zscore_prev_prev = state['zscore_prev'] output_prev = state['output'] # align the arrays to prevent problems in case the asset list changes zscore_prev, zscore_prev_prev, last_close = xr.align(zscore_prev, zscore_prev_prev, last_close, join='right') s1 = close[-lookback_trading_days:, 0] s2 = close[-lookback_trading_days:, 1] # Compute mean of the spread up to now mvavg = np.mean(np.log(s1/s2)) # Compute stdev of the spread up to now stdev = np.std(np.log(s1/s2)) # Compute current spread current_spread = np.log(s1[-1] / s2[-1]) # Compute z-score zscore = (current_spread - mvavg) / stdev if stdev > 0 else 0 if zscore >= zthreshold: output = [-0.5, 0.5] elif zscore <= -zthreshold: output = [0.5, -0.5] else: output = output_prev next_state = { "zscore": zscore, "zscore_prev": zscore_prev, "output": output } return xr.DataArray(output, dims=['asset'], coords=dict(asset=markets)), next_state weights, state = qnbt.backtest( competition_type="futures", # Futures contest lookback_period=100, # lookback in calendar days test_period=16*365, strategy=strategy, analyze=True, build_plots=True, collect_all_states=False # if it is False, then the function returns the last state, otherwise - all states )
Thank you!
-
RE: Share the state between iterations
@support
ok I did what @antinomy said below and the 'state' strategy worked.
https://quantiacs.com/community/topic/46/macroeconomic-data-with-quantiacs/3?_=1619554449031However, 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. -
RE: Share the state between iterations
@support
I am working in the Quantiacs online env in my account, why doesn't it catch the latest libraries?
Anyway, I created a new Jupyter notebook with the strategy as suggested and it still does NOT work, same error msg. -
RE: Share the state between iterations
@support
Sorry friend, that still does not work.
I am working in the Quantiacs online cloud Jupyter environment.
I am NOT working locally.
I copied your example template as is and just added load_data().
Below is what I am running:import xarray as xr import numpy as np import qnt.data as qndata import qnt.backtester as qnbt def load_data(period): data = qndata.futures_load_data(tail=period) return data def strategy(data, state): close = data.sel(field="close") last_close = close.ffill('time').isel(time=-1) # state may be null, so define a default value if state is None: state = { "ma": last_close, "ma_prev": last_close, "output": xr.zeros_like(last_close) } ma_prev = state['ma'] ma_prev_prev = state['ma_prev'] output_prev = state['output'] # align the arrays to prevent problems in case the asset list changes ma_prev, ma_prev_prev, last_close = xr.align(ma_prev, ma_prev_prev, last_close, join='right') ma = ma_prev.where(np.isfinite(ma_prev), last_close) * 0.97 + last_close * 0.03 buy_signal = np.logical_and(ma > ma_prev, ma_prev > ma_prev_prev) stop_signal = ma < ma_prev_prev output = xr.where(buy_signal, 1, output_prev) output = xr.where(stop_signal, 0, output) next_state = { "ma": ma, "ma_prev": ma_prev, "output": output } return output, next_state weights, state = qnbt.backtest( competition_type="futures", # Futures contest lookback_period=365, # lookback in calendar days start_date="2006-01-01", strategy=strategy, analyze=True, build_plots=True, collect_all_states=False # if it is False, then the function returns the last state, otherwise - all states )
Error I'm getting is:
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-1-434dffafaefc> in <module> 50 analyze=True, 51 build_plots=True, ---> 52 collect_all_states=False # if it is False, then the function returns the last state, otherwise - all states 53 ) TypeError: backtest() got an unexpected keyword argument 'collect_all_states'
The reason I want to get the 'state' working is that I have a pairs trading strategy that needs it.
Any help would be greatly appreciated.
Thanks.In a related issue, when I run the macroeconomic example, I get the following error:
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-1-62eeefb4e65f> in <module> 76 strategy=strategy, 77 analyze=True, ---> 78 build_plots=True 79 ) ~/book/qnt/backtester.py in backtest(competition_type, strategy, load_data, lookback_period, test_period, start_date, window, step, analyze, build_plots) 66 data, time_series = extract_time_series(data) 67 print("Run pass...") ---> 68 result = strategy(data) 69 if result is None: 70 log_err("ERROR! Strategy output is None!") TypeError: strategy() missing 1 required positional argument: 'state'
-
RE: Share the state between iterations
Hi @support
Thanks but I tried that and it still did not work.
Just so you understand, I do NOT work locally, I only work in the Quantiacs online cloud Jupyter env.
I ran the update you suggested in my Quantiacs online Jupyter and it still did not work. I'm guessing you guys keep the env updated though.
I'm still getting the same error:
TypeError: backtest() got an unexpected keyword argument 'collect_all_states'Any suggestions pls?
-
RE: Strategy Funding
@support
Thank you. That is the level of detail I was looking for.
I presume you meant though the quant would receive a fixed management fee of $10K per month for $1M of funding on a 1.0 Sharpe Ratio strategy? -
RE: Share the state between iterations
@support
Please advise what to do here. Thanks.--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-1-434dffafaefc> in <module> 50 analyze=True, 51 build_plots=True, ---> 52 collect_all_states=False # if it is False, then the function returns the last state, otherwise - all states 53 ) TypeError: backtest() got an unexpected keyword argument 'collect_all_states'