Exemple #1
0
 def test_perturbate_risk(self):
     GoalMetricFactory.create(group=self.goal_settings.metric_group, feature=self.equity,
                              type=GoalMetric.METRIC_TYPE_RISK_SCORE,
                              rebalance_type=GoalMetric.REBALANCE_TYPE_ABSOLUTE,
                              rebalance_thr=0.5, configured_val=0.5)
     lots = get_tax_lots(self.goal)
     weights = get_weights(lots, self.goal.available_balance)
     #risk = process_risk(weights=weights, goal=self.goal, idata=idata, data_provider=data_provider, execution_provider=execution_provider)
     #weights = perturbate_risk(goal=self.goal)
     self.assertTrue(True)
Exemple #2
0
    def get_asset_weights_without_tax_winners(self, goal):
        lots = PositionLot.objects \
            .filter(execution_distribution__transaction__from_goal__id=goal.id,
                    execution_distribution__execution__asset__state=Ticker.State.ACTIVE.value) \
            .annotate(ticker_id=F('execution_distribution__execution__asset__id'),
                      price=F('execution_distribution__execution__asset__unit_price'),
                      bought_price=F('execution_distribution__execution__price')) \
            .annotate(tax_gain=F('price')-F('bought_price'))\
            .values('ticker_id', 'tax_gain', 'quantity', 'price')

        lots_no_tax_gain = [lot for lot in lots if lot['tax_gain'] > 0]

        weights = get_weights(lots_no_tax_gain, goal.available_balance)
        return weights