BpaLibrary   "Bpa" 
TODO: library of Brooks Price Action concepts
 isBreakoutBar(atr, high, low, close, open, tail, size) 
  TODO: check if the bar is a breakout based on the specified conditions
  Parameters:
     atr : TODO: atr value
     high : TODO: high price
     low : TODO: low price
     close : TODO: close price 
     open : TODO: open price
     tail : TODO: decimal value for a percent that represent the size of the tail of the bar that cant be preceeded to be considered strong close
     size : TODO: decimal value for a percent that represents by how much the breakout bar should be bigger than others to be considered one
  Returns: TODO: boolean value, true if breakout bar, false otherwise
Statistics
LibraryCOTLibrary   "LibraryCOT" 
This library provides tools to help Pine programmers fetch Commitment of Traders (COT) data for futures.
 rootToCFTCCode(root) 
  Accepts a futures root and returns the relevant CFTC code.
  Parameters:
     root : Root prefix of the future's symbol, e.g. "ZC" for "ZC1!"" or "ZCU2021".
  Returns: The  part of a COT ticker corresponding to `root`, or "" if no CFTC code exists for the `root`.
 currencyToCFTCCode(curr) 
  Converts a currency string to its corresponding CFTC code.
  Parameters:
     curr : Currency code, e.g., "USD" for US Dollar.
  Returns: The  corresponding to the currency, if one exists.
 optionsToTicker(includeOptions) 
  Returns the  part of a COT ticker using the `includeOptions` value supplied, which determines whether options data is to be included.
  Parameters:
     includeOptions : A "bool" value: 'true' if the symbol should include options and 'false' otherwise.
  Returns: The  part of a COT ticker: "FO" for data that includes options and "F" for data that doesn't.
 metricNameAndDirectionToTicker(metricName, metricDirection) 
  Returns a string corresponding to a metric name and direction, which is one component required to build a valid COT ticker ID.
  Parameters:
     metricName : One of the metric names listed in this library's chart. Invalid values will cause a runtime error.
     metricDirection : Metric direction. Possible values are: "Long", "Short", "Spreading", and "No direction". Valid values vary with metrics. Invalid values will cause a runtime error.
  Returns: The  part of a COT ticker ID string, e.g., "OI_OLD" for "Open Interest" and "No direction", or "TC_L" for "Traders Commercial" and "Long".
 typeToTicker(metricType) 
  Converts a metric type into one component required to build a valid COT ticker ID. See the "Old and Other Futures" section of the CFTC's Explanatory Notes for details on types.
  Parameters:
     metricType : Metric type. Accepted values are: "All", "Old", "Other".
  Returns: The  part of a COT ticker.
 convertRootToCOTCode(mode, convertToCOT) 
  Depending on the `mode`, returns a CFTC code using the chart's symbol or its currency information when `convertToCOT = true`. Otherwise, returns the symbol's root or currency information. If no COT data exists, a runtime error is generated.
  Parameters:
     mode : A string determining how the function will work. Valid values are:
"Root": the function extracts the futures symbol root (e.g. "ES" in "ESH2020") and looks for its CFTC code.
"Base currency": the function extracts the first currency in a pair (e.g. "EUR" in "EURUSD") and looks for its CFTC code.
"Currency": the function extracts the quote currency ("JPY" for "TSE:9984" or "USDJPY") and looks for its CFTC code.
"Auto": the function tries the first three modes (Root -> Base Currency -> Currency) until a match is found.
     convertToCOT : "bool" value that, when `true`, causes the function to return a CFTC code. Otherwise, the root or currency information is returned. Optional. The default is `true`.
  Returns: If `convertToCOT` is `true`, the  part of a COT ticker ID string. If `convertToCOT` is `false`, the root or currency extracted from the current symbol.
 COTTickerid(COTType, CTFCCode, includeOptions, metricName, metricDirection, metricType) 
  Returns a valid TradingView ticker for the COT symbol with specified parameters.
  Parameters:
     COTType : A string with the type of the report requested with the ticker, one of the following: "Legacy", "Disaggregated", "Financial".
     CTFCCode : The  for the asset, e.g., wheat futures (root "ZW") have the code "001602".
     includeOptions : A boolean value. 'true' if the symbol should include options and 'false' otherwise.
     metricName : One of the metric names listed in this library's chart.
     metricDirection : Direction of the metric, one of the following: "Long", "Short", "Spreading", "No direction". 
     metricType : Type of the metric. Possible values: "All", "Old", and "Other".
  Returns: A ticker ID string usable with `request.security()` to fetch the specified Commitment of Traders data.
