示例#1
0
def printOrderXLSHEADER():
    BU.errPrint("Order id\t"
                "Symbol\t"
                "Price\t"
                "Qtd\t"
                "Qtd executed\t"
                "Side\t"
                "Type\t"
                "Stop price\t"
                "Is working")
示例#2
0
def printOrderXLS(order):
    BU.errPrint(f"{order['orderId']}\t"
                f"{order['symbol']}\t"
                f"{order['price']}\t"
                f"{order['origQty']}\t"
                f"{order['executedQty']}\t"
                f"{order['side']}\t"
                f"{order['type']}\t"
                f"{order['stopPrice']}\t"
                f"{order['isWorking']}")
示例#3
0
def printInfoSymbolValuesXLS(symbPrc):
    BU.errPrint(f"{BU.completeMilliTime(symbPrc[0])}\t"
                f"{BU.completeMilliTime(symbPrc[6])}\t"
                f"{symbPrc[2]}\t"
                f"{symbPrc[1]}\t"
                f"{symbPrc[4]}\t"
                f"{symbPrc[3]}\t"
                f"{symbPrc[5]}\t"
                f"{symbPrc[7]}\t"
                f"{symbPrc[8]}\t"
                f"{symbPrc[9]}\t"
                f"{symbPrc[10]}")
示例#4
0
def printInfoSymbolValuesXLSHEADER():
    BU.errPrint("Open time\t"
                "Close time\t"
                "High\t"
                "Open\t"
                "Close\t"
                "Low\t"
                "Volume\t"
                "Quote asset volume\t"
                "Number of trades\t"
                "Taker buy base asset volume\t"
                "Taker buy quote asset volume")
示例#5
0
def orderSpotLimit(client, symbOrd = '', qtdOrd = 0, prcOrd = 0.0, prcStopOrd = 0.0, prcStopLimitOrd = 0.0, sideOrd = 0) -> [bool, str]:

	if BU.getExportXLS() == True:
		BU.errPrint("Symbol\tSide\tQuantity\tPrice\tStop Price\tLimit OCO")
		BU.errPrint(f"{symbOrd}\t{sideOrd}\t{qtdOrd}\t{prcOrd}\t{prcStopOrd}\t{prcStopLimitOrd}")
	else:
		print(f"Symbol....: [{symbOrd}]")
		print(f"Side......: [{sideOrd}]")
		print(f"Quantity..: [{qtdOrd}]")
		print(f"Price.....: [{prcOrd}]")
		print(f"Stop Price: [{prcStopOrd}]")
		print(f"Limit OCO.: [{prcStopLimitOrd}]")

	if BU.askConfirmation() == False:
		return True, "Cancelled by Confirmation!"

	# TESTING
	global LOCK
	if LOCK == True:
		return False, "Programmed flag order lock ON!"

	try:
		order = client.create_oco_order(symbol               = symbOrd,
		                                side                 = sideOrd,
		                                quantity             = qtdOrd,
		                                price                = prcOrd,
		                                stopPrice            = prcStopOrd,
												  stopLimitPrice       = prcStopLimitOrd,
		                                stopLimitTimeInForce = Client.TIME_IN_FORCE_GTC,
		                                newOrderRespType     = Client.ORDER_RESP_TYPE_FULL)

	except BinanceRequestException as e:
		return False, f"Erro create_oco_order BinanceRequestException: [{e.status_code} - {e.message}]"
	except BinanceAPIException as e:
		return False, f"Erro create_oco_order BinanceAPIException: [{e.status_code} - {e.message}]"
	except BinanceOrderException as e:
		return False, f"Erro create_oco_order BinanceOrderException: [{e.status_code} - {e.message}]"
	except BinanceOrderMinAmountException as e:
		return False, f"Erro create_oco_order BinanceOrderMinAmountException: [{e.status_code} - {e.message}]"
	except BinanceOrderMinPriceException as e:
		return False, f"Erro create_oco_order BinanceOrderMinPriceException: [{e.status_code} - {e.message}]"
	except BinanceOrderMinTotalException as e:
		return False, f"Erro create_oco_order BinanceOrderMinTotalException: [{e.status_code} - {e.message}]"
	except BinanceOrderUnknownSymbolException as e:
		return False, f"Erro create_oco_order BinanceOrderUnknownSymbolException: [{e.status_code} - {e.message}]"
	except BinanceOrderInactiveSymbolException as e:
		return False, f"Erro create_oco_order BinanceOrderInactiveSymbolException: [{e.status_code} - {e.message}]"
	except Expcetion as e:
		return False, f"Erro create_oco_order generic exception: {e}"

	printPlacedOrder(order)

	return True, "Ok"
