I found your DiscreteAllocation.greedy_portfolio() in pypfopt while implementing a regular rebalancing task. However, my challenge was that my situation was not SIMPLY convert continuous weights to discrete allocation.
A new situation I had to consider was:
I already have some stocks.
In other words, we had to consider the situation of not only buying the stock, but also selling it.
‘fee’ (a kind of contraction cost) must be considered
(In addition, using ‘total_portfolio_value’, which is dependent on ‘latest_prices’, felt a little less intuitive to me.)
Thankfully, thanks to your project, I was able to implement the task without difficulty.
I really appreciate this part.
I am using your code by modifying the structure as below.
[Inputs & Outputs in DiscreteAllocation class]
“””
Hello, Robert
I found your DiscreteAllocation.greedy_portfolio() in pypfopt while implementing a regular rebalancing task. However, my challenge was that my situation was not SIMPLY convert continuous weights to discrete allocation.
A new situation I had to consider was:
Thankfully, thanks to your project, I was able to implement the task without difficulty. I really appreciate this part.
I am using your code by modifying the structure as below.
[Inputs & Outputs in DiscreteAllocation class] “””
Inputs:
weights
- dictlatest_prices
- pd.Series or dicttotal_portfolio_value
- int/floatshort_ratio
- floatOutput:
allocation
- dict “””[After modifying] “””
Inputs:
weights
- dictinit_state
- dict # number of existing shareslatest_prices
- pd.Series or dictcash
- int/float # amount of cash currently hasfee_rate
- float # fee rate as contraction costshort_ratio
- floatverbose
- boolOutput:
allocation
- dictaction
- dict # action for desired weight (+ indicates buying, - indicates selling)cash_left
- dict “””If this fixing fits the direction of your project PyPortfolioOpt, I'd be happy to share with you.
Please read the above and reply. Thank you for your time.