TradingWolfLibaryLibrary   "TradingWolfLibary" 
 getMA(int, string) 
  Gets a Moving Average based on type
  Parameters:
     int : length The MA period
     string : maType The type of MA
  Returns: A moving average with the given parameters
 minStop(float, simple, float, string) 
  Calculates and returns Minimum stop loss
  Parameters:
     float : entry price (Close if calculating on the entry candle)
     simple : int Calculate how many bars back to look at swings
     float : Minimum Stop Loss allowed (Should be x 0.01) if input
     string : Direciton of trade either "Long" or "Short"
  Returns: Stop Loss Value
KernelFunctionsLibrary   "KernelFunctions" 
This library provides non-repainting kernel functions for Nadaraya-Watson estimator implementations. This allows for easy substitution/comparison of different kernel functions for one another in indicators. Furthermore, kernels can easily be combined with other kernels to create newer, more customized kernels. Compared to Moving Averages (which are really just simple kernels themselves), these kernel functions are more adaptive and afford the user an unprecedented degree of customization and flexibility.
 rationalQuadratic(_src, _lookback, _relativeWeight, _startAtBar) 
  Rational Quadratic Kernel - An infinite sum of Gaussian Kernels of different length scales.
  Parameters:
     _src :  The source series.
     _lookback :  The number of bars used for the estimation. This is a sliding value that represents the most recent historical bars.
     _relativeWeight :  Relative weighting of time frames. Smaller values result in a more stretched-out curve, and larger values will result in a more wiggly curve. As this value approaches zero, the longer time frames will exert more influence on the estimation. As this value approaches infinity, the behavior of the Rational Quadratic Kernel will become identical to the Gaussian kernel.
     _startAtBar :  Bar index on which to start regression. The first bars of a chart are often highly volatile, and omitting these initial bars often leads to a better overall fit.
  Returns: yhat  The estimated values according to the Rational Quadratic Kernel.
 gaussian(_src, _lookback, _startAtBar) 
  Gaussian Kernel - A weighted average of the source series. The weights are determined by the Radial Basis Function (RBF).
  Parameters:
     _src :  The source series.
     _lookback :  The number of bars used for the estimation. This is a sliding value that represents the most recent historical bars.
     _startAtBar :  Bar index on which to start regression. The first bars of a chart are often highly volatile, and omitting these initial bars often leads to a better overall fit.
  Returns: yhat  The estimated values according to the Gaussian Kernel.
 periodic(_src, _lookback, _period, _startAtBar) 
  Periodic Kernel - The periodic kernel (derived by David Mackay) allows one to model functions that repeat themselves exactly.
  Parameters:
     _src :  The source series.
     _lookback :  The number of bars used for the estimation. This is a sliding value that represents the most recent historical bars.
     _period :  The distance between repititions of the function.
     _startAtBar :  Bar index on which to start regression. The first bars of a chart are often highly volatile, and omitting these initial bars often leads to a better overall fit.
  Returns: yhat  The estimated values according to the Periodic Kernel.
 locallyPeriodic(_src, _lookback, _period, _startAtBar) 
  Locally Periodic Kernel - The locally periodic kernel is a periodic function that slowly varies with time. It is the product of the Periodic Kernel and the Gaussian Kernel.
  Parameters:
     _src :  The source series.
     _lookback :  The number of bars used for the estimation. This is a sliding value that represents the most recent historical bars.
     _period :  The distance between repititions of the function.
     _startAtBar :  Bar index on which to start regression. The first bars of a chart are often highly volatile, and omitting these initial bars often leads to a better overall fit.
  Returns: yhat  The estimated values according to the Locally Periodic Kernel.
