Skip to content

Instantly share code, notes, and snippets.

@jsgaston
Created February 3, 2022 16:01
Show Gist options
  • Save jsgaston/3cb2716ee593f5a05d19ecd2ed954999 to your computer and use it in GitHub Desktop.
Save jsgaston/3cb2716ee593f5a05d19ecd2ed954999 to your computer and use it in GitHub Desktop.
else:
if len(strongBuy_list1)!=0:
f=c.shape
g=f[0]-1
cc=c[g]
CC = float(round((cc) , 4))
print("el close es:",CC)
tpl=cc+((1.5)*datr1d)
#sls=cc+((1.5)*datr1d)
#tps=cc-((1.5)*datr1d)
sll=cc-((1.5)*datr1d)
TPL = float(round((tpl) , 4))
SLL = float(round((sll) , 4))
#TPS = float(round((tps) , 4))
#SLS = float(round((sls) , 4))
print("TPL:",TPL)
print("SLL:",SLL)
#print("TPS:",TPS)
#print("SLS:",SLS)
client.futures_change_leverage(symbol=symbolo,leverage=leve)
order_buy=client.futures_create_order(
symbol=symbolo,
side='BUY',
type='MARKET',
quantity=cantidad,
#reduceOnly=True
)
order_Buy_ID=order_buy['orderId']
print(order_buy)
precio=order_buy['price']
print("Order ID: " + str(order_Buy_ID))
order_buysl=client.futures_create_order(
symbol=symbolo,
#quantity=cantidad,
side='SELL',
type='STOP_MARKET',
stopPrice=SLL,
closePosition=True
#activationPrice=cc*1.01,
#callbackRate=1,
##reduceOnly='True'
)
order_Buysl_ID=order_buysl['orderId']
print(order_buysl)
print("Or der IDsl: " + str(order_Buysl_ID))
order_buytp=client.futures_create_order(
symbol=symbolo,
side='SELL',
type='TAKE_PROFIT_MARKET',
stopPrice=TPL,
closePosition=True
)
order_Buytp_ID=order_buytp['orderId']
print(order_buytp)
print("Or der IDtp: " + str(order_Buytp_ID))
telegram_send.send(messages=["Buy order!",symbolo])
print("Order ID: " + str(order_Buy_ID))
print("Order IDtp: " + str(order_Buytp_ID))
print("Order IDsl: " + str(order_Buysl_ID))
mylista1[0]=(order_Buy_ID)
mylista1[1]=(order_Buytp_ID)
mylista1[2]=(order_Buysl_ID)
print(str(mylista1))
print("primeras órdenes")
print(client.futures_position_information(symbol=symbolo))
abc=time.time()+(60*60*24)
while True:
print(client.futures_position_information(symbol=symbolo))
orders = client.futures_get_open_orders(symbol=symbolo)
now = datetime.now()
fecha = now.strftime("%d-%m-%y %H:%M:%S")
lista = [symbolo]
print("length lista es:")
print(len(lista))
print("length simbolo es:")
print(len(symbolo))
print(now)
print(order_Buy_ID)
strongBuy_list1 = []
strongSell_list1 = []
for i in lista:
tesla = TA_Handler()
tesla.set_symbol_as(i)
tesla.set_exchange_as_crypto_or_stock("BINANCE")
tesla.set_screener_as_crypto()
tesla.set_interval_as(Interval.INTERVAL_1_DAY)
#openOrder = client.get_order(symbol=symbolo)
#print(openOrder)
#orderId = openOrder[0]['orderId']
#print(orderId)
print(i)
try:
print(tesla.get_analysis().summary)
except Exception as e:
print("No Data")
continue
if((tesla.get_analysis().summary)["RECOMMENDATION"])=="STRONG_BUY":
print(f" Compar más fuerte {i}", fecha)
strongBuy_list1.append(i)
print("*** STRONG BUY LIST 1 DIA***")
print(strongBuy_list1)
entrada[0]=float(client.futures_position_information(symbol=symbolo)[-1]['entryPrice'])
print("precio entrada es",entrada)
amount[0]=float(client.futures_position_information(symbol=symbolo)[-1]['positionAmt'])
print("el lotaje es: ",amount)
leverage[0]=float(client.futures_position_information(symbol=symbolo)[-1]['leverage'])
print("el leverage es: ",leverage)
bingo[-1]=float(entrada[0]+(comision*amount[0]*entrada[0]*3.0))
print("bingo es: ",bingo)
markPrice[0]=float(client.futures_position_information(symbol=symbolo)[-1]['markPrice'])
print("el precio mark es:", markPrice)
if bingo[-1] < markPrice[-1]:
client.futures_cancel_all_open_orders(symbol=symbolo)
client.futures_create_order(symbol=symbolo,side='SELL', type="MARKET", quantity=cantidad, redueOnly='True')
telegram_send.send(messages=["Profit!",symbolo])
break
#order_ids = [order['clientOrderId'] for order in orders]
if client.futures_position_information(symbol=symbolo)[-1]['positionAmt'] == '0.00000':
client.futures_cancel_all_open_orders(symbol=symbolo)
telegram_send.send(messages=["Buy cerrado y ordenes cerradas!",symbolo])
break
if len(strongBuy_list1) !=1:
client.futures_cancel_all_open_orders(symbol=symbolo)
client.futures_create_order(symbol=symbolo,side='SELL', type="MARKET", quantity=cantidad, redueOnly='True')
telegram_send.send(messages=["Buy cerrado y ordenes cerradas!",symbolo])
break
#else: print("na de na")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment