Package QSTK :: Package qstkfeat :: Module featutil
[hide private]
[frames] | no frames]

Module featutil

source code

(c) 2011, 2012 Georgia Tech Research Corporation This source code is released under the New BSD license. Please see http://wiki.quantsoftware.org/index.php?title=QSTK_License for license details.

Created on Nov 7, 2011


Author: John Cornwell

Contact: JohnWCornwellV@gmail.com

Functions [hide private]
 
getMarketRel(dData, sRel='$SPX')
Calculates market relative data.
source code
 
applyFeatures(dData, lfcFeatures, ldArgs, sMarketRel=None, sLog=None)
Calculates the feature values using a list of feature functions and arguments.
source code
 
loadFeatures(sLog)
Loads cached features.
source code
 
stackSyms(ldfFeatures, dtStart=None, dtEnd=None, lsSym=None, bDelNan=True, bShowRemoved=False)
Remove symbols from the dataframes, effectively stacking all stocks on top of each other.
source code
 
normFeatures(naFeatures, fMin, fMax, bAbsolute, bIgnoreLast=True)
Normalizes the featurespace.
source code
 
normQuery(naQueries, ltWeightShift)
Normalizes the queries using the given normalization parameters generated from training data.
source code
 
createKnnLearner(naFeatures, lKnn=30, leafsize=10)
Creates a quick KNN learner
source code
 
log500(sLog)
Loads cached features.
source code
 
getFeatureFuncs()
Gets feature functions supported by the website.
source code
 
testFeature(fcFeature, dArgs)
Quick function to run a feature on some data and plot it to see if it works.
source code
Variables [hide private]
  __package__ = 'QSTK.qstkfeat'
Function Details [hide private]

getMarketRel(dData, sRel='$SPX')

source code 
Parameters:
  • dData, -, Dictionary, containing, data, to, be, used, requires, specific, naming - open/high/low/close/volume @param sRel - Stock ticker to make the data relative to, $SPX is default.
Returns:
Dictionary of market relative values

applyFeatures(dData, lfcFeatures, ldArgs, sMarketRel=None, sLog=None)

source code 
Parameters:
  • dData, -, Dictionary, containing, data, to, be, used, requires, specific, naming - open/high/low/close/volume
  • lfcFeatures - List of feature functions, most likely coming from features.py
  • ldArgs - List of dictionaries containing arguments, passed as **kwargs There is a special argument 'MR', if it exists, the data will be made market relative
  • sMarketRel - If not none, the data will all be made relative to the symbol provided
  • sLog - If not None, will be filename to log all of the features to
Returns:
list of dataframes containing values

loadFeatures(sLog)

source code 
Parameters:
  • sLog - Filename of features.
Returns:
Numpy array containing values

stackSyms(ldfFeatures, dtStart=None, dtEnd=None, lsSym=None, bDelNan=True, bShowRemoved=False)

source code 
Parameters:
  • ldfFeatures - List of data frames of features.
  • dtStart - Start time, if None, uses all
  • dtEnd - End time, if None uses all
  • lsSym - List of symbols to use, if None, all are used.
  • bDelNan - Optional, default is true: delete all rows with a NaN in it
Returns:
Numpy array containing all features as columns and all

normFeatures(naFeatures, fMin, fMax, bAbsolute, bIgnoreLast=True)

source code 
Parameters:
  • naFeatures - Numpy array of features,
  • fMin - Data frame containing the price information for all of the stocks.
  • fMax - List of feature functions, most likely coming from features.py
  • bAbsolute - If true, min value will be scaled to fMin, max to fMax, if false, +-1 standard deviations will be scaled to fit between fMin and fMax, i.e. ~69% of the values
  • bIgnoreLast - If true, last column is ignored (assumed to be classification)
Returns:
list of (weights, shifts) to be used to normalize the query points

normQuery(naQueries, ltWeightShift)

source code 
Parameters:
  • naQueries - Numpy array of queries
  • ltWeightShift - List of weights and shift amounts to be applied to each query.
Returns:
None, modifies naQueries

createKnnLearner(naFeatures, lKnn=30, leafsize=10)

source code 
Parameters:
  • naFeatures - Numpy array of features,
  • fMin - Data frame containing the price information for all of the stocks.
  • fMax - List of feature functions, most likely coming from features.py
  • bAbsolute - If true, min value will be scaled to fMin, max to fMax, if false, +-1 standard deviations will be scaled to fit between fMin and fMax, i.e. ~69% of the values
  • bIgnoreLast - If true, last column is ignored (assumed to be classification)
Returns:
None, data is modified in place

log500(sLog)

source code 
Parameters:
  • sLog - Filename of features.
Returns:
Nothing, logs features to desired location

getFeatureFuncs()

source code 
Returns:
Tuple containing (list of functions, list of arguments, list of names)

testFeature(fcFeature, dArgs)

source code 
Parameters:
  • fcFeature - Feature function to test
  • dArgs - Arguments to pass into feature function
Returns:
Void