Package: pallo
pallo v0.2.1This is a Python package available on PyPi that simplifies the creation and usage of probabilistic asset allocation models.Pallo currently supports:Geometric Mean MaximizationCustom Drawdown constraintsMargin Trading Calculation OptionsMaximizing Sharpe RatiosInstallationpip install palloUsageIn v0.2.1 there are two asset allocation models currently available, a geometric mean maximization model and an efficient frontier model. There are plans for additional options in the future.#Load a custom dataset as a 2d list with each asset's percentage price moves as a one list
#Use the createDataset() method to create a 2d list to use with the gphrModel
stocks = ["SGRY", "AA", "MTX"]
dataset = createDataset(stocks, 30)

#Create a gphrModel object and load the dataset
model = gphrModel(dataset)

#defineBins(), calcGPHRs(), and findBestUnderDrawdown() (need to be executed in that order)
#will compute the best asset allocation based on the inputted specifications. View method parameters below. 
model.defineBins()
model.calcGPHRs()
model.findBestUnderDrawdown(.90, 12, .2)

#Print the best possible asset allocation under the inputted drawdown constraint.
model.showStats()




#Find the best possible Sharpe ratio out of a collection of stocks
allStocks = ["BK", "MTZ", "SGRY", "AA", "ARCB", "RDNT", "MMYT", "DECK", "TEO", "WK"]

#Make a efModel object and input the list of stocks
mod = efModel(allStocks)

#Returns the best possible Sharpe ratio, stocks, and asset allocation
print(mod.findMaxSharpe(30))Object and Method DetailsgphrModel(dataset):This is the object that will hold all calculations and information related to the inputted dataset.Dataset Specifications For Proper Function:Must be a 2d list that holds the percentage price movements of each asset.Each sub-list in the dataset must be of equal length to one anotherThe period (timeframe) referenced in each object of each sublist must be equal in all sublistsThe dataset has a minimum asset count of 2 and an uncapped maximumgphrModel.defineBins(numBins=5):This method will take the dataset you have inputted and create the probabilistic range as well as setup the most of the attributes for computation.Parameters:numBinsThis parameter determines how many probability bins are to be created for the model. This will have a low-moderate impact on the speed of computation and granularity of results.Default: 5Minimum to function: 3No Maximum, however, the more you add the longer the computations will take later.gphrModel.calcGPHRs(portfolioLimit=.33):This method will calculate all of the possible combinations of asset allocations within the portfolio limit.Parameters:portfolioLimitThis is the percentage of the overall portfolio available funds that you will allow to compute. This will have a very high impact on the speed of computation, lower = faster, higher = slower. Consider lowering the input from default if your assets are highly volatile or you are seeking a low risk of hitting your drawdown constraint. Consider raising the input from default if your assets aren't volatile.Default: .33Minimum: .01No Maximum for the method to function properly but to calculate for cash accounts 1.0 would equate to your entire account value. The input should exceed 1.0 for margin accounts.gphrModel.findBestUnderDrawdown(drawdownConstraint, periods, percentChance, extraBranches=False):This method will do a pseudo tree traversal to calculate the best asset allocation that has a percent change below percentChance of hitting your drawdown constraint.Parameters:drawdownConstraintThis will determine your drawdown constraint over the trading period. .90 equates to a 10% decrease on initial capitalization.Minimum: .01Maximum: .99periodsThis is the number of trading periods you want to calculate for. The timeframe for the period is the same as the timeframe between each percent change in your dataset.Minimum: 1No Maximum but it should be noted that as the periods grow larger the chance of hitting your drawdown will increase so you will find that the percentage of your overall portfolio you can trade will decrease.This has a moderate impact on computation speed.percentChanceThis determines what percent chance you are willing to have of hitting your drawdown constraint over the trading period.Minimum: .01Maximum: 1.0This has a moderate impact on computation speed.extraBranchesThis should only be set to true after extensive testing as this willsignificantlyincrease computation time. However, if this is set to true the results will be significantly more accurate and viable for use. With this set to false the results will not be consistent however the computation time is low and testing is more viable.Default: FalsecreateDataset(stockList, timeIncluded):This is a method that will turn a list of stocks into a usable 2d dataset for the gphrModel object.Parameters:stockListInput that determines the stocks the dataset is based offCurrent functionality requires that the stock list length must be 3 exactlyTime IncludedInteger that determines how many days prior to today will be included in the creation of the datsetMinimum: 1 (More if previous days were weekend or holiday)Maximum: UncappedefModel(stockList):This object will intake a list of stocks and then calculate the best combination of three stocks and weights to produce the highest possible Sharpe ratio out of the inputted stocks.Stock List Specifications for Proper Function:Must be List of stock tags as stringsMinimum: 2Uncapped MaximumefModel.findMaxSharpe(timeIncluded)This method will calculate all of the best Sharpe ratios in the list of possible stock combinations and output the best possible Sharpe ratio and the asset allocation that achieves it.Parameters:timeIncludedInteger that determines how many days prior to today will be included in the calculation of Sharpe ratiosMinimum: 1 (More if previous days were weekend or holiday)Maximum: UncappedRoadmapEfficient Frontier Model Additional CustomizationAdd the ability to import custom datasets rather than downloading from yfinance.Return a list of all Sharpe ratios and asset allocations.Allow different numbers of final stock combinations aside from the default 3.Expanding Options/Interperiod Methods For gprhModelWill be adding additional methods that adjust asset allocations depending upon ROI between periods.Planning to add saving and recovering methods.Also working towards a multiprocessing solution to reduce computation times.Recent Changesv0.2.1Added the createDataset() method to make it easier to test the gphrModelv0.2.0New efModel is finished with the ability to input any length stock list and find the best possible asset allocation of a combination of three stocks.Cleaned up and updated README.