示例#6
0
def printMarginTradesXLS(mt):
    BU.errPrint(f"{mt['symbol']}\t"
                f"{mt['id']}\t"
                f"{mt['orderId']}\t"
                f"{mt['price']}\t"
                f"{mt['qty']}\t"
                f"{mt['time']}\t"
                f"{mt['commission']}\t"
                f"{mt['commissionAsset']}\t"
                f"{mt['isBestMatch']}\t"
                f"{mt['isBuyer']}\t"
                f"{BU.completeMilliTime(mt['time'])}")
示例#7
0
def printTradeHistoryXLS(tradeHist):
    BU.errPrint(f"{tradeHist['symbol']}\t"
                f"{BU.completeMilliTime(tradeHist['time'])}\t"
                f"{tradeHist['orderId']}\t"
                f"{tradeHist['id']}\t"
                f"{tradeHist['price']}\t"
                f"{tradeHist['qty']}\t"
                f"{tradeHist['quoteQty']}\t"
                f"{tradeHist['commission']}\t"
                f"{tradeHist['commissionAsset']}\t"
                f"{tradeHist['isBuyer']}\t"
                f"{tradeHist['isMaker']}\t"
                f"{tradeHist['isBestMatch']}")
示例#8
0
def printTradeHistoryXLSHEADER():
    BU.errPrint("Symbol\t"
                "Time\t"
                "Order Id\t"
                "Id\t"
                "Price\t"
                "Qtd\t"
                "Quote Qtd\t"
                "Commission\t"
                "Commission asset\t"
                "Buyer\t"
                "Maker\t"
                "TradeHist")
示例#9
0
def printTradeAllHistXLS(tradeAllHist):
    BU.errPrint(f"{tradeAllHist['symbol']}\t"
                f"{BU.completeMilliTime(tradeAllHist['time'])}\t"
                f"{BU.completeMilliTime(tradeAllHist['updateTime'])}\t"
                f"{tradeAllHist['orderId']}\t"
                f"{tradeAllHist['clientOrderId']}\t"
                f"{tradeAllHist['price']}\t"
                f"{tradeAllHist['origQty']}\t"
                f"{tradeAllHist['executedQty']}\t"
                f"{tradeAllHist['cummulativeQuoteQty']}\t"
                f"{tradeAllHist['status']}\t"
                f"{tradeAllHist['timeInForce']}\t"
                f"{tradeAllHist['side']}\t"
                f"{tradeAllHist['type']}\t"
                f"{tradeAllHist['stopPrice']}\t"
                f"{tradeAllHist['isWorking']}")
示例#10
0
def printTradeAllHistXLSHEADER():
    BU.errPrint("Symbol\t"
                "Time\t"
                "Update time\t"
                "Order Id\t"
                "Client Order Id\t"
                "Price\t"
                "Orig Qtd\t"
                "Executed Qtd\t"
                "Cummulative Quote Qtd\t"
                "Status\t"
                "Time in Force\t"
                "Side\t"
                "Type\t"
                "Stop Price\t"
                "Is working")
示例#11
0
def cancel_a_margin_order(client, symbOrd = '', ordrid = 0) -> [bool, str]:
	print(f"Cancel Margin Order Id [{ordrid}] with Symbol [{symbOrd}]")

	if BU.askConfirmation() == False:
		return True, "Cancelled by Confirmation!"

	# TESTING
	global LOCK
	if LOCK == True:
		return False, "Programmed flag order lock ON!"

	try:
		cancOrd = client.cancel_margin_order(symbol = symbOrd, orderId = ordrid)
	except BinanceRequestException as e:
		return False, f"Erro at client.cancel_margin_order() BinanceRequestException: [{e.status_code} - {e.message}]"

	except BinanceAPIException as e:
		return False, f"Erro at client.cancel_margin_order() BinanceAPIException: [{e.status_code} - {e.message}]"

	except Exception as e:
		return False, f"Erro at client.cancel_margin_order(): {e}"

	if BU.getExportXLS() == True:
		BU.errPrint("Symbol\tOriginal Client Order Id\tOrder Id\tClient Order Id\tPrice\tOriginal Qtd\tExecuted Qty\tCummulative Quote Qty\tStatus\tTime In Force\tType\tSide")
		BU.errPrint(f"{cancOrd['symbol']}\t{cancOrd['origClientOrderId']}\t{cancOrd['orderId']}\t{cancOrd['clientOrderId']}\t{cancOrd['price']}\t{cancOrd['origQty']}\t{cancOrd['executedQty']}\t{cancOrd['cummulativeQuoteQty']}\t{cancOrd['status']}\t{cancOrd['timeInForce']}\t{cancOrd['timeInForce']}\t{cancOrd['type']}\t{cancOrd['side']}")

	else:
		print(f"Symbol..................: [{cancOrd['symbol']}]")
		print(f"Original Client Order Id: [{cancOrd['origClientOrderId']}]")
		print(f"OrderId.................: [{cancOrd['orderId']}]")
		print(f"Client Order Id.........: [{cancOrd['clientOrderId']}]")
		print(f"Price...................: [{cancOrd['price']}]")
		print(f"Original Qtd............: [{cancOrd['origQty']}]")
		print(f"Executed Qty............: [{cancOrd['executedQty']}]")
		print(f"Cummulative Quote Qty...: [{cancOrd['cummulativeQuoteQty']}]")
		print(f"Status..................: [{cancOrd['status']}]")
		print(f"Time In Force...........: [{cancOrd['timeInForce']}]")
		print(f"Type....................: [{cancOrd['type']}]")
		print(f"Side....................: [{cancOrd['side']}]")

	return True, 'Ok'
