当前位置: 首页>>代码示例>>Python>>正文


Python Interface.getLastErrorMessage方法代码示例

本文整理汇总了Python中interface.Interface.getLastErrorMessage方法的典型用法代码示例。如果您正苦于以下问题:Python Interface.getLastErrorMessage方法的具体用法?Python Interface.getLastErrorMessage怎么用?Python Interface.getLastErrorMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在interface.Interface的用法示例。


在下文中一共展示了Interface.getLastErrorMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import getLastErrorMessage [as 别名]
class Speculator:
	host = 'speculator.in'
	apiLink = '/ax/'

	## 
	#  @brief Brief
	#  
	#  @param [in] self Parameter_Description
	#  @return Return_Description
	#  
	#  @details Details
	#  
	def __init__(self):
		self.int = Interface()
		self.int.setHost(self.host)
		self.int.setApiLink(self.apiLink)

	## 
	#  @brief Brief
	#  
	#  @param [in] self Parameter_Description
	#  @param [in] pair Parameter_Description
	#  @param [in] depth Parameter_Description
	#  @return sigma, avg or False, errorMessage
	#  
	#  @details Details
	#  		
	def getSigmaAndAvg(self, pair = None, depth = None):
		req = {'pair': pair}
		if not depth is None and depth.isdigit():
			req['depth'] = depth
		
		res = self.int.sendGet('stat', None, req, False)
		if not res:
			return False, self.int.getLastErrorMessage()
			
		return res['res']['sigma'], res['res']['avg']
开发者ID:echangein,项目名称:arbitrage,代码行数:39,代码来源:speculator.py

示例2: __init__

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import getLastErrorMessage [as 别名]
class Spec:
	dialogs = None
	lastErrorMessage = None
	checkTimeout = 2
	silent = False
	int = None
	pairs = None
	tickers = None
	depth = None
	seqs = []
	
	
	def __init__(self, key = None, secret = None, silent = False):
		self.int = Interface(key, secret)
		self.dialogs = Dialogs()
		self.formatTrade = self.dialogs.formatTrade
		self.silent = silent
	
	def getLastErrorMessage(self):
		return self.lastErrorMessage

	def checkConnection(self):
		res = self.int.sendGet('info')
		if not res:
			self.lastErrorMessage = self.int.getLastErrorMessage()
			if not self.silent:
				print self.dialogs.getCheckConnectionError(self.lastErrorMessage)
			return False
		
		if not self.silent:
			print self.dialogs.getCheckConnectionSuccess()
		return True
	
	def loadTradeConditions(self):
		res = self.int.sendGet('info')
		if not res:
			self.lastErrorMessage = self.int.getLastErrorMessage()
			if not self.silent:
				print self.dialogs.getLoadTradeConditionsError(self.lastErrorMessage)
			return False
			
		self.pairs = res['pairs']
		if not self.silent:
			print self.dialogs.getLoadTradeConditionsSuccess()
		return True
	
	def loadTickers(self, pairs = ['btc_rur']):
		res = self.int.sendGet('ticker', pairs)
		if not res:
			self.lastErrorMessage = self.int.getLastErrorMessage()
			if not self.silent:
				print self.dialogs.getLoadTickersError(self.lastErrorMessage)
			return False
			
		self.tickers = res
		if not self.silent:
			print self.dialogs.getLoadTickersSuccess()
		return True
	
	def generateTradeSequence(self, start, seq = None, length = 3):
		if length < 2:
			self.lastErrorMessage = 'tradeLength at config.py too small'
			if not self.silent:
				print self.dialogs.getGenerateTradeSequenceError(self.lastErrorMessage)
			return False
		
		if len(seq) < length:
			self.lastErrorMessage = 'Not enough values in tradeSequence at config.py'
			if not self.silent:
				print self.dialogs.getGenerateTradeSequenceError(self.lastErrorMessage)
			return False
			
		self.seqs = []
		for seqItem in [items for items in self.__getAllCombinations(seq) if len(items) == length and items[0] == start]:
			success = True
			seq = []
			for idx, val in enumerate(seqItem):
				if success:
					if idx + 1 == len(seqItem):
						idx = -1
					pair = self.__searchPair(val, seqItem[idx+1])
					if not pair:
						success = False
					seq.append(pair)
			if success:
				self.seqs.append({'trades': seq})
		
		if len(self.seqs)>0:
			if not self.silent:
				print self.dialogs.getGenerateTradeSequenceSuccess()
			return True
		
		self.lastErrorMessage = 'Can\'t choose pair for any sequence'
		if not self.silent:
			print self.dialogs.getGenerateTradeSequenceError(self.lastErrorMessage)
		return False
	
	def generateTradeAmount(self, startAmount = 0.0):
		pairs = set()
		for row in self.seqs:
