示例#1
0
def buyorder(symbol, idata,logger):
 if (symbol.status == 0): # if only is not bought
  xstr = symbol.tname.replace(chr(124),chr(34)).split(chr(34))
  tsym = xstr[1]+".png"#r"D:\stock_market\My_Algo_Code\Live_trading\NIFTY15JUL8700CE.png" #
  bprice = round(idata.bp[classes.symbol.maxtick-1],2)
  symbol.bprice = bprice
  symbol.btime = time.time()
  #(BUY : bs = 1 ) (SELL : bs = 0 )
  symbol.status = util.eluka(symbol.type, tsym, symbol.lot_size, bprice, 1)
  #(symbol.status = 1 in a trade)
  #if (symbol.status==1): util.update_ledger(symbol)
  logger.info("BOUGHT :: "+symbol.tname+ ' at '+ str(bprice))
  localtime = time.localtime(time.time())
  #bprice = round(idata.ltp[classes.symbol.maxtick-1],2) # Assigning bprice for sell order to be max
  print "Bought ", symbol.tname, ' at ', bprice, str(localtime.tm_hour)+':'+str(localtime.tm_min)+':'+str(localtime.tm_sec)
 return
示例#2
0
def sellorder(symbol, idata,logger):
 if (symbol.status == 1): # if only bought
  xstr = symbol.tname.replace(chr(124),chr(34)).split(chr(34))
  tsym = xstr[1]+".png"
  sprice = round(idata.ap[classes.symbol.maxtick-1],2)
  symbol.sprice = sprice
  symbol.stime = time.time()
  #(BUY : bs = 1 ) (SELL : bs = 0 )
  symbol.status = util.eluka(symbol.type, tsym, symbol.lot_size, sprice, 0)
  #(symbol.status = 0 out of a trade)
  #if (symbol.status==0): util.update_ledger(symbol)
 
  logger.info("SOLD :: "+symbol.tname+ ' at '+ str(sprice)+ 'Perc = '+str( (symbol.sprice-symbol.bprice)*100/symbol.bprice) )
  localtime = time.localtime(time.time())
  print "Sold ", symbol.tname, ' at ', sprice, 'Perc = ',(symbol.sprice-symbol.bprice)*100/symbol.bprice,str(localtime.tm_hour)+':'+str(localtime.tm_min)+':'+str(localtime.tm_sec)
 return