Beispiel #1
0
 def __finish_initialization(self):
     """ Fetches remaining data not retrieved during basket initialization """
     if has(self, 'id'):
         if not has(self, '__initial_positions'):
             position_set = GsAssetApi.get_latest_positions(
                 self.id, PositionType.ANY)
             position_set = PositionSet.from_target(position_set)
             self.__position_set = position_set
             self.__divisor = get(position_set, 'divisor')
             self.__initial_positions = set(
                 deepcopy(self.__position_set.positions))
             set_(self.__initial_state, 'divisor', self.__divisor)
             set_(self.__initial_state, 'position_set', self.__position_set)
         if not has(self.__initial_state, 'initial_price'):
             initial_price = GsIndexApi.initial_price(
                 self.id, dt.date.today())
             self.__initial_price = get(initial_price, 'price')
             set_(self.__initial_state, 'initial_price',
                  self.__initial_price)
         if not has(self.__initial_state, 'publish_to_bloomberg'):
             report = get(self, '__latest_create_report',
                          self.__get_latest_create_report())
             self.__publish_to_bloomberg = get(
                 report, 'parameters.publish_to_bloomberg')
             self.__publish_to_factset = get(
                 report, 'parameters.publish_to_factset')
             self.__publish_to_reuters = get(
                 report, 'parameters.publish_to_reuters')
             set_(self.__initial_state, 'publish_to_bloomberg',
                  self.__publish_to_bloomberg)
             set_(self.__initial_state, 'publish_to_factset',
                  self.__publish_to_factset)
             set_(self.__initial_state, 'publish_to_reuters',
                  self.__publish_to_reuters)
         if not has(self, '__entitlements'):
             self.__entitlements = BasketEntitlements.from_target(
                 self.__initial_entitlements)
     self.__set_error_messages()
Beispiel #2
0
def test_get_positions(mocker):
    positions = {
        'positionSets': [{
            'positionDate':
            '2020-01-01',
            'positions': [{
                'asset_id': 'asset_id_1',
                'quantity': 100
            }, {
                'asset_id': 'asset_id_2',
                'quantity': 150
            }]
        }]
    }
    position_set = PositionSet(positions=[
        Position(asset_id='asset_id_1', quantity=100),
        Position(asset_id='asset_id_2', quantity=150)
    ],
                               date=datetime.date(2020, 1, 1))
    portfolio = test_pull_from_marquee(mocker)
    mocker.patch.object(GsSession.current, '_get', return_value=positions)
    mocker.patch.object(PositionSet, 'from_target', return_value=position_set)
    returned_positions = portfolio.get_position_sets()
    assert returned_positions[0].date == datetime.date(2020, 1, 1)
Beispiel #3
0
                   name='Test Basket',
                   id_='MA1234567890',
                   entitlements=TargetEntitlements(admin=['guid:user_abc']),
                   xref=XRef(ticker='GSMBXXXX'))
initial_price = {'price': 100}
mqid = 'MA1234567890'
name = 'Test Basket'
positions = [
    Position('bbid1', asset_id='id1', quantity=100),
    Position('bbid2', asset_id='id2', quantity=200)
]
positions_weighted = positions = [
    Position('bbid1', asset_id='id1', weight=0.4),
    Position('bbid2', asset_id='id2', weight=0.6)
]
position_set = PositionSet(positions, divisor=1000)
report = Report(mqid,
                'asset',
                'Basket Create',
                ReportParameters(),
                status='done')
resolved_asset = {'GSMBXXXX': [{'id': mqid}]}
target_positions = tuple([
    TargetPosition(asset_id='id1', quantity=100),
    TargetPosition(asset_id='id2', quantity=200)
])
target_position_set = TargetPositionSet(target_positions,
                                        dt.date(2021, 1, 7),
                                        divisor=1000)
ticker = 'GSMBXXXX'
user_ea = {