def buy_args(self): ''' Place_order() Args List: 1 - Buy/Sell 2 - Instrument to buy 3 - Quantity (for futures, it is multiples of 75) 4 - Order Type - StopLossLimit(SL/Limit(L)/SLM(StoplossMarket/Market 5 - Product Type - Intraday/Delivery/CO/OCO 6 - Order price for purchase 7 - Trigger Price for purchase to activate 8 - Disclosed qt shown on NSE to other traders 9 - Duration of trade(Use "DAY" only) 10 - Stoploss as Difference between the purchase price and stop-loss target price 11 - Square Off as Difference between purchase price and profit target price 12 - Multiplier for 5 paise. Resultant no. is the flexibility given while placing orders. ''' args = (TransactionType.Buy, self.instrument, 75, OrderType.StopLossLimit, ProductType.OneCancelsOther, round_off(self.res_vals[4]), round_off(self.res_vals[3]), 0, DurationType.DAY, round_off(self.res_vals[4] - self.sup_vals[5]), round_off(self.res_vals[-1] - self.res_vals[4]), None ) return args
def gann(price=0, direction='up'): angles = (0.02, 0.04, 0.08, 0.1, 0.15, 0.25, 0.35, 0.40, 0.42, 0.46, 0.48, 0.5, 0.67, 1.0) if direction == 'up': return [round_off((sqrt(price) + a)**2) for a in angles] elif direction == 'down': return [round_off((sqrt(price) - a)**2) for a in angles] else: return None
def select_symbol(self, event): 'Get usable strike prices for the symbol provided' inst = None feed = None exch = 'NSE_INDEX' global sym_dict choice = self.symbol_combo.get() sym = sym_dict[choice] try: inst = self.ts.client.get_instrument_by_symbol(exch, choice) except Exception as e: print('Unable to load the instrument ' + choice) try: feed = self.ts.client.get_live_feed(inst, LiveFeedType.Full) except Exception as e: print('unable to get live feed for' + sym) bp = round_off(feed['ltp'], 100) strike_prices = [] mult = 100 for x in range(-5, 5): sp = int(bp + (x * mult)) strike_prices.append(str(sp)) self.price_combo['text'] = str(bp) self.price_combo['values'] = strike_prices self.result_label['text'] = sym.upper() \ + self.dates_combo.get() \ + self.price_combo.get()\ + self.option_combo.get() self.set_info(feed)
def _create_sell_order(self): order = {'transaction': upstox.TransactionType.Sell, 'instrument': self.instrument, 'quantity': int(round_off(self.balance / self.sell, LOT_SIZE)), 'order_type': upstox.OrderType.Limit, 'product': upstox.ProductType.OneCancelsOther, 'buy_price': self.sell, 'stoploss': abs(self.sell + self.stoploss), 'target': abs(self.sell - self.target)} return order