def getInstrumentExecutionsFromExecutions(self, time, executions):
     instrumentExecutions = []
     for (instrumentId, position) in executions.iteritems():
         if position == 0:
             continue
         instExecution = InstrumentExection(time=time,
                                            instrumentId=instrumentId,
                                            volume=np.abs(position),
                                            executionType=np.sign(position))
         instrumentExecutions.append(instExecution)
     return instrumentExecutions
 def getExecutionsAtClose(self, time, instrumentsManager):
     instrumentExecutions = []
     instruments = instrumentsManager.getAllInstrumentsByInstrumentId().values()
     for instrument in instruments:
         position = instrument.getCurrentPosition()
         if position == 0:
             continue
         instrumentExec = InstrumentExection(time=time,
                                             instrumentId=instrument.getInstrumentId(),
                                             volume=np.abs(position),
                                             executionType=-np.sign(position))
         instrumentExecutions.append(instrumentExec)
     return instrumentExecutions
    def getInstrumentExecutionsFromExecutions(self, time, executions):
        instrumentExecutions = []
        for row in executions.iterrows():
            instrumentId = row[0]
            position = row[1]['position']
            price = row[1]['price']
            spread = row[1]['spread']
            instExecution = InstrumentExection(time=time,
                                               instrumentId=instrumentId,
                                               volume=np.abs(position),
                                               executionType=np.sign(position))
            setattr(instExecution, 'price', price)
            setattr(instExecution, 'spread', spread)

            instrumentExecutions.append(instExecution)
        return instrumentExecutions