예제 #1
0
def agentFactory(**kwargs):
    agentType = kwargs.get('agentType')
    m         = kwargs.get('m',5)
    vmin  = kwargs.get('vmin',0)
    vmax  = kwargs.get('vmax',50)

    if agentType == None:
        raise ValueError("Must specify Agent Type")
    
    if agentType == "straightMV":
        agent = straightMV(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "straightMU":
        agent = straightMU(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "straightMU8":
        agent = straightMU8(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "straightMU64":
        agent = straightMU64(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "straightMU256":
        agent = straightMU256(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "targetMV":
        agent = targetMV(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "targetMU":
        agent = targetMU(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "targetMU8":
        agent = targetMU8(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "targetMU64":
        agent = targetMU64(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "targetMU256":
        agent = targetMU256(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "targetMVS":
        agent = targetMVS(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "targetMUS":
        agent = targetMUS(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "targetMUS8":
        agent = targetMUS8(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "targetMUS64":
        agent = targetMUS64(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "targetMUS256":
        agent = targetMUS256(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "targetPrice":
        agent = targetPrice(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "targetPriceDist":
        agent = targetPriceDist(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "targetPrice8":
        agent = targetPrice8(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "targetPrice64":
        agent = targetPrice64(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "targetPrice256":
        agent = targetPrice256(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "riskEvaluator8":
        agent = riskEvaluator8(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "riskEvaluator64":
        agent = riskEvaluator64(m = m, vmin = vmin, vmax = vmax)
#    elif agentType == "riskEvaluator256":
#        agent = riskEvaluator256(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "averageMU":
        agent = averageMU(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "averageMU8":
        agent = averageMU8(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "averageMU64":
        agent = averageMU64(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "averageMU256":
        agent = averageMU256(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "localBid":
        agent = localBid(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "localBid1e3":
        agent = localBid1e3(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "condLocalBid":
        agent = condLocalBid(m = m, vmin = vmin, vmax = vmax)
    elif agentType == "margLocalBid":
        agent = margLocalBid(m = m,vmin = vmin, vmax = vmax)
    else:
        raise ValueError("{0} not defined in agentFactory".format(agentType))

    return agent
예제 #2
0
 def agentsFromType(self,**kwargs):
     """
     Construct agents from a list of strings. An agent factory.
     """
     agentTypeList = kwargs.get('agentTypeList',self.agentTypeList)
         
     #will be set to none if not specified
     margDistPrediction = kwargs.get('margDistPrediction',self.margDistPrediction)
     
     m = kwargs.get('m',margDistPrediction.m)
     
     agentList = []
     for i, agentType in enumerate(agentTypeList):
         if agentTypeList[i] == 'riskAwareTP8':
             
             A = kwargs.get('A',self.A)
             if A == None:
                 raise KeyError('Must Specify A valu of A if a riskAware Agent is specified.')
                 
             agentList.append(riskAwareTP8( m                       = m,
                                            margDistPricePrediction = margDistPrediction,
                                            A                       = A) )
             
         elif agentTypeList[i] == 'riskAwareTMUS8':
             
             A = kwargs.get('A',self.A)
             if A == None:
                 raise KeyError('Must Specify A valu of A if a riskAware Agent is specified.')
             
             agentList.append(riskAwareTMUS8( m                       = m,
                                              margDistPricePrediction = margDistPrediction,
                                              A                       = A))
         elif agentTypeList[i] == 'riskAwareTMUS64':
             
             A = kwargs.get('A',self.A)
             if A == None:
                 raise KeyError('Must Specify A valu of A if a riskAware Agent is specified.')
                 
             agentList.append(riskAwareTMUS64( m                       = m,
                                               margDistPricePrediction = margDistPrediction,
                                               A                       = A) )
         elif agentTypeList[i] == 'targetMUS8':
             agentList.append(targetMUS8(m                       = m,
                                         margDistPricePrediction = margDistPrediction))
         elif agentTypeList[i] == 'targetMU8':
             agentList.append(targetMU8(m                       = m,
                                        margDistPricePrediction = margDistPrediction))
         elif agentTypeList[i] == 'straightMU8':
             agentList.append(straightMU8(m                       = m,
                                          margDistPricePrediction = margDistPrediction))
         elif agentTypeList[i] == 'averageMU':
             agentList.append(averageMU(m                       = m,
                                        margDistPricePrediction = margDistPrediction))
         elif agentTypeList[i] == 'bidEvaluatorSMU8':
             agentList.append(bidEvaluatorSMU8(m                       = m,
                                               margDistPricePrediction = margDistPrediction))
         elif agentTypeList[i] == 'bidEvaluatorSMU64':
             agentList.append(bidEvaluatorSMU64(m                       = m,
                                               margDistPricePrediction = margDistPrediction))
         elif agentTypeList[i] == 'bidEvaluatorTMUS8':
             agentList.append(bidEvaluatorTMUS8(m                       = m,
                                                margDistPricePrediction = margDistPrediction))
         elif agentTypeList[i] == 'bidEvaluatorRaTMUS8':
             A = kwargs.get('A',self.A)
             if A == None:
                 raise KeyError('Must Specify A valu of A if a riskAware Agent is specified.')
             agentList.append(bidEvaluatorRaTMUS8(m                       = m,
                                                  margDistPricePrediction = margDistPrediction,
                                                  A                       = A))
         elif agentTypeList[i] == 'riskEvaluator8':
             A = kwargs.get('A',self.A)
             if A == None:
                 raise KeyError('Must Specify A valu of A if a riskAware Agent is specified.')
             agentList.append(riskEvaluator8(m                       = m,
                                             margDistPricePrediction = margDistPrediction,
                                             A                       = A))
             
         elif agentTypeList[i] == 'riskEvaluator64':
             A = kwargs.get('A',self.A)
             if A == None:
                 raise KeyError('Must Specify A valu of A if a riskAware Agent is specified.')
             agentList.append(riskEvaluator64(m                       = m,
                                              margDistPricePrediction = margDistPrediction,
                                              A                       = A))
             
         elif agentTypeList[i] == 'riskEvaluator256':
             A = kwargs.get('A',self.A)
             if A == None:
                 raise KeyError('Must Specify A valu of A if a riskAware Agent is specified.')
             agentList.append(riskEvaluator256(m                       = m,
                                               margDistPricePrediction = margDistPrediction,
                                               A                       = A))
         else:
             raise ValueError('Unknown Agent Type {0}'.format(agentTypeList[i]))
         
     return agentList