Advertisement
ImDerekD

Added Termcolor - Fixed Duplicate Ranges

Jan 3rd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.54 KB | None | 0 0
  1. #!/usr/bin/bash python
  2.  
  3. import csv
  4. import datetime
  5. from datetime import datetime
  6. from colorama import Back, Fore, Style
  7. import sys
  8. from termcolor import colored, cprint
  9. from colorama import init
  10. import numbers
  11. import time
  12. import itertools
  13. from itertools import zip_longest
  14. from time import sleep
  15. with open('/Users/King/Spy_Current.csv', 'r') as csv_file:
  16. csv_reader = csv.reader(csv_file)
  17. header = next(csv_reader)
  18.  
  19.  
  20. ref = [] # Start off w/ empty list
  21. ref_Num = int() # First to go in list = ref # (390 cells in 1 day)(using ref+=1 for each row)
  22. data = [] # Not sure but I could rearrange for liquidity?
  23. Liquidity = float()
  24. found = int(0)
  25. Range = []
  26. Target = []
  27. filled = bool
  28. filled_Price = float()
  29. Range_List = {}
  30. Low_Range_Found = {}
  31. High_Range_Found = {}
  32. ht_filled = bool
  33. hr_filled = bool
  34. lr_filled = bool
  35. lt_filled = bool
  36. lows_found = int()
  37. highs_found = int()
  38. Range_Found = {}
  39. range_ref_String = ('')
  40. dTime = []
  41. printRanges = str()
  42. range_identifier_low = 'Low'
  43. range_identifier_high = 'High'
  44. range_identifier_all = 'All'
  45. All_Range_References = []
  46. All_Referenced_Prices = []
  47. menu_ans = input('What would you like to do? \n [1] Print Liquidity Data | [2] See previous ranges | [3] Test | [4] Show Changes By Date\n')
  48. if menu_ans == '1':
  49. Liquidity_Data = input('Would you like to print liquidity data? [y/n]: ')
  50. if menu_ans == '2':
  51. printRanges = input('Which ranges would you like to see?: [High/Low/All]\n')
  52. range_identifier = ''
  53. new_range = bool
  54. t = bool
  55. tLow = bool
  56. tHigh = bool
  57. Target = float()
  58. Range_Dict = {}
  59. TickString = str()
  60. Tick_String = ''
  61. Strength = int()
  62. StartTraceback = {}
  63. day_Count = int()
  64. tList = []
  65. last = float()
  66. LT = float()
  67. HT = float()
  68. last = float()
  69. TrendStrength = ''
  70. Previous = []
  71. allfoundallfilled = {}
  72. lowfilled = float()
  73. highfilled = float()
  74. rangefilled = bool
  75. low_Ranges_Filled = int()
  76. high_Ranges_Filled = int()
  77. high_Targets_Filled = int()
  78. low_Targets_Filled = int()
  79. prevVol = float(1)
  80. prevFlow = float(1)
  81. prevIndexValue = float(1)
  82. prevPrice = float(1)
  83.  
  84. for row in csv_reader:
  85. range_ref_String = ''
  86. Target_String = ''
  87. LRS = '$'
  88. LRT = '$'
  89. HRS = '$'
  90. HRT = '$'
  91. found_Price_String = '$'
  92. Target_String = '$'
  93. target_String = range_ref_String + ': $'
  94. end_String = 'Price while found: $'
  95. # row = [Time, Open, Close, High, Low, realVol, Money_Flow]
  96. ref_Num += 1 # Starting at 0
  97. dTime = str(datetime.strptime(row[0], '%a %b %d %H:%M'))
  98. Time = dTime[-14:]
  99. Open_Price = float(row[1]) # Price Data Dictionary
  100. Close_Price = float(row[2]) # Price Data Dictionary
  101. High_Price = float(row[3]) # Price Data Dictionary
  102. Low_Price = float(row[4]) # Price Data Dictionary
  103. Money_Flow = float(row[6]) # Price Data Dictionary
  104. Vol = row[5] # Price Data Dictionary
  105. f_Vol = float(Vol[:-1]) # Price Data Dictionary
  106. m_Vol = str(Vol[-1:]) # Price Data Dictionary
  107. if m_Vol == "K": # Price Data Dictionary
  108. f_Vol = f_Vol * 1000 # Price Data Dictionary
  109. if m_Vol == "M": # Price Data Dictionary
  110. f_Vol = f_Vol * 1000000
  111. if m_Vol != "K" and m_Vol != "M":
  112. f_Vol = float(row[5]) # Price Data Dictionary
  113. if f_Vol < 1:
  114. M_Price = HLCC
  115. else:
  116. M_Price = round(float(Money_Flow) / f_Vol, 2)
  117. HLCC = float(High_Price + Low_Price + Close_Price + Close_Price)/4 # Price Data Dictionary & RangeReference Dictionary # Price Data Dictionary & RangeReference Dictionary
  118. Diff = round(HLCC - M_Price, 2) # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  119. MMM = float(f_Vol * HLCC) # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  120. Liq_change = float(Money_Flow - MMM) # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  121. Liquidity += Liq_change # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  122. Date = str(Time[:5]) # Important
  123. military_time = str(Time[-8:])
  124. criteria = abs(.003*HLCC)
  125. Liq_Tick = int()
  126. Price_Tick = int()
  127.  
  128. allData = [ref_Num,Date, military_time, High_Price,Low_Price,Close_Price, HLCC, M_Price, f_Vol, Money_Flow,MMM, Liquidity,Liq_change]
  129. Data_Dict = {'REF#':[ref_Num],'Date':[Date],'Time':[military_time], 'Close_Price':[Close_Price], 'M_Price':[M_Price], 'Volume':[f_Vol]}
  130. '''USING THIS DATA
  131. [0]REFERENCE NUMBER
  132. [1]DATE
  133. [2]MILITARY_TIME
  134. [3]HIGH_PRICE
  135. [4]LOW_PRICE
  136. [5]CLOSE_PRICE
  137. [6]HLCC
  138. [7]M_Price
  139. [8]F_VOL
  140. [9]MONEY_FLOW
  141. [10]MARKETMAKERMOVE 'MMM'
  142. [11]LIQUIDITY
  143. [12]LIQ_CHANGE
  144. '''
  145. if abs(allData[7]-allData[6]) >= criteria:
  146. diff = abs(M_Price - Close_Price)
  147. Range_Clause = True
  148. range_identifier_all = 'All'
  149. else:
  150. Range_Clause = False
  151. if Range_Clause == True:
  152. t_price = M_Price
  153. found_Price = HLCC
  154. Low_Range = round(HLCC - abs(float(M_Price - HLCC)), 2)
  155. High_Range = round(HLCC + abs(float(M_Price - HLCC)), 2)
  156. Low_Target = round(Low_Range - abs(float(M_Price - HLCC)), 2)
  157. High_Target = round(High_Range + abs(float(M_Price - HLCC)), 2)
  158. RT_Reference1 = [Low_Range, High_Range, Low_Target, High_Target]
  159. LRS = '$' + str(Low_Range)
  160. LRT = '$' + str(Low_Target)
  161. HRS = '$' + str(High_Range)
  162. HRT = '$' + str(High_Target)
  163. found_Price_String = '$' + str(found_Price)
  164. RT_Reference = [LRS, LRT, HRS, HRT]
  165. Target_String = '$' + str(Target)
  166. lows = [LRS, LRT]
  167. highs = [HRS, HRT]
  168. range_ref_String = range_ref_String
  169. target_String = range_ref_String + ': $'
  170. end_String = 'Price while found: $' + str(Close_Price)
  171. if M_Price >= found_Price+diff:
  172. found += 1
  173. range_ref_String = "HIGH TARGET"
  174. tHigh = True
  175. Target = M_Price
  176. range_identifier = 'High'
  177. found_Price = HLCC
  178. range_identifier_all = 'All'
  179. thList = ['HIGH TARGET', High_Target, highfilled]
  180. filled = False
  181. ht_filled = False
  182. hr_filled = False
  183. highs_found += 1
  184. elif M_Price<= found_Price-diff:
  185. found += 1
  186. range_ref_String = "LOW TARGET"
  187. tLow = True
  188. Target = M_Price
  189. range_identifier = 'Low'
  190. range_identifier_all = 'All'
  191. found_Price = HLCC
  192. tlList = ['LOW TARGET', Low_Target, lowfilled]
  193. filled = False
  194. lt_filled = False
  195. lr_filled = False
  196. lows_found += 1
  197.  
  198.  
  199. if printRanges == range_identifier and range_identifier == range_identifier_low:
  200. Low_Range_Reference = [Date, military_time, range_ref_String, Target_String, end_String]
  201. Low_Range_Found = {'\nData Found':Low_Range_Reference, 'Watch for: $':lows, 'Potential Resistance: ':highs}
  202. Low_Range = Low_Range_Found
  203. for k, v in dict.items(Low_Range):
  204. print(Fore.RED, k, v)
  205.  
  206. if printRanges == range_identifier and range_identifier == range_identifier_high:
  207. High_Range_Reference = [Date, military_time, range_ref_String, end_String]
  208. High_Range_Found = {'\nData Found': High_Range_Reference, 'Watch for: $':highs, 'Potential Support: ':lows}
  209. High_Range = High_Range_Found
  210. for k, v in dict.items(High_Range):
  211. print(Fore.CYAN, k, v)
  212.  
  213. elif printRanges == range_identifier_all:
  214. if range_ref_String == 'LOW TARGET' or range_ref_String == 'HIGH TARGET':
  215. money_string = '$'
  216. Close_Price_String = money_string+str(Close_Price)
  217. Range_Reference = [Date, military_time, Close_Price_String, range_ref_String, Target_String]
  218. Low_Ranges = [LRS, LRT]
  219. High_Ranges = [HRS, HRT]
  220. Range_Found = {'<-- Reference':Range_Reference, 'Low Ranges':Low_Ranges, 'High Ranges':High_Ranges, 'REF#':ref_Num}
  221. Range_List[ref_Num] = Range_Found
  222. text = colored(str(found)+' '+str(Range_Found), 'cyan', 'on_grey', attrs=['reverse'])
  223. cprint(text)
  224.  
  225.  
  226. '''if Range_Clause == True:
  227. if range_ref_String == "HIGH TARGET" and Money_Flow < 300000000:
  228. print("MARKET MAKER HIGH TARGET")
  229. if range_ref_String == "LOW TARGET" and Money_Flow > 300000000:
  230. print("MARKET MAKER LOW TARGET")'''
  231.  
  232. else:
  233. Range_Clause = False
  234. tHigh = False
  235. tLow = False
  236.  
  237. if menu_ans == '1' and Liquidity_Data =='y':
  238.  
  239. if Close_Price > Open_Price and Liq_change > 0:
  240. Price_Tick = 1
  241. Liq_Tick = 1
  242. elif Close_Price >= Open_Price and Liq_change < 0:
  243. Price_Tick = 0
  244. Liq_Tick = -1
  245. elif Close_Price <= Open_Price and Liq_change > 0:
  246. Price_Tick = -1
  247. Liq_Tick = 0
  248. elif Close_Price <= Open_Price and Liq_change < 0:
  249. Price_Tick = -1
  250. Liq_Tick = -1
  251. Tick = Liq_Tick + Price_Tick
  252. Strength += Tick
  253.  
  254. if Tick == 2:
  255. Tick_String = Fore.BLUE+Back.GREEN+'STRONG BUYERS'+Style.RESET_ALL+' '+Fore.GREEN+str(Strength)
  256. if Tick == -1 and Price_Tick == 0:
  257. Tick_String = Fore.WHITE+'PRICE UP LIQ DOWN'+Style.RESET_ALL+' '+Fore.RED+str(Strength)
  258. if Tick == -2:
  259. Tick_String = Fore.RED+Back.YELLOW+'STRONG SELLERS'+Style.RESET_ALL+' '+Fore.WHITE+str(Strength)
  260. if Tick == -1 and Liq_Tick == 0:
  261. Tick_String = Fore.RED+'SHORT COVERING'+Style.RESET_ALL+' '+Fore.YELLOW+Back.BLUE+str(Strength)
  262. Range_List[ref_Num] = Range_Found
  263.  
  264. if lr_filled == False:
  265. if filled == False:
  266. if range_ref_String == "LOW TARGET" and Low_Price <= Low_Range:
  267. filled_Price = Low_Price
  268. time.sleep(.5)
  269. print(Fore.WHITE + Back.RED + "LOW RANGE FILLED" + Style.RESET_ALL)
  270. time.sleep(1)
  271. lr_filled = True
  272. lt_filled = False
  273. lrf = 1
  274. low_Ranges_Filled += lrf
  275. if lt_filled == False and lr_filled == True:
  276. if Close_Price <= Low_Target:
  277. filled_target_price = Close_Price
  278. time.sleep(.5)
  279. print(Fore.RED + Back.YELLOW + 'LOW TARGET FILLED' + Style.RESET_ALL)
  280. time.sleep(1)
  281. lt_filled = True
  282. filled = True
  283. low_Targets_Filled += 1
  284. if hr_filled == False:
  285. if filled == False:
  286. if range_ref_String == "HIGH TARGET" and High_Price >= High_Range:
  287. filled_range_price = High_Price
  288. time.sleep(.5)
  289. print(Fore.CYAN + "HIGH RANGE FILLED" + Style.RESET_ALL)
  290. time.sleep(1)
  291. hr_filled = True
  292. ht_filled = False
  293. hrf = 1
  294. high_Ranges_Filled += hrf
  295. if ht_filled == False and hr_filled == True:
  296. if Close_Price >= High_Target:
  297. filled_target_price = High_Price
  298. print(Fore.CYAN + "HIGH TARGET FILLED")
  299. time.sleep(1)
  300. ht_filled = True
  301. filled = True
  302. high_Targets_Filled += 1
  303. if Range_Clause == True:
  304. if range_ref_String == "HIGH TARGET" and Money_Flow < 300000000:
  305. if Liq_change > 1000000:
  306. print("MARKET MAKER HIGH TARGET")
  307. if range_ref_String == "LOW TARGET" and Money_Flow > 300000000:
  308. if Liq_change < 1000000:
  309. print("MARKET MAKER LOW TARGET")
  310.  
  311. Close_Price = Close_Price
  312. if tHigh == True:
  313. t = True
  314. HRS = str(High_Range)
  315. HRT = str(High_Target)
  316. LRS = str(Low_Range)
  317. LRT = str(Low_Target)
  318. print(Fore.YELLOW+'['+Date+']',military_time,Style.RESET_ALL+Fore.BLUE+Back.YELLOW+Style.BRIGHT+'Current Liquidity:'+'{:20,.2f}'.format(Liquidity)+Style.RESET_ALL+Fore.BLUE+Back.YELLOW+Style.BRIGHT+' Liq Change: '+'{:20,.2f}'.format(Liq_change)+Style.RESET_ALL, Fore.YELLOW+Back.BLUE+Style.BRIGHT,'Last Price: [$'+str(Close_Price)+'] '+Style.RESET_ALL+Tick_String+Style.RESET_ALL+Fore.GREEN+Back.BLUE+Style.BRIGHT+' NEW HIGH RANGE FOUND:[$'+HRS+']'+' NEW HIGH TARGET FOUND: [$'+HRT+']'+Style.RESET_ALL)
  319. time.sleep(2)
  320. add_Range_Target = input('Would you like to add this range to file?: [y/n]:')
  321. if add_Range_Target == 'y':
  322. with open('/Users/King/Desktop/RangeTargets.csv', 'a') as csv_file:
  323. file_PriceList = [Date, military_time, range_ref_String, Close_Price, M_Price, HRT, Money_Flow, f_Vol, LRS, LRT, Liquidity, Liq_change]
  324. wr = csv.writer(csv_file)
  325. wr.writerow(file_PriceList)
  326. else:
  327. t = False
  328. Close_Price = Close_Price
  329. if tLow == True:
  330. t = True
  331. HRS = str(High_Range)
  332. HRT = str(High_Target)
  333. LRS = str(Low_Range)
  334. LRT = str(Low_Target)
  335. Low_Prices = {'LOW RANGE: $': Low_Range, 'LOW TARGET: $': Low_Target} ##### May not need this line
  336. print(Fore.YELLOW+'['+Date+']',military_time,Style.RESET_ALL+Fore.CYAN+Back.RED+Style.BRIGHT+'Current Liquidity:'+'{:20,.2f}'.format(Liquidity)+Style.RESET_ALL+Fore.CYAN+Back.RED+Style.BRIGHT+' Liq Change: '+'{:20,.2f}'.format(Liq_change)+Style.RESET_ALL, Fore.YELLOW+Back.BLUE+Style.BRIGHT,'Last Price: [$'+str(Close_Price)+'] '+Style.RESET_ALL+Tick_String+Style.RESET_ALL+Fore.CYAN+Back.RED+Style.BRIGHT+' NEW LOW RANGE FOUND:[$'+LRS+']'+' NEW LOW TARGET FOUND: [$'+LRT+']'+Style.RESET_ALL)
  337. time.sleep(2)
  338. add_Range_Target = input('Would you like to add this range to file?: [y/n]:')
  339. if add_Range_Target == 'y':
  340. with open('/Users/King/Desktop/RangeTargets.csv', 'a') as csv_file:
  341. file_PriceList = [Date, military_time, range_ref_String, Close_Price, M_Price, LRT, Money_Flow, f_Vol, HRS, HRT, Liquidity, Liq_change]
  342. wr = csv.writer(csv_file)
  343. wr.writerow(file_PriceList)
  344. elif Liq_change < -1000000:
  345. print(Fore.YELLOW + '[' + Date + ']', military_time,
  346. Style.RESET_ALL + Fore.CYAN + Back.RED + Style.BRIGHT + 'Current Liquidity:' + '{:20,.2f}'.format(Liquidity) + Style.RESET_ALL + Fore.YELLOW + Back.RED + Style.BRIGHT + ' Liq Change: ' + '{:20,.2f}'.format(Liq_change) + Style.RESET_ALL, Fore.YELLOW + Back.RED + Style.BRIGHT,'Last Price: [$' + str(Close_Price) + '] ' + Style.RESET_ALL + Tick_String + Style.RESET_ALL + Fore.YELLOW + Back.RED + Style.BRIGHT + '**SELL SIGNAL**' + Style.RESET_ALL)
  347. time.sleep(1)
  348. else:
  349. t = False
  350. if abs(Liq_change) > 500000:
  351. time.sleep(.005)
  352. print(Fore.CYAN + '[' + Date + ']', military_time,Fore.CYAN + 'Current Liquidity:' + '{:20,.2f}'.format(Liquidity) + Style.RESET_ALL + Fore.YELLOW + Back.BLUE + Style.BRIGHT + ' Liq Change: ' + '{:20,.2f}'.format(Liq_change) + ' ' + Fore.YELLOW + Back.BLUE,'Last Price [$' + str(Close_Price) + '] ' + Tick_String + Style.RESET_ALL)
  353. elif Liquidity > 0:
  354. if Liq_change > 0:
  355. time.sleep(.005)
  356. print(Fore.YELLOW + '[' + Date + ']', military_time,
  357. Fore.GREEN + 'Current Liquidity:' + '{:20,.2f}'.format(
  358. Liquidity) + Fore.GREEN + ' Liq Change: ' + '{:20,.2f}'.format(Liq_change) + ' ' + Fore.YELLOW + Back.BLUE,'Last Price [$' + str(Close_Price) + '] ' + Tick_String + Style.RESET_ALL)
  359. if Liq_change < 0:
  360. time.sleep(.005)
  361. print(Fore.YELLOW + '[' + Date + ']', military_time,
  362. Fore.GREEN + 'Current Liquidity:' + '{:20,.2f}'.format(
  363. Liquidity) + Style.RESET_ALL + Fore.RED + ' Liq Change: ' + '{:20,.2f}'.format(Liq_change) + Style.RESET_ALL + ' ' + Fore.YELLOW + Back.BLUE,'Last Price [$' + str(Close_Price) + '] ' + Tick_String + Style.RESET_ALL)
  364. elif Liq_change > 0:
  365. time.sleep(.005)
  366. print(Fore.YELLOW + '[' + Date + ']', military_time,Fore.BLUE + 'Current Liquidity:' + '{:20,.2f}'.format(Liquidity) + Style.RESET_ALL + Fore.WHITE,' Liq Change: ' + '{:20,.2f}'.format(Liq_change) + ' ' + Fore.YELLOW + Back.BLUE,'Last Price [$' + str(Close_Price) + '] ' + Tick_String + Style.RESET_ALL)
  367. elif Liq_change < 0:
  368. time.sleep(.005)
  369. print(Fore.YELLOW + '[' + Date + ']', military_time,Fore.BLUE + 'Current Liquidity:' + '{:20,.2f}'.format(Liquidity) + Style.RESET_ALL + Fore.CYAN,' Liq Change: ' + '{:20,.2f}'.format(Liq_change) + ' ' + Fore.YELLOW + Back.BLUE+'Last Price [$' + str(Close_Price) + '] ' + Tick_String + Style.RESET_ALL)
  370. MIV_Index = round(100 * (f_Vol / prevVol) - 100 * ((Money_Flow * HLCC) / (prevFlow * prevPrice)), 3)
  371. runningValueIndex = round(MIV_Index+prevIndexValue, 3)
  372. prevPrice = Close_Price
  373. prevFlow = Money_Flow
  374. prevVol = f_Vol
  375. prevIndexValue = MIV_Index
  376. MIV_Index_String = str(MIV_Index)
  377. runningValueIndex_String = str(runningValueIndex)
  378. if abs(MIV_Index) > .25:
  379. if MIV_Index > .25:
  380. MIV_Index_String = str(round(MIV_Index, 2))
  381. print(Fore.BLACK+Back.WHITE+Style.BRIGHT+'MIV_Index: '+Style.RESET_ALL+Fore.BLACK+Back.WHITE+'[+'+MIV_Index_String+'%]'+Style.RESET_ALL+Fore.BLACK+Back.WHITE+Style.BRIGHT+'Running Value: '+Style.RESET_ALL+Fore.BLACK+Back.WHITE+'[+'+runningValueIndex_String+'%]'+Style.RESET_ALL)
  382. elif MIV_Index < -.25:
  383. MIV_Index_String = str(round(MIV_Index, 2))
  384. print(Fore.BLACK+Back.RED+Style.BRIGHT+'MIV_Index: '+Style.RESET_ALL+Fore.BLACK+Back.RED+'['+MIV_Index_String+'%]'+Style.RESET_ALL+Fore.BLACK+Back.RED+'Running Value: '+Style.RESET_ALL+Fore.BLACK+Back.RED+'['+runningValueIndex_String+'%]'+Style.RESET_ALL)
  385. else:
  386. '''if runningValueIndex > 0 and MIV_Index > 0:
  387. print(' '+Fore.BLACK+Back.WHITE+'MIV_Index:+'+MIV_Index_String+'% '+Style.RESET_ALL+' '+Fore.BLACK+Back.GREEN+'Running Value:+'+runningValueIndex_String+'%'+Style.RESET_ALL)
  388. if MIV_Index < 0 and runningValueIndex > 0:
  389. print(' '+Fore.RED+Back.YELLOW+'MIV_Index:'+MIV_Index_String+'% '+Style.RESET_ALL+' '+Fore.BLACK+Back.GREEN+'Running Value:+'+runningValueIndex_String+'%'+Style.RESET_ALL)
  390. if MIV_Index > 0 and runningValueIndex < 0:
  391. print(' '+Fore.WHITE+'MIV_Index:+'+MIV_Index_String+'% '+Style.RESET_ALL+' '+Fore.RED+Back.YELLOW+'Running Value:'+runningValueIndex_String+'%'+Style.RESET_ALL)
  392. if MIV_Index < 0 and runningValueIndex < 0:
  393. print(' '+Fore.RED+'MIV_Index:'+MIV_Index_String+'% '+Style.RESET_ALL+' '+Fore.RED+'Running Value:'+runningValueIndex_String+'%'+Style.RESET_ALL)'''
  394.  
  395. '''else:
  396. runningValueIndex += MIV_Index
  397. runningValueIndex_String = str(round(runningValueIndex, 2))
  398. if runningValueIndex > 0:
  399. print(Fore.GREEN+'MIV_Index: '+runningValueIndex_String, '%')
  400. else:
  401. runningValueIndex_String = str(round(runningValueIndex, 2))
  402. print(Fore.RED+'MIV_Index: '+runningValueIndex_String, '%')'''
  403.  
  404.  
  405.  
  406. '''if menu_ans == '1' and Liquidity_Data == 'list':
  407. print(Fore.CYAN + 'REF#:', ref_Num)
  408. time.sleep(.05)
  409. print(Fore.WHITE + Time)
  410. time.sleep(.05)
  411. print("Last:", "$" + str(Close_Price))
  412. time.sleep(.05)
  413. print("HLCC:", "$" + str(HLCC))
  414. time.sleep(.05)
  415. print("Money Price: ", "$" + str(round(M_Price, 2)))
  416. time.sleep(.05)
  417. print('Price Diff: ' + '$' + str(Diff))
  418. time.sleep(.05)
  419. if f_Vol > 1000000:
  420. print(Fore.YELLOW + 'Volume:' + '{:20,.2f}'.format(f_Vol))
  421. else:
  422. print(Fore.WHITE + 'Volume:' + '{:20,.2f}'.format(f_Vol))
  423. time.sleep(.05)
  424. if Money_Flow > 350000000:
  425. print(Fore.YELLOW + '$Flow:' + '{:20,.2f}'.format(Money_Flow))
  426. else:
  427. print(Fore.WHITE + '$Flow:' + '{:20,.2f}'.format(Money_Flow))
  428. time.sleep(.05)
  429. if Liq_change < 0:
  430. print(Fore.RED + 'Liq Change:', '{:20,.2f}'.format(Liq_change), Style.RESET_ALL)
  431. else:
  432. print(Fore.CYAN + 'Liq Change:', '{:20,.2f}'.format(Liq_change))
  433. time.sleep(.05)
  434. if Liquidity < 0:
  435. print(Fore.RED + 'Current Liquidity:' + '{:20,.2f}'.format(Liquidity), Style.RESET_ALL)
  436. else:
  437. print(Fore.CYAN + 'Current Liquidity:' + '{:20,.2f}'.format(Liquidity), Style.RESET_ALL)
  438. time.sleep(.1)'''
  439.  
  440. if menu_ans == '3':
  441. Days = ref_Num // 390
  442. Hours = float(ref_Num / 60)
  443. HoursLeft = float(ref_Num / 390 - Days) / 60
  444. Minutes = ref_Num
  445. MinutesLeft = HoursLeft * 100
  446. print('Total Minutes recorded: ',ref_Num)
  447. print('Total Days recorded ', Days,'Days', str(round(HoursLeft, 2)), 'Hours', str(round(MinutesLeft, 2)), 'Minutes')
  448. testans = input('Would you like to see other found ranges?: [y/n]')
  449. if testans == 'y':
  450. with open('/Users/King/Desktop/RangeTargets.csv', 'r') as csv_file:
  451. csv_reader = csv.reader(csv_file)
  452. for row in csv_reader:
  453. Date = row[0]
  454. Time = row[1]
  455. range_ref_String = row[2]
  456. Close_Price = float(row[3])
  457. M_Price = float(row[4])
  458. TargetPrice = row[5]
  459. Money_Flow = float(row[6])
  460. f_Vol = float(row[7])
  461. OppRange = row[8]
  462. OppTarget = row[9]
  463. list = [Date, Time, range_ref_String]
  464. Targets = [M_Price, TargetPrice]
  465. oppositePrices = [OppRange, OppTarget]
  466. listlist = [TargetPrice, OppRange, OppTarget]
  467. dict = {'Info':list, 'Targets: ':Targets, 'Found price: ':Close_Price, 'Opposite Ranges/Targets':oppositePrices}
  468. print(dict)
  469. if menu_ans == '4':
  470. print('Low Targets Found: ', lows_found)
  471. shortAccuracy = low_Ranges_Filled / lows_found
  472. print('Low Targets Met: ', low_Ranges_Filled, '[Accuracy: ', shortAccuracy, '%')
  473. print('High Targets Found: ', highs_found)
  474. longAccuracy = high_Ranges_Filled / highs_found
  475. print('Long Targets Met: ', high_Ranges_Filled, '[Accuracy: ', longAccuracy, '%')
  476.  
  477. print(Fore.CYAN + 'REF#:', ref_Num)
  478. time.sleep(.25)
  479. print(Fore.WHITE + Time)
  480. time.sleep(.25)
  481. print("Last:", "$" + str(Close_Price))
  482. time.sleep(.25)
  483. print("HLCC:", "$" + str(HLCC))
  484. time.sleep(.25)
  485. print("Money Price: ", "$" + str(round(M_Price, 2)))
  486. time.sleep(.25)
  487. print('Price Diff: ' + '$' + str(Diff))
  488. time.sleep(.25)
  489. if f_Vol > 1000000:
  490. print(Fore.YELLOW + 'Volume:' + '{:20,.2f}'.format(f_Vol))
  491. else:
  492. print(Fore.WHITE + 'Volume:' + '{:20,.2f}'.format(f_Vol))
  493. time.sleep(.25)
  494. if Money_Flow > 350000000:
  495. print(Fore.YELLOW + '$Flow:' + '{:20,.2f}'.format(Money_Flow))
  496. else:
  497. print(Fore.WHITE + '$Flow:' + '{:20,.2f}'.format(Money_Flow))
  498. time.sleep(.25)
  499. if Liq_change < 0:
  500. print(Fore.RED + 'Liq Change:', '{:20,.2f}'.format(Liq_change), Style.RESET_ALL)
  501. else:
  502. print(Fore.CYAN + 'Liq Change:', '{:20,.2f}'.format(Liq_change))
  503. time.sleep(.25)
  504. if Liquidity < 0:
  505. print(Fore.RED + 'Current Liquidity:' + '{:20,.2f}'.format(Liquidity), Style.RESET_ALL)
  506. else:
  507. print(Fore.CYAN + 'Current Liquidity:' + '{:20,.2f}'.format(Liquidity), Style.RESET_ALL)
  508. time.sleep(.25)
  509. percent_Strength = round(Strength / ref_Num, 4)
  510. if percent_Strength >= -.68:
  511. percent_Strength_String = Fore.WHITE+'Current Strength: '+str(percent_Strength)+'%'
  512. else:
  513. percent_Strength_String = Fore.RED+'Current Strength: '+str(percent_Strength)+'%'
  514. new_Strength = 100-(100*abs(percent_Strength- -.3153) / .9333)
  515. '''new_Strength = 100-abs((100*(percent_Strength- -.9333/percent_Strength - -.286)))+100'''
  516. if new_Strength > 70:
  517. new_Strength_String = Fore.CYAN+'Bullishness Percentile: '+str(round(new_Strength, 2))+'%'+Style.RESET_ALL
  518. else:
  519. new_Strength_String = Fore.RED+'Bullishness Percentile: '+str(round(new_Strength, 2))+'%'+Style.RESET_ALL
  520. print(percent_Strength_String)
  521. print(new_Strength_String)
  522. print('\n Low Ranges/Targets Found|Filled:', lows_found, '| ', low_Ranges_Filled)
  523. print('\nHigh Ranges/Targets Found|Filled: ',highs_found, '| ', high_Ranges_Filled)
  524. print(found)
  525.  
  526. '''if found >0:
  527. tList = tList
  528. if tList[1] == 'High':
  529. print(Fore.GREEN+'LAST RANGE FOUND: [$' + str(Low_Range)+']','[$' + str(High_Range)+']', ' [' + range_ref_String + ': $' + str(Target)+']'+Style.RESET_ALL)
  530. print(Fore.GREEN+'POTENTIAL TARGETS: [$' + str(Low_Target)+']', '[$' + str(High_Target)+']'+Style.RESET_ALL)
  531. print(Fore.GREEN+'Found price: [$' + found_price + ']', 'Target implies a move of [' + implied_move + '%]'+'from current price ['+str(Close_Price)+']'+Style.RESET_ALL)
  532. else:
  533. tList = tList
  534. if tList[1] == 'Low':
  535. print(Fore.RED+'LAST RANGE FOUND: [$' + str(Low_Range)+']','$' + str(High_Range) + ' [' + range_ref_String + ': $' + str(Target)+Style.RESET_ALL)
  536. print(Fore.RED+'POTENTIAL TARGETS: [$' + str(Low_Target)+']', '$' + str(High_Target)+Style.RESET_ALL)
  537. print(Fore.RED+'Found price: [$' + (found_price) + ']', 'Target implies a move of [' + implied_move + '%]' + 'from current price [' + str(Close_Price) + ']'+Style.RESET_ALL)'''
  538.  
  539. '''input = input('Would you like to see other found ranges?: [y/n]')
  540. if input == 'y':
  541. with open('/Users/King/Desktop/RangeTargets.csv' 'r') as csv_file:
  542. csv_reader = csv.reader(csv_file)
  543. for row in csv_file:
  544. row[0] = Date
  545. row[1] = Time
  546. row[2] = range_ref_String
  547. row[3] = Close_Price
  548. row[4] = M_Price
  549. row[5] = TargetPrice
  550. print('\nLow Ranges/Targets Found|Filled: ', lows_found, '| ', low_Ranges_Filled, str(round(low_range_Accuracy, 2)), '%')
  551. low_range_Accuracy = low_Ranges_Filled / lows_found
  552.  
  553. row[6] = Money_Flow
  554. row[7] = f_Vol
  555. row[8] = OppRange
  556. row[9] = OppTarget'''
  557.  
  558. '''if abs(Liq_change) > 500000:
  559. time.sleep(.005)
  560. print(Fore.CYAN+'['+Date+']',military_time,Fore.CYAN+'Current Liquidity:'+'{:20,.2f}'.format(Liquidity)+Style.RESET_ALL+Fore.YELLOW+Back.BLUE+Style.BRIGHT+' Liq Change: '+'{:20,.2f}'.format(Liq_change)+' '+Fore.YELLOW+Back.BLUE, 'Last Price [$'+str(Close_Price)+'] '+Tick_String+Style.RESET_ALL)
  561. else if Liquidity > 0:
  562. if Liq_change > 0:
  563. time.sleep(.005)
  564. print(Fore.YELLOW+'['+Date+']', military_time,Fore.GREEN+'Current Liquidity:'+'{:20,.2f}'.format(Liquidity)+Fore.GREEN+' Liq Change: ' + '{:20,.2f}'.format(Liq_change)+' '+Fore.YELLOW+Back.BLUE, 'Last Price [$'+str(Close_Price)+'] '+Tick_String+Style.RESET_ALL)
  565. if Liq_change < 0:
  566. time.sleep(.005)
  567. print(Fore.YELLOW+'['+Date+']', military_time,Fore.GREEN+'Current Liquidity:'+'{:20,.2f}'.format(Liquidity)+Style.RESET_ALL+Fore.RED+' Liq Change: '+'{:20,.2f}'.format(Liq_change)+Style.RESET_ALL+' '+Fore.YELLOW+Back.BLUE, 'Last Price [$'+str(Close_Price)+'] '+Tick_String+Style.RESET_ALL)
  568. else if Liq_change > 0:
  569. time.sleep(.005)
  570. print(Fore.YELLOW+'['+Date+']', military_time,Fore.BLUE+'Current Liquidity:'+'{:20,.2f}'.format(Liquidity)+Style.RESET_ALL+Fore.CYAN,' Liq Change: '+'{:20,.2f}'.format(Liq_change)+' '+Fore.YELLOW+Back.BLUE, 'Last Price [$'+str(Close_Price)+'] '+Tick_String+Style.RESET_ALL)
  571. else if Liq_change < 0:
  572. time.sleep(.005)
  573. print(Fore.RED+'['+Date+']', military_time,Fore.BLUE+'Current Liquidity:'+'{:20,.2f}'.format(Liquidity)+Style.RESET_ALL+Fore.CYAN,' Liq Change: '+'{:20,.2f}'.format(Liq_change)+' '+Fore.YELLOW+Back.BLUE, 'Last Price [$'+str(Close_Price)+'] '+Tick_String+Style.RESET_ALL)'''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement