Reference

computeFees

quantiacsToolbox.computeFees(equityCurve, managementFee, performanceFee)

Computes equity curve after fees.

Args:

equityCurve (list, numpy array) : a column vector of daily fund values

managementFee (float) : the management fee charged to the investor (a portion of the AUM charged yearly)

performanceFee (float) : the performance fee charged to the investor (the portion of the difference between a new high and the most recent high, charged daily)

Returns:

returns an equity curve with the fees subtracted. (does not include the effect of fees on equity lot size)

fillnans

quantiacsToolbox.fillnans(inArr)

Fills in (column-wise) value gaps with the most recent non-nan value. Fills in value gaps with the most recent non-nan value. Leading nan’s remain in place. The gaps are filled in only after the first non-nan entry.

Args:

inArr (list, numpy array)

Returns:

returns an array of the same size as inArr with the nan-values replaced by the most recent non-nan entry.

fillwith

quantiacsToolbox.fillwith(field, lookup)

Replaces nan entries of field, with values of lookup.

Args:

field (list, numpy array) : array whose nan-values are to be replaced

lookup (list, numpy array) : array to copy values for placement in field

Returns:

returns array with nan-values replaced by entries in lookup.

loadData

quantiacsToolbox.loadData(marketList=None, dataToLoad=None, refresh=False, beginInSample=None, endInSample=None, dataDir='tickerData')

Prepares and returns market data for specified markets. Prepares and returns related to the entries in the dataToLoad list. When refresh is true, data is updated from the Quantiacs server. If inSample is left as none, all available data dates will be returned.

Args:

marketList (list): list of market data to be supplied

dataToLoad (list): list of financial data types to load

refresh (bool): boolean value determining whether or not to update the local data from the Quantiacs server.

beginInSample (str): a str in the format of YYYYMMDD defining the begining of the time series endInSample (str): a str in the format of YYYYMMDD defining the end of the time series

Returns:

dataDict (dict): mapping all data types requested by dataToLoad. The data is returned as a numpy array or list and is ordered by marketList along columns and date along the row.

plotts

quantiacsToolbox.plotts(tradingSystem, equity, mEquity, exposure, settings, DATE, statistics, returns, marketReturns)

Plots equity curve and calculates trading system statistics

Args:

equity (list): list of equity of evaluated trading system

mEquity (list): list of equity of each market over the trading days

exposure (list): list of positions over the trading days

settings (dict): list of settings

DATE (list): list of dates corresponding to entries in equity

runts

quantiacsToolbox.runts(tradingSystem, plotEquity=True, reloadData=False, state={}, sourceData='tickerData')

Backtests a trading system. Evaluates the trading system function specified in the argument tsName and returns the struct ret. runts calls the trading system for each period with sufficient market data, and collets the returns of each call to compose a backtest.

Args:

tsName (str): Specifies the trading system to be backtested

plotEquity (bool, optional): Show the equity curve plot after the evaluation

reloadData (bool,optional): Force reload of market data

state (dict, optional): State information to resume computation of an existing backtest (for live evaluation on Quantiacs servers). State needs to be of the same form as ret

Returns:

a dict mapping keys to the relevant backesting information: trading system name, system equity, trading dates, market exposure, market equity, the errorlog, the run time, the system’s statistics, and the evaluation date.

keys and description:

‘tsName’ (str): Name of the trading system, same as tsName

‘fundDate’ (int): All dates of the backtest in the format YYYYMMDD

‘fundEquity’ (float): Equity curve for the fund (collection of all markets) ‘returns’ (float): Marketwise returns of trading system

‘marketEquity’ (float): Equity curves for each market in the fund

‘marketExposure’ (float): Collection of the returns p of the trading system function. Equivalent to the percent expsoure of each market in the fund. Normalized between -1 and 1 ‘settings’ (dict): The settings of the trading system as defined in file tsName

‘errorLog’ (list): list of strings with error messages

‘runtime’ (float): Runtime of the evaluation in seconds

‘stats’ (dict): Performance numbers of the backtest ‘evalDate’ (datetime): Last market data present in the backtest

stats

quantiacsToolbox.stats(equityCurve)

Calculates trading system statistics. Calculates and returns a dict containing the following statistics - sharpe ratio - sortino ratio - annualized returns - annualized volatility - maximum drawdown

  • the dates at which the drawdown begins and ends
  • the MAR ratio
  • the maximum time below the peak value (the dates at which the max time off peak begin and end)

Args:

equityCurve (list): the equity curve of the evaluated trading system

Returns:

statistics (dict): a dict mapping keys to corresponding trading system statistics (sharpe ratio, sortino ration, max drawdown...)

submit

quantiacsToolbox.submit(tradingSystem, tsName)

Submits trading system to Quantiacs server.

Args:

tradingSystem (file, obj, instance): accepts a filepath, a class object, or class instance.

tsName (str): the desired trading system name for display on Quantiacs website.

Returns:

returns True if upload was successful, False otherwise.

updateCheck

quantiacsToolbox.updateCheck()

Checks for new version of toolbox.

Returns:

returns True if the version of the toolbox on PYPI is not the same as the current version returns False if version is the same