Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sell_all(minute=99, second=99, variety='regular', product_to_use='ALL'):
- while ((util.getTime()['min'] != minute) or (util.getTime()['sec'] != second)) \
- and ((second != 99) and (minute != 99)):
- time.sleep(0.01)
- holdings = kite.positions()
- print(holdings)
- # return
- for x in holdings['net']:
- res = x
- quantity = res["quantity"]
- exchange = res["exchange"]
- symbol_name = res["tradingsymbol"]
- product = res["product"]
- # print(product)
- # print(res)
- if (product_to_use != 'ALL') and (product_to_use != product):
- continue
- print('\n')
- if quantity < 0 and product == 'MIS':
- # print(res, '\n\n')
- quantity = buy_stocks[res['tradingsymbol'] + '+' + res['exchange']][0]
- print(quantity, exchange, symbol_name, product, variety)
- print('Selling ' + str(quantity) + ' ' + symbol_name)
- print()
- # if False:
- """Place Sell Market Order"""
- # get_margin_cap_available()
- if config.deploy:
- order_id1 = kite.place_order(variety=variety, exchange=exchange,
- tradingsymbol=symbol_name,
- transaction_type="SELL", quantity=abs(quantity),
- product=product,
- order_type="MARKET",
- price=None, validity="DAY", disclosed_quantity=None,
- trigger_price=None,
- squareoff=None,
- stoploss=None,
- trailing_stoploss=None,
- tag=None)
- print("SOLD!")
Add Comment
Please, Sign In to add comment