Advertisement
dequone

tend analyse alfa 2

Jan 30th, 2014
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.27 KB | None | 0 0
  1. def tendAnalyse(ordersToBuy, ordersToSell):
  2.     global d, lastd, D, LD, fl, i, j, L
  3.  
  4.     if fl == 1:
  5.         lastd = d
  6.         fl = 2
  7.     elif fl == 2:
  8.         D = lastd - d
  9.         fl = 3
  10.     elif fl == 3:
  11.         D = lastd - d
  12.         if LD < D and j == 0:
  13.             i += 1
  14.             #print "i = " + str(i)    
  15.         elif LD > D and i == 0:
  16.             j += 1
  17.             #print "j = " + str(j)
  18.  
  19.         if D < 0 and j > 1:
  20.             print str(datetime.now()) + ' try to buy, d = ' + str(d) + '; mtb = ' + str(minToBuy) + '; mts = ' + str(maxToSell) + '\n'
  21.             log(workLog, '[{0}] try to buy: d={1}; mtb={2}; mts={3}'.format(datetime.now(), d, minToBuy, maxToSell))
  22.         elif D > 0 and i > 1:
  23.             print str(datetime.now()) + ' try to sell, d = ' + str(d) + '; mtb = ' + str(minToBuy) + '; mts = ' + str(maxToSell) + '\n'
  24.             log(workLog, '[{0}] try to sell: d={1}; mtb={2}; mts={3}'.format(datetime.now(), d, minToBuy, maxToSell))
  25.         if i > 1 and j > 1:
  26.             i = j = 0
  27.            
  28.         print "d = " + str(d) + "; lastd = " + str(lastd) + "; D = " + str(D) + "; LD = " + str(LD)        
  29.         if lastd != d:
  30.             lastd = d
  31.             if LD != D:
  32.                 LD = D            
  33.  
  34.     time.sleep(3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement