Beispiel #1
0
 def getParsedPositionsDetail(self, accountId):
     '''
     Populate a dictionary of PositionsDetail
     :return: list of all the positions
     '''
     positionDetailedResponse = self.getPositionsDetail(accountId)
     items = positionDetailedResponse[TradeMonsterConstants.ResponseRoots.RETRIEVE_POSITIONS_DETAILED_ROOT]['item']
     
     positions = []
     if isinstance(items,list):
         for item in items:
                 for Position in item['positions']:
                     position = PositionItem()
                     position.UnderlierBeta = item['beta']
                     position.UnderlierDescription = item['description']
                     position.UnderlierInstrumentId = item['instrumentId']
                     position.UnderlierInstrumentType = item['instrumentType']
                     position.UnderlierMargin = item['margin']
                     position.UnderlierPmMargin = item['pmMargin']
                     position.UnderlierSymbol = item['symbol']
                     self.parseSinglePositionQuote(position, Position)
                     positions.append(position)
     else:
         position = PositionItem()
         Position = items['positions']
         position.UnderlierBeta = items['beta']
         position.UnderlierDescription = items['description']
         position.UnderlierInstrumentId = items['instrumentId']
         position.UnderlierInstrumentType = items['instrumentType']
         position.UnderlierMargin = items['margin']
         position.UnderlierPmMargin = items['pmMargin']
         position.UnderlierSymbol = items['symbol']
         self.parseSinglePositionQuote(position, Position)
         positions.append(position)
     return positions
 def getParsedPositionsDetail(self, accountId):
     '''
     Populate a dictionary of PositionsDetail
     :return: list of all the positions
     '''
     positionDetailedResponse = self.getPositionsDetail(accountId)
     items = positionDetailedResponse[TradeMonsterConstants.ResponseRoots.RETRIEVE_POSITIONS_DETAILED_ROOT]['item']
     
     positions = []
     for item in items:
         if item['description'] == 'multiple':
             # TODO FIXME following loop is not tested; not sure if this is how we could iterate through multiple tags
             for Position in item['positions']:
                 position = PositionItem()
                 position.UnderlierBeta = item['beta']
                 position.UnderlierDescription = item['description']
                 position.UnderlierInstrumentId = item['instrumentId']
                 position.UnderlierInstrumentType = item['instrumentType']
                 position.UnderlierMargin = item['margin']
                 position.UnderlierPmMargin = item['pmMargin']
                 position.UnderlierSymbol = item['symbol']
                 self.parseSignlePositionQuote(position, Position)
                 positions.append(position)
         else:
             position = PositionItem()
             Position = item['positions']
             position.UnderlierBeta = item['beta']
             position.UnderlierDescription = item['description']
             position.UnderlierInstrumentId = item['instrumentId']
             position.UnderlierInstrumentType = item['instrumentType']
             position.UnderlierMargin = item['margin']
             position.UnderlierPmMargin = item['pmMargin']
             position.UnderlierSymbol = item['symbol']
             self.parseSignlePositionQuote(position, Position)
             positions.append(position)
     return positions
 def createPositionItemObject(self, items, positionLeg):
     '''
     Helper for creating a PositionItem object
     :param items:
     :param positionLeg:
     :return:
     '''
     position = PositionItem()
     position.UnderlierBeta = items['beta']
     position.UnderlierDescription = items['description']
     position.UnderlierInstrumentId = items['instrumentId']
     position.UnderlierInstrumentType = items['instrumentType']
     position.UnderlierMargin = items['margin']
     position.UnderlierPmMargin = items['pmMargin']
     position.UnderlierSymbol = items['symbol']
     self.parseSinglePositionQuote(position, positionLeg)
     return position
 def createPositionItemObject(self, items, positionLeg):
     '''
     Helper for creating a PositionItem object
     :param items:
     :param positionLeg:
     :return:
     '''
     position = PositionItem()
     position.UnderlierBeta = items['beta']
     position.UnderlierDescription = items['description']
     position.UnderlierInstrumentId = items['instrumentId']
     position.UnderlierInstrumentType = items['instrumentType']
     position.UnderlierMargin = items['margin']
     position.UnderlierPmMargin = items['pmMargin']
     position.UnderlierSymbol = items['symbol']
     self.parseSinglePositionQuote(position, positionLeg)
     return position