''' hello traders .. this is a sample program to test risk reward...by randomly buying selling edit the sl and tp note: trade at your own risk ''' import logging from kiteconnect import KiteConnect from kiteconnect import KiteTicker
trd_capital = int(input("[*] Enter Trading Capital (eg. 10000, 25000) : "));
get_login(api_k,api_s);
def do_buy_sell(instrument_token,company_data): global trd_capital,trd_portfolio; quant = int(trd_capital//company_data['last_price']); sl = 20/quant; tp = 50/quant; number = random.randint(1,2000)%2;
kite.place_order(tradingsymbol=trd_portfolio[instrument_token],price=company_data['last_price'],variety=kite.VARIETY_BO,exchange=kite.EXCHANGE_NSE,transaction_type=kite.TRANSACTION_TYPE_BUY if number==0 else kite.TRANSACTION_TYPE_SELL,quantity=quant,squareoff=tp , stoploss=sl ,order_type=kite.ORDER_TYPE_LIMIT,product=kite.PRODUCT_BO)
print(("BUY" if number==0 else "SELL"),quant," OF ",trd_portfolio[instrument_token]," ON TIME ",company_data['timestamp']," AT PRICE ",ohlc[instrument_token][5][1]);
def on_ticks(ws, ticks): global is_buy_sell_done; for company_data in ticks: if not is_buy_sell_done[company_data['instrument_token']]: try: do_buy_sell(company_data['instrument_token'],company_data);#do buy or sell on random number except Exception as e: print("EXC ",e);
is_buy_sell_done[company_data['instrument_token']] = True; #buy or sell is done
def on_connect(ws, response): ws.subscribe([x for x in trd_portfolio]) ws.set_mode(ws.MODE_FULL,[x for x in trd_portfolio])
# Assign the callbacks. kws.on_ticks = on_ticks kws.on_connect = on_connect
You can contact us at.
+91 9921754273
[email protected]