ahpuhelperLibrary   "ahpuhelper" 
Helper Library for Auto Harmonic Patterns UltimateX. It is not meaningful for others. This is supposed to be private library. But, publishing it to make sure that I don't delete accidentally. Some functions may be useful for coders.
 insert_open_trades_table_column(showOpenTrades, table_id, column, colors, values, intStatus, harmonicTrailingStartState, lblSizeOpenTrades) 
  add data to open trades table column
  Parameters:
     showOpenTrades : flag to show open trades table
     table_id : Table Id
     column : refers to pattern data
     colors : backgroud and text color array
     values : cell values
     intStatus : status as integer
     harmonicTrailingStartState : trailing Start state as per configs
     lblSizeOpenTrades : text size
  Returns: nextColumn
 populate_closed_stats(ClosedStatsPosition, bullishCounts, bearishCounts, bullishRetouchCounts, bearishRetouchCounts, bullishSizeMatrix, bearishSizeMatrix, bullishRR, bearishRR, allPatternLabels, flags, rowMain, rowHeaders) 
  populate closed stats for harmonic patterns
  Parameters:
     ClosedStatsPosition : Table position for closed stats
     bullishCounts : Matrix containing bullish trade stats
     bearishCounts : Matrix containing bearish trade stats
     bullishRetouchCounts : Matrix containing bullish trade stats for those which retouched entry
     bearishRetouchCounts : Matrix containing bearish trade stats for those which retouched entry
     bullishSizeMatrix : Matrix containing data about size of bullish patterns
     bearishSizeMatrix : Matrix containing data about size of bearish patterns
     bullishRR : Matrix containing Risk Reward data of bullish patterns
     bearishRR : Matrix containing Risk Reward data of bearish patterns
     allPatternLabels : array containing pattern labels
     flags : display flags
     rowMain : Pattern header data
     rowHeaders : header grouping data
  Returns: void
 get_rr_details(patternTradeDetails, harmonicTrailingStartState, disableTrail, breakEvenTrail) 
  calculate and return risk reward based on targets and stops
  Parameters:
     patternTradeDetails : array containing stop, entry and targets
     harmonicTrailingStartState : trailing point
     disableTrail : If set, ignores trailing point
     breakEvenTrail : If set, trailing does not go beyond breakeven.
  Returns: nextColumn
normsinvLibrary   "normsinv" 
 Description:  
Returns the inverse of the standard normal cumulative distribution. 
The distribution has a mean of zero and a standard deviation of one; i.e., 
normsinv seeks that value z such that a normal distribtuion of mean of zero 
and standard deviation one is equal to the input probability.
 Reference: 
github.com
 normsinv(y0) 
  Returns the inverse of the standard normal cumulative distribution. The distribution has a mean of zero and a standard deviation of one.
  Parameters:
     y0 : float, probability corresponding to the normal distribution.
  Returns: float, z-score
cndevLibrary   "cndev" 
This function returns the inverse of cumulative normal distribution function
Reference:
The Full Monte, by Boris Moro, Union Bank of Switzerland . RISK 1995(2)
 CNDEV(U) 
  Returns the inverse of cumulative normal distribution function
  Parameters:
     U : float, 
  Returns: float.