示例#12
0
def print24hPrcChangStsXLSHEADER():
    BU.errPrint("Symbol\t"
                "Price Change\t"
                "Price Change Percent\t"
                "Weighted Avarege Price\t"
                "Previous Close Price\t"
                "Last Price\t"
                "Last Qty\t"
                "Bid Price\t"
                "Bid Qty\t"
                "Ask Price\t"
                "Ask Qty\t"
                "Open Price\t"
                "High Price\t"
                "Low Price\t"
                "Volume\t"
                "Quote Volume\t"
                "Open Time\t"
                "Close Time\t"
                "First Id\t"
                "Last Id\t"
                "Count")
示例#13
0
def print24hPrcChangStsXLS(priceSts):
    BU.errPrint(f"{priceSts['symbol']}\t"
                f"{priceSts['priceChange']}\t"
                f"{priceSts['priceChangePercent']}\t"
                f"{priceSts['weightedAvgPrice']}\t"
                f"{priceSts['prevClosePrice']}\t"
                f"{priceSts['lastPrice']}\t"
                f"{priceSts['lastQty']}\t"
                f"{priceSts['bidPrice']}\t"
                f"{priceSts['bidQty']}\t"
                f"{priceSts['askPrice']}\t"
                f"{priceSts['askQty']}\t"
                f"{priceSts['openPrice']}\t"
                f"{priceSts['highPrice']}\t"
                f"{priceSts['lowPrice']}\t"
                f"{priceSts['volume']}\t"
                f"{priceSts['quoteVolume']}\t"
                f"{BU.completeMilliTime(priceSts['openTime'])}\t"
                f"{BU.completeMilliTime(priceSts['closeTime'])}\t"
                f"{priceSts['firstId']}\t"
                f"{priceSts['lastId']}\t"
                f"{priceSts['count']}")
示例#14
0
def printListSymbolsXLS(symb):
    BU.errPrint(
        f"{symb['symbol']}\t{symb['status']}\t{symb['baseAsset']}\t{symb['baseAssetPrecision']}\t{symb['quoteAsset']}\t{symb['quotePrecision']}\t{symb['quoteAssetPrecision']}\t{symb['baseCommissionPrecision']}\t{symb['quoteCommissionPrecision']}\t{symb['icebergAllowed']}\t{symb['ocoAllowed']}\t{symb['quoteOrderQtyMarketAllowed']}\t{symb['isSpotTradingAllowed']}\t{symb['isMarginTradingAllowed']}\t{', '.join(symb['orderTypes'])}\t{', '.join(symb['permissions'])}"
    )

    BU.errPrint(
        "\tFilters\tType\tMin Price\tMax Price\tTick Size\tMultiplier Up\tMultiplier Down\tAvg Price Mins\tMin Qty\tMax Qty\tStep Size\tMin Notional\tApply To Market\tAvg Price Mins\tMax Num Algo Orders"
    )
    for n in symb['filters']:
        BU.errPrint(
            f"\t\t{n['filterType']}\t{n.get('minPrice', '')}\t{n.get('maxPrice', '')}\t{n.get('tickSize', '')}\t{n.get('multiplierUp', '')}\t{n.get('multiplierDown', '')}\t{n.get('avgPriceMins', '')}\t{n.get('minQty', '')}\t{n.get('maxQty', '')}\t{n.get('stepSize', '')}\t{n.get('minNotional', '')}\t{n.get('applyToMarket', '')}\t{n.get('avgPriceMins', '')}\t{n.get('maxNumAlgoOrders', '')}"
        )