#.........这里部分代码省略.........
开发者ID:echangein,项目名称:arbitrage,代码行数:103,代码来源:spec.py

示例3: __init__

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import getLastErrorMessage [as 别名]
class Btce:
	int = None

	## 
	#  @brief Brief
	#  
	#  @param [in] self Parameter_Description
	#  @param [in] key Parameter_Description
	#  @param [in] secret Parameter_Description
	#  @return Return_Description
	#  
	#  @details Details
	#  
	def __init__(self, key = None, secret = None):
		self.int = Interface(key, secret)
	## 
	#  @brief get exchange trade conditions
	#  
	#  @param [in] self Parameter_Description
	#  @return result, 'ok' or False, 'error message'
	#  
	#  @details Details
	#  
	def getConditions(self):
		res = self.int.sendGet('info')
		if not res:
			return False, self.int.getLastErrorMessage()
			
		return res, 'ok'
		
	## 
	#  @brief Brief
	#  
	#  @param [in] self Parameter_Description
	#  @param [in] pairs array of pair alias
	#  @return Return_Description
	#  
	#  @details Details
	#  	
	def getTicker(self, pairs = None):
		if not hasattr(pairs, '__contains__'):
			return False, 'pairs must be array'
			
		res = self.int.sendGet('ticker', pairs)
		if not res:
			return False, self.int.getLastErrorMessage()
			
		return res, 'ok'
		
	## 
	#  @brief Brief
	#  
	#  @param [in] self Parameter_Description
	#  @param [in] pair Parameter_Description
	#  @param [in] type Parameter_Description
	#  @param [in] rate Parameter_Description
	#  @param [in] amount Parameter_Description
	#  @return Return_Description
	#  
	#  @details Details
	#  		
	def createOrder(self, pair = None, type = None, rate = None, amount = None):
		res = self.int.sendPost({'method': 'Trade', 'pair': pair, 'type': type, 'rate': rate, 'amount': amount})
		if not res:
			return False, self.int.getLastErrorMessage()
		return res['return'], 'ok'
	
	## 
	#  @brief Brief
	#  
	#  @param [in] self Parameter_Description
	#  @param [in] pair only one pair
	#  @return Return_Description
	#  
	#  @details Details
	#  		
	def getActiveOrders(self, pair = None):
		params = {'method': 'ActiveOrders'}
		if isinstance(pair, str) or isinstance(pair, unicode):
			params['pair'] = pair
		
		res = self.int.sendPost(params)
		if not res:
			return False, self.int.getLastErrorMessage()
			
		return res['return'], 'ok'
	
	## 
	#  @brief Brief
	#  
	#  @param [in] self Parameter_Description
	#  @param [in] orderId Parameter_Description
	#  @return Return_Description
	#  
	#  @details 0 - active, 1 - excuted, 2 - canceled, 3 - canceled but partial executed
	#  		
	def getOrderInfo(self, orderId = None):
		res = self.int.sendPost({'method': 'OrderInfo', 'order_id': orderId})
		if not res:
			return False, self.int.getLastErrorMessage()
#.........这里部分代码省略.........
开发者ID:echangein,项目名称:arbitrage,代码行数:103,代码来源:btce.py


注:本文中的interface.Interface.getLastErrorMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。