Strategy PnL LibraryLibrary   "Strategy_PnL_Library" 
TODO: This is a library that helps you learn current pnl of open position and use it to create your own dynamic take profit or stop loss rules based on current level of your profit. It should only be used with strategies.
 inTrade() 
  inTrade: Checks if a position is currently open.
  Returns: bool: true for yes, false for no.
 notInTrade() 
  inTrade: Checks if a position is currently open. Interchangeable with inTrade but just here for simple semantics.
  Returns: bool: true for yes, false for no.
 pnl() 
  pnl: Calculates current profit or loss of position after the commission. If the strategy is not in trade it will always return na.
  Returns: float: Current Profit or Loss of position, positive values for profit, negative values for loss.
 entryBars() 
  entryBars: Checks how many bars it's been since the entry of the position.
  Returns: int: Returns a int of strategy entry bars back. Minimum value is always corrected to 1 to avoid lookback errors.
 pnlvelocity() 
  pnlvelocity: Calculates the velocity of pnl by following the change in open profit compared to previous bar. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float value of pnl velocity.
 pnlacc() 
  pnlacc: Calculates the acceleration of pnl by following the change in profit velocity compared to previous bar. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float value of pnl acceleration.
 pnljerk() 
  pnljerk: Calculates the jerk of pnl by following the change in profit acceleration compared to previous bar. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float value of pnl jerk.
 pnlhigh() 
  pnlhigh: Calculates the highest value the pnl has reached since the start of the current position. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float highest value the pnl has reached.
 pnllow() 
  pnllow: Calculates the lowest value the pnl has reached since the start of the current position. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float lowest value the pnl has reached.
 pnldev() 
  pnldev: Calculates the deviance of the pnl since the start of the current position. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float deviance value of the pnl.
 pnlvar() 
  pnlvar: Calculates the variance value of the pnl since the start of the current position. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float variance value of the pnl.
 pnlstdev() 
  pnlstdev: Calculates the stdev value of the pnl since the start of the current position. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float stdev value of the pnl.
 pnlmedian() 
  pnlmedian: Calculates the median value of the pnl since the start of the current position. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float median value of the pnl.
ctndLibrary   "ctnd" 
 Description: 
Double precision algorithm to compute the cumulative trivariate normal distribution 
found in A.Genz, Numerical computation of rectangular bivariate and trivariate normal 
and t probabilities”, Statistics and Computing, 14, (3), 2004. The cumulative trivariate 
normal is needed to price window barrier options, see G.F. Armstrong, Valuation formulae
or window barrier options”, Applied Mathematical Finance, 8, 2001.
 References: 
 link.springer.com 
 www.tandfonline.com 
 citeseerx.ist.psu.edu 
The Complete Guide to Option Pricing Formulas, 2nd ed. (Espen Gaarder Haug)
 CTND(LIMIT1, LIMIT2, LIMIT3, SIGMA1, SIGMA2, SIGMA3) 
  Returns the Cumulative Trivariate Normal Distribution
  Parameters:
     LIMIT1 : float, 
     LIMIT2 : float, 
     LIMIT3 : float, 
     SIGMA1 : float, 
     SIGMA2 : float, 
     SIGMA3 : float, 
  Returns: float.
combinLibrary   "combin" 
 Description: 
The combin function is a the combination function 
as it calculates the number of possible combinations for two given numbers.
This function takes two arguments: the number and the number_chosen. 
For example, if the number is 5 and the number chosen is 1, 
there are 5 combinations, giving 5 as a result.
 Reference: 
 ideone.com 
 support.microsoft.com 
 combin(n, kin) 
  Returns the number of combinations for a given number of items. Use to determine the total possible number of groups for a given number of items.
  Parameters:
     n : int, The number of items.
     kin : int, The number of items in each combination.
  Returns: int.
norminvLibrary   "norminv" 
 Description: 
