本文整理汇总了Python中interface.Interface.sendPost方法的典型用法代码示例。如果您正苦于以下问题:Python Interface.sendPost方法的具体用法?Python Interface.sendPost怎么用?Python Interface.sendPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interface.Interface
的用法示例。
在下文中一共展示了Interface.sendPost方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import sendPost [as 别名]
#.........这里部分代码省略.........
return False
if trade['action'] == 'sell':
return self.checkAmount(trade['operationAmount'], trade['pair'][:3])
else:
return self.checkAmount(trade['operationAmount'] * trade['price'], trade['pair'][4:])
def saveTrades(self, trades):
file = open('selected_trades', 'w+')
file.write(json.dumps(trades))
file.close()
def loadTrades(self):
file = open('selected_trades', 'r+')
trades = json.load(file)
file.close()
if not self.silent:
print self.dialogs.getLoadTradesMessage()
for action in trades:
print(self.dialogs.formatTrade(action))
return trades
def unlinkTrades(self):
if os.path.isfile('selected_trades'):
os.remove('selected_trades')
def hasSavedTrades(self):
return os.path.isfile('selected_trades')
def checkAmount(self, startAmount = 0.0, startCurr = 'usd'):
res = self.int.sendPost({'method': 'getInfo'})
if not res:
self.lastErrorMessage = self.int.getLastErrorMessage()
return False
if not startCurr in res['return']['funds']:
self.lastErrorMessage = 'Not have fund: '+startCurr
return False
if res['return']['funds'][startCurr] < startAmount:
self.lastErrorMessage = 'Start amount large than {0}'.format(res['return']['funds'][startCurr])
return False
return True
def waitingOrder(self, orderId = None):
status = 0
while status == 0:
time.sleep(self.checkTimeout)
status = self.getOrderStatus(orderId)
return status
def getOrderStatus(self, orderId = None):
res = self.int.sendPost({'method': 'OrderInfo', 'order_id': orderId})
if not res:
self.lastErrorMessage = self.int.getLastErrorMessage()
return False
if not str(orderId) in res['return']:
self.lastErrorMessage = 'Order {0} not found'.format(orderId)
return False
示例2: __init__
# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import sendPost [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()
#.........这里部分代码省略.........