示例#15
0
def printsubAccountsAssetsXLSHEADER():
    BU.errPrint("Asset\tFree\tLocked")
示例#16
0
def printListRateLimitXLS(limits):
    BU.errPrint(
        f"{limits['rateLimitType']}\t{limits['interval']}\t{limits['intervalNum']}\t{limits['limit']}"
    )
示例#17
0
def printListSymbolsXLSHEADER():
    BU.errPrint(
        "Symbol\tStatus\tBase Asset\tBase Asset Precision\tQuote Asset\tQuote Precision\tQuote Asset Precision\tBase Commission Precision\tQuote Commission Precision\tIceberg Allowed\tOco Allowed\tQuote Order Qty Market Allowed\tIs Spot Trading Allowed\tIs Margin Trading Allowed\tOrder Types\tPermissions"
    )
示例#18
0
def printProductsXLS(product):
    BU.errPrint(
        f"{product['symbol']}\t{product['quoteAssetName']}\t{product['tradedMoney']}\t{product['baseAssetUnit']}\t{product['baseAssetName']}\t{product['baseAsset']}\t{product['tickSize']}\t{product['prevClose']}\t{product['activeBuy']}\t{product['high']}\t{product['low']}\t{product['matchingUnitType']}\t{product['close']}\t{product['quoteAsset']}\t{product['productType']}\t{product['open']}\t{product['status']}\t{product['active']}\t{product['minTrade']}\t{product['minQty']}\t{product['activeSell']}\t{product['lastAggTradeId']}\t{product['withdrawFee']}\t{product['market']}\t{product['volume']}\t{product['marketName']}\t{product['decimalPlaces']}\t{product['parentMarket']}\t{product['parentMarketName']}\t{product['quoteAssetUnit']}"
    )
示例#19
0
def printListRateLimitXLSHEADER():
    BU.errPrint("Type\tInterval\tIntervalNum\tLimit")
示例#20
0
def printProductsXLSHEADER():
    BU.errPrint(
        "Symbol\tQuote Asset Name\tTraded Money\tBase Asset Unit\tBase Asset Name\tBase Asset\tTick Size\tPrev Close\tActive Buy\tHigh\tLow\tMatching Unit Type\tClose\tQuote Asset\tProduct Type\tOpen\tStatus\tActive\tMin Trade\tMin Qty\tActive Sell\tLast Aggregate Trade Id\tWithdraw Fee\tMarket\tVolume\tMarket Name\tDecimal Places\tParent Market\tParent Market Name\tQuote Asset Unit"
    )
示例#21
0
def printServerTimeXLS(st):
    BU.errPrint(f"{BU.completeMilliTime(st['serverTime'])}")
示例#22
0
def printHistoricalTradesXLS(trade):
    BU.errPrint(
        f"{trade['id']}\t{trade['price']}\t{trade['qty']}\t{trade['quoteQty']}\t{BU.completeMilliTime(trade['time'])}\t{trade['isBuyerMaker']}\t{trade['isBestMatch']}"
    )
示例#23
0
def printsubAccountsListXLSHEADER():
    BU.errPrint("Email\tStatus\tActivated\tMobile\tAuth\tCreate Time")
示例#24
0
def printsubAccountTransferHistoryXLSHEADER():
    BU.errPrint("From\tTo\tAsset\tQty\tTime")
示例#25
0
def printsubAccountsListXLS(n):
    BU.errPrint(
        f"{n['email']}\t{n['status']}\t{n['activated']}\t{n['mobile']}\t{n['gAuth']}\t{n['createTime']}"
    )
示例#26
0
def printAccountXLS(accBalance):
    BU.errPrint(
        f"{accBalance['asset']}\t{accBalance['free']}\t{accBalance['locked']}")
示例#27
0
def printsubAccountTransferHistoryXLS(n):
    BU.errPrint(
        f"{n['from']}\t{n['to']}\t{n['asset']}\t{n['qty']}\t{BU.completeMilliTime(n['time'])}"
    )
示例#28
0
def printSystemStatusXLS(sst):
    BU.errPrint(
        f"{sst['msg']}\t{'normal' if sst['status'] == 0 else 'system maintenance'}"
    )
示例#29
0
def printsubAccountsAssetsXLS(n):
    BU.errPrint(f"{n['asset']}\t{n['free']}\t{n['locked']}")
示例#30
0
def printHistoricalTradesXLSHEADER():
    BU.errPrint(
        "Id\tPrice\tQtyt\tQuote Qty\tTime\tIs Buyer Maker\tIs Best Match")