An inverse normal distribution is a way to work backwards 
from a known probability to find an x-value. It is an informal term and 
doesn't refer to a particular probability distribution. Returns the 
value of the inverse normal distribution function for a specified value, 
mean, and standard deviation.
 Reference: 
 github.com 
 support.microsoft.com 
 norminv(x, mean, stdev) 
  Returns the value of the inverse normal distribution function for a specified value, mean, and standard deviation.
  Parameters:
     x : float, The input to the normal distribution function.
     mean : float, The mean (mu) of the normal distribution function
     stdev : float, The standard deviation (sigma) of the normal distribution function.
  Returns: float.
cbndLibrary   "cbnd" 
 Description: 
A standalone Cumulative Bivariate Normal Distribution (CBND) functions that do not require any external libraries. 
This includes 3 different CBND calculations: Drezner(1978), Drezner and Wesolowsky (1990), and Genz (2004)
 Comments: 
The standardized cumulative normal distribution function returns the probability that one random 
variable is less than a and that a second random variable is less than b when the correlation 
between the two variables is p. Since no closed-form solution exists for the bivariate cumulative 
normal distribution, we present three approximations. The first one is the well-known 
Drezner (1978) algorithm. The second one is the more efficient Drezner and Wesolowsky (1990) 
algorithm. The third is the Genz (2004) algorithm, which is the most accurate one and therefore
our recommended algorithm. West (2005b) and Agca and Chance (2003) discuss the speed and 
accuracy of bivariate normal distribution approximations for use in option pricing in 
ore detail.
 Reference: 
The Complete Guide to Option Pricing Formulas, 2nd ed. (Espen Gaarder Haug)
 CBND1(A, b, rho) 
  Returns the Cumulative Bivariate Normal Distribution (CBND) using Drezner 1978 Algorithm
  Parameters:
     A : float, 
     b : float, 
     rho : float, 
  Returns: float.
 CBND2(A, b, rho) 
  Returns the Cumulative Bivariate Normal Distribution (CBND) using Drezner and Wesolowsky (1990) function
  Parameters:
     A : float, 
     b : float, 
     rho : float, 
  Returns: float.
 CBND3(x, y, rho) 
  Returns the Cumulative Bivariate Normal Distribution (CBND) using Genz (2004) algorithm (this is the preferred method)
  Parameters:
     x : float, 
     y : float, 
     rho : float, 
  Returns: float.
cndLibrary   "cnd" 
Cumulative Normal Distribution 
 CND1(x) 
  Returns the Cumulative Normal Distribution (CND) using the Hart (1968) method. (preferred method, 14-18 decimal accuracy)
  Parameters:
     x : float, 
  Returns: float.
 CND2(x) 
  Returns the Cumulative Normal Distribution (CND) using the Abromowitz and Stegun (1974) Polynomial Approximation.
  Parameters:
     x : float, 
  Returns: float.
 CND3(x) 
  Returns the Cumulative Normal Distribution (CND) using Newton-Cotes method, Boole’s rule
  Parameters:
     x : float, 
  Returns: float.
chi2InvLibrary   "chi2Inv" 
 chi2Inv(p, n) 
  Returns the inverse cumulative distribution function (icdf) of the chi-square distribution with degrees of freedom nu, evaluated at the probability values in p. Goldstein approximation
  Parameters:
     p : float, probability 
     n : float, degress of freedom source.
  Returns: float.
TradersCustomLibraryLibrary   "TradersCustomLibrary" 
TODO: add library description here
 SelectOptimalTimeframeTrendlineSettings() 
 calculateShortStopLoss() 
 calculateLongStopLoss() 
 werdygerTrend() 
 trendLines() 
 stoch() 
 timeToString()
TALibrary   "TA" 
General technical analysis functions
 div_bull(pS, iS, cp_length_after, cp_length_before, pivot_length, lookback, no_broken, pW, iW, hidW, regW) 
  Test for bullish divergence
  Parameters:
     pS : Price series (float)
     iS : Indicator series (float)
     cp_length_after : Bars after current (divergent) pivot low to be considered a valid pivot (optional int)
     cp_length_before : Bars before current (divergent) pivot low to be considered a valid pivot (optional int)
     pivot_length : Bars before and after prior pivot low to be considered valid pivot (optional int)
     lookback : Bars back to search for prior pivot low (optional int)
     no_broken : Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool)
     pW : Weight of change in price, used in degree of divergence calculation (optional float)
     iW : Weight of change in indicator, used in degree of divergence calculation (optional float)
     hidW : Weight of hidden divergence, used in degree of divergence calculation (optional float)
     regW : Weight of regular divergence, used in degree of divergence calculation (optional float)
  Returns:  
flag = true if divergence exists (bool)
degree = degree (strength) of divergence (float)
type = 1 = regular, 2 = hidden (int)
lx1 = x coordinate 1 (int)
ly1 = y coordinate 1 (float)
lx2 = x coordinate 2 (int)
ly2 = y coordinate 2 (float)
 div_bear(pS, iS, cp_length_after, cp_length_before, pivot_length, lookback, no_broken, pW, iW, hidW, regW) 
  Test for bearish divergence
  Parameters:
     pS : Price series (float)
     iS : Indicator series (float)
     cp_length_after : Bars after current (divergent) pivot high to be considered a valid pivot (optional int)
     cp_length_before : Bars before current (divergent) pivot highto be considered a valid pivot (optional int)
     pivot_length : Bars before and after prior pivot high to be considered valid pivot (optional int)
     lookback : Bars back to search for prior pivot high (optional int)
     no_broken : Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool)
     pW : Weight of change in price, used in degree of divergence calculation (optional float)
     iW : Weight of change in indicator, used in degree of divergence calculation (optional float)
     hidW : Weight of hidden divergence, used in degree of divergence calculation (optional float)
     regW : Weight of regular divergence, used in degree of divergence calculation (optional float)
  Returns:  
flag = true if divergence exists (bool)
degree = degree (strength) of divergence (float)
type = 1 = regular, 2 = hidden (int)
lx1 = x coordinate 1 (int)
ly1 = y coordinate 1 (float)
lx2 = x coordinate 2 (int)
ly2 = y coordinate 2 (float)
AllTimeHighLowLibrary   "AllTimeHighLow" 
Provides functions calculating the all-time high/low of values.
 hi(val) 
  Calculates the all-time high of a series.
  Parameters:
     val : Series to use (`high` is used if no argument is supplied).
  Returns: The all-time high for the series.
 lo(val) 
  Calculates the all-time low of a series.
  Parameters:
     val : Series to use (`low` is used if no argument is supplied).
  Returns: The all-time low for the series.
L_BetaLibrary   "L_Beta" 
TODO: add library description here
 length() 
 beta() 
 simple_beta() 
 index_selector()
CalulateWinLossLibrary   "CalulateWinLoss" 
TODO: add library description here
 colorwhitered(x) 
  TODO: add function description here
  Parameters:
     x : TODO: add parameter x description here
  Returns: TODO: add what function returns
 colorredwhite() 
 cal()
FunctionPatternFrequencyLibrary   "FunctionPatternFrequency" 
Counts the word or integer number pattern frequency on a array.
reference:
rosettacode.org
 count(pattern) 
  counts the number a pattern is repeated.
  Parameters:
     pattern : : array : array with patterns to be counted.
  Returns: 
    array	: list of unique patterns.
    array		: list of counters per pattern.
  usage:
    count(array.from('a','b','c','a','b','a'))
 count(pattern) 
  counts the number a pattern is repeated.
  Parameters:
     pattern : : array : array with patterns to be counted.
  Returns: 
    array	: list of unique patterns.
    array	: list of counters per pattern.
  usage:
    count(array.from(1,2,3,1,2,1))
DatasetWeatherTokyoMeanAirTemperatureLibrary   "DatasetWeatherTokyoMeanAirTemperature" 
Provides a data set of the monthly mean air temperature (°C) for the city of Tokyo in Japan.
this was just for fun, no financial implications in this.
reference:
www.data.jma.go.jp
TOKYO   WMO Station ID:47662 Lat 35o41.5'N  Lon 139o45.0'E
 year_() 
  the years of the data set.
  Returns: array : year values.
 january() 
  the january values of the dataset
  Returns: array\ : data values for january.
 february() 
  the february values of the dataset
  Returns: array\ : data values for february.
 march() 
  the march values of the dataset
  Returns: array\ : data values for march.
 april() 
  the april values of the dataset
  Returns: array\ : data values for april.
 may() 
  the may values of the dataset
  Returns: array\ : data values for may.
 june() 
  the june values of the dataset
  Returns: array\ : data values for june.
 july() 
  the july values of the dataset
  Returns: array\ : data values for july.
 august() 
  the august values of the dataset
  Returns: array\ : data values for august.
 september() 
  the september values of the dataset
  Returns: array\ : data values for september.
 october() 
  the october values of the dataset
  Returns: array\ : data values for october.
 november() 
  the november values of the dataset
  Returns: array\ : data values for november.
 december() 
  the december values of the dataset
  Returns: array\ : data values for december.
 annual() 
  the annual values of the dataset
  Returns: array\ : data values for annual.
 select_month(idx) 
  get the temperature values for a specific month.
  Parameters:
     idx : int, month index (1 -> 12 | any other value returns annual average values).
  Returns: array\ : data values for selected month.
 select_value(year_, month_) 
  get the temperature value of a specified year and month.
  Parameters:
     year_ : int, year value.
     month_ : int, month index (1 -> 12 | any other value returns annual average values).
  Returns: float : value of specified year and month.
 diff_to_median(month_) 
  the difference of the month air temperature (ºC) to the median of the sample.
  Parameters:
     month_ : int, month index (1 -> 12 | any other value returns annual average values).
  Returns: float : difference of current month to median in (Cº)
FunctionDynamicTimeWarpingLibrary   "FunctionDynamicTimeWarping" 
"In time series analysis, dynamic time warping (DTW) is an algorithm for 
measuring similarity between two temporal sequences, which may vary in 
speed. For instance, similarities in walking could be detected using DTW, 
even if one person was walking faster than the other, or if there were 
accelerations and decelerations during the course of an observation. 
DTW has been applied to temporal sequences of video, audio, and graphics 
data — indeed, any data that can be turned into a linear sequence can be 
analyzed with DTW. A well-known application has been automatic speech 
recognition, to cope with different speaking speeds. Other applications 
include speaker recognition and online signature recognition. 
It can also be used in partial shape matching applications." 
"Dynamic time warping is used in finance and econometrics to assess the 
quality of the prediction versus real-world data."
~~ wikipedia
reference:
en.wikipedia.org
towardsdatascience.com
github.com
 cost_matrix(a, b, w) 
  Dynamic Time Warping procedure.
  Parameters:
     a : array, data series.
     b : array, data series.
     w : int         , minimum window size.
  Returns: matrix optimum match matrix.
 traceback(M) 
  perform a backtrace on the cost matrix and retrieve optimal paths and cost between arrays.
  Parameters:
     M : matrix, cost matrix.
  Returns: tuple:
array aligned 1st array of indices.
array aligned 2nd array of indices.
float      final cost.
reference:
github.com
 report(a, b, w) 
  report ordered arrays, cost and cost matrix.
  Parameters:
     a : array, data series.
     b : array, data series.
     w : int        , minimum window size.
  Returns: string report.
FunctionKellyCriterionLibrary   "FunctionKellyCriterion" 
Kelly criterion methods.
the kelly criterion helps with the decision of how much one should invest in
a asset as long as you know the odds and expected return of said asset.
 simplified(win_p, rr) 
  simplified version of the kelly criterion formula.
  Parameters:
     win_p : float, probability of winning.
     rr : float, reward to risk rate.
  Returns: float, optimal fraction to risk.
usage:
simplified(0.55, 1.0)
 partial(win_p, loss_p, win_rr, loss_rr) 
  general form of the kelly criterion formula.
  Parameters:
     win_p : float, probability of the investment returns a positive outcome.
     loss_p : float, probability of the investment returns a negative outcome.
     win_rr : float, reward on a positive outcome.
     loss_rr : float, reward on a negative outcome.
  Returns: float, optimal fraction to risk.
usage:
partial(0.6, 0.4, 0.6, 0.1)
 from_returns(returns) 
  Calculate the fraction to invest from a array of returns.
  Parameters:
     returns : array trade/asset/strategy returns.
  Returns: float, optimal fraction to risk.
usage:
from_returns(array.from(0.1,0.2,0.1,-0.1,-0.05,0.05))
 final_f(fraction, max_expected_loss) 
  Final fraction, eg. if fraction is 0.2 and expected max loss is 10% 
then you should size your position as 0.2/0.1=2 (leverage, 200% position size).
  Parameters:
     fraction : float, aproximate percent fraction invested.
     max_expected_loss : float, maximum expected percent on a loss (ex 10% = 0.1).
  Returns: float, final fraction to invest.
usage:
final_f(0.2, 0.5)
 hpr(fraction, trade, biggest_loss) 
  Holding Period Return function
  Parameters:
     fraction : float, aproximate percent fraction invested.
     trade : float, profit or loss in a trade.
     biggest_loss : float, value of the biggest loss on record.
  Returns: float, multiplier of effect on equity so that a win of 5% is 1.05 and loss of 5% is 0.95.
usage:
hpr(fraction=0.05, trade=0.1, biggest_loss=-0.2)
 twr(returns, rr, eps) 
  Terminal Wealth Relative, returns a multiplier that can be applied 
to the initial capital that leadds to the final balance.
  Parameters:
     returns : array, list of trade returns.
     rr : float       , reward to risk rate.
     eps : float       , minimum resolution to void zero division.
  Returns: float, optimal fraction to invest.
usage:
twr(returns=array.from(0.1,-0.2,0.3), rr=0.6)
 ghpr(returns, rr, eps) 
  Geometric mean Holding Period Return, represents the average multiple made on the stake.
  Parameters:
     returns : array, list of trade returns.
     rr : float       , reward to risk rate.
     eps : float       , minimum resolution to void zero division.
  Returns: float, multiplier of effect on equity so that a win of 5% is 1.05 and loss of 5% is 0.95.
usage:
ghpr(returns=array.from(0.1,-0.2,0.3), rr=0.6)
 run_coin_simulation(fraction, initial_capital, n_series, n_periods) 
  run multiple coin flipping (binary outcome) simulations.
  Parameters:
     fraction : float, fraction of capital to bet.
     initial_capital : float, capital at the start of simulation.
     n_series : int  , number of simulation series.
     n_periods : int  , number of periods in each simulation series.
  Returns: matrix(n_series, n_periods), matrix with simulation results per row.
usage:
run_coin_simulation(fraction=0.1)
 run_asset_simulation(returns, fraction, initial_capital) 
  run a simulation over provided returns.
  Parameters:
     returns : array, trade, asset or strategy percent returns.
     fraction : float       , fraction of capital to bet.
     initial_capital : float       , capital at the start of simulation.
  Returns: array, array with simulation results.
usage:
run_asset_simulation(returns=array.from(0.1,-0.2,0.-3,0.4), fraction=0.1)
 strategy_win_probability() 
  calculate strategy() current probability of positive outcome in a trade.
 strategy_avg_won() 
  calculate strategy() current average won on a trade with positive outcome.
 strategy_avg_loss() 
  calculate strategy() current average lost on a trade with negative outcome.






















