Advertisement
ImDerekD

Eric.py

Jan 4th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.82 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.  
  16. print('To view the ranges for each $TICKER in the iFiles folder -> you need to scavenge them fist.\n Enter the filename (without the extension), then use option 1 for \n in depth quotes. Use option 4 for a quicker version of option 1. ')
  17. dir = '/Users/ericdeckeriFiles/'
  18. rangedir = '/Users/ericdeckeriFiles/iRanges/'
  19. filename = input('Input Filename: [Ticker][Number](ex. DIA2 = $DIA, 2 min chart) ')
  20. with open(dir+str(filename)+'.csv', 'r') as csv_file:
  21. csv_reader = csv.reader(csv_file)
  22. header = next(csv_reader)
  23.  
  24.  
  25. ref = [] # Start off w/ empty list
  26. ref_Num = int(0) # First to go in list = ref # (390 cells in 1 day)(using ref+=1 for each row)
  27. data = [] # Not sure but I could rearrange for liquidity?
  28. Liquidity = float()
  29. found = int(0)
  30. Range = []
  31. Tick = int()
  32. Target = []
  33. filled = bool
  34. filled_Price = float()
  35. Range_List = {}
  36. Low_Range_Found = {}
  37. High_Range_Found = {}
  38. ht_filled = bool
  39. hr_filled = bool
  40. lr_filled = bool
  41. lt_filled = bool
  42. lows_found = int()
  43. highs_found = int()
  44. Range_Found = {}
  45. range_ref_String = ('')
  46. dTime = []
  47. printRanges = str()
  48. range_identifier_low = 'Low'
  49. range_identifier_high = 'High'
  50. range_identifier_all = 'All'
  51. All_Range_References = []
  52. All_Referenced_Prices = []
  53. menu_ans = input('What would you like to do? \n [1] Print Liquidity Data | [2] See previous ranges | [3] RangeTargets File | [4] No-Stop-Data-Add [5] Current Info\n')
  54. if menu_ans == '1':
  55. Liquidity_Data = input('Would you like to print liquidity data? [y/n]: ')
  56. if menu_ans == '2':
  57. printRanges = input('Which ranges would you like to see?: [High/Low/All]\n')
  58. if menu_ans == '4':
  59. NoStop = True
  60. CandleDur = input('Candle Duration: ')
  61. else:
  62. NoStop = False
  63. if menu_ans == '3':
  64. option3 = True
  65. range_identifier = ''
  66. new_range = bool
  67. t = bool
  68. tLow = bool
  69. tHigh = bool
  70. Target = float()
  71. Range_Dict = {}
  72. TickString = str()
  73. Tick_String = ''
  74. Strength = int()
  75. StartTraceback = {}
  76. day_Count = int()
  77. tList = []
  78. last = float()
  79. LT = float()
  80. HT = float()
  81. last = float()
  82. TrendStrength = ''
  83. Previous = []
  84. allfoundallfilled = {}
  85. lowfilled = float()
  86. highfilled = float()
  87. rangefilled = bool
  88. low_Ranges_Filled = int()
  89. high_Ranges_Filled = int()
  90. high_Targets_Filled = int()
  91. low_Targets_Filled = int()
  92. prevVol = float(1)
  93. prevFlow = float(1)
  94. prevIndexValue = float(1)
  95. prevPrice = float(1)
  96. Status = str('')
  97. RangeTarget = float()
  98. rFound = bool
  99. for row in csv_reader:
  100. range_ref_String = ''
  101. LRS = '$'
  102. LRT = '$'
  103. HRS = '$'
  104. HRT = '$'
  105. found_Price_String = '$'
  106. end_String = 'Price while found: $'
  107. # row = [Time, Open, Close, High, Low, realVol, Money_Flow]
  108. ref_Num += 1 # Starting at 0
  109. dTime = str(datetime.strptime(row[0], '%a %b %d %H:%M'))
  110. Time = dTime[-14:]
  111. Open_Price = float(row[1]) # Price Data Dictionary
  112. Close_Price = float(row[2]) # Price Data Dictionary
  113. High_Price = float(row[3]) # Price Data Dictionary
  114. Low_Price = float(row[4]) # Price Data Dictionary
  115. Money_Flow = float(row[6]) # Price Data Dictionary
  116. Vol = row[5] # Price Data Dictionary
  117. f_Vol = float(Vol[:-1]) # Price Data Dictionary
  118. m_Vol = str(Vol[-1:]) # Price Data Dictionary
  119. if m_Vol == "K": # Price Data Dictionary
  120. f_Vol = f_Vol * 1000 # Price Data Dictionary
  121. if m_Vol == "M": # Price Data Dictionary
  122. f_Vol = f_Vol * 1000000
  123. if m_Vol != "K" and m_Vol != "M":
  124. f_Vol = float(row[5]) # Price Data Dictionary
  125. if f_Vol < 1:
  126. M_Price = HLCC
  127. else:
  128. M_Price = round(float(Money_Flow) / f_Vol, 2)
  129. HLCC = float(High_Price + Low_Price + Close_Price + Close_Price)/4 # Price Data Dictionary & RangeReference Dictionary # Price Data Dictionary & RangeReference Dictionary
  130. Diff = round(HLCC - M_Price, 2) # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  131. MMM = float(f_Vol * HLCC) # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  132. Liq_change = float(Money_Flow - MMM) # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  133. Liquidity += Liq_change # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  134. Date = str(Time[:5]) # Important
  135. military_time = str(Time[-8:])
  136. criteria = abs(.003*HLCC)
  137. Liq_Tick = int()
  138. Price_Tick = int()
  139. tREF = int()
  140. rFound = False
  141. percent_Strength = Strength / ref_Num
  142. allData = [ref_Num,Date, military_time, High_Price,Low_Price,Close_Price, HLCC, M_Price, f_Vol, Money_Flow,MMM, Liquidity,Liq_change]
  143. Data_Dict = {'REF#':[ref_Num],'Date':[Date],'Time':[military_time], 'Close_Price':[Close_Price], 'M_Price':[M_Price], 'Volume':[f_Vol]}
  144. '''USING THIS DATA
  145. [0]REFERENCE NUMBER
  146. [1]DATE
  147. [2]MILITARY_TIME
  148. [3]HIGH_PRICE
  149. [4]LOW_PRICE
  150. [5]CLOSE_PRICE
  151. [6]HLCC
  152. [7]M_Price
  153. [8]F_VOL
  154. [9]MONEY_FLOW
  155. [10]MARKETMAKERMOVE 'MMM'
  156. [11]LIQUIDITY
  157. [12]LIQ_CHANGE
  158. '''
  159. if abs(allData[7]-allData[6]) >= criteria:
  160. diff = abs(M_Price - Close_Price)
  161. Range_Clause = True
  162. range_identifier_all = 'All'
  163. else:
  164. Range_Clause = False
  165. if Range_Clause == True:
  166. t_price = M_Price
  167. found_Price = HLCC
  168. Low_Range = round(HLCC - abs(float(M_Price - HLCC)), 2)
  169. High_Range = round(HLCC + abs(float(M_Price - HLCC)), 2)
  170. Low_Target = round(Low_Range - abs(float(M_Price - HLCC)), 2)
  171. High_Target = round(High_Range + abs(float(M_Price - HLCC)), 2)
  172. RT_Reference1 = [Low_Range, High_Range, Low_Target, High_Target]
  173. LRS = '$' + str(Low_Range)
  174. LRT = '$' + str(Low_Target)
  175. HRS = '$' + str(High_Range)
  176. HRT = '$' + str(High_Target)
  177. found_Price_String = '$' + str(found_Price)
  178. RT_Reference = [LRS, LRT, HRS, HRT]
  179. lows = [LRS, LRT]
  180. highs = [HRS, HRT]
  181. range_ref_String = range_ref_String
  182. target_String = range_ref_String + ': $'
  183. end_String = 'Price while found: $' + str(Close_Price)
  184. Target_String = '$' + str(Target)
  185. if M_Price >= found_Price+diff:
  186. found += 1
  187. range_ref_String = "HIGH TARGET"
  188. tHigh = True
  189. RangeTarget = High_Target
  190. Target = M_Price
  191. range_identifier = 'High'
  192. found_Price = HLCC
  193. range_identifier_all = 'All'
  194. thList = ['HIGH TARGET', High_Target, highfilled]
  195. filled = False
  196. ht_filled = False
  197. hr_filled = False
  198. highs_found += 1
  199. rFound = True
  200. elif M_Price<= found_Price-diff:
  201. found += 1
  202. range_ref_String = "LOW TARGET"
  203. tLow = True
  204. RangeTarget = Low_Target
  205. Target = M_Price
  206. range_identifier = 'Low'
  207. range_identifier_all = 'All'
  208. found_Price = HLCC
  209. tlList = ['LOW TARGET', Low_Target, lowfilled]
  210. filled = False
  211. lt_filled = False
  212. lr_filled = False
  213. lows_found += 1
  214. rFound = True
  215.  
  216.  
  217. if printRanges == range_identifier and range_identifier == range_identifier_low:
  218. Low_Range_Reference = [Date, military_time, range_ref_String, Target_String, end_String]
  219. Low_Range_Found = {'\nData Found':Low_Range_Reference, 'Watch for: $':lows, 'Potential Resistance: ':highs}
  220. Low_Range = Low_Range_Found
  221. for k, v in dict.items(Low_Range):
  222. print(Fore.RED, k, v)
  223.  
  224. if printRanges == range_identifier and range_identifier == range_identifier_high:
  225. High_Range_Reference = [Date, military_time, range_ref_String, end_String]
  226. High_Range_Found = {'\nData Found': High_Range_Reference, 'Watch for: $':highs, 'Potential Support: ':lows}
  227. High_Range = High_Range_Found
  228. for k, v in dict.items(High_Range):
  229. print(Fore.CYAN, k, v)
  230.  
  231. elif printRanges == range_identifier_all:
  232. if range_ref_String == 'LOW TARGET' or range_ref_String == 'HIGH TARGET':
  233. money_string = '$'
  234. Target_String = '$' + str(Target)
  235. Close_Price_String = money_string+str(Close_Price)
  236. Range_Reference = [Date, military_time, Close_Price_String, range_ref_String, Target_String]
  237. Low_Ranges = [LRS, LRT]
  238. High_Ranges = [HRS, HRT]
  239. Range_Found = {'<-- Reference':Range_Reference, 'Low Ranges':Low_Ranges, 'High Ranges':High_Ranges, 'REF#':ref_Num}
  240. Range_List[ref_Num] = Range_Found
  241. text = colored(str(found)+' '+str(Range_Found), 'cyan', 'on_grey', attrs=['reverse'])
  242. cprint(text)
  243.  
  244.  
  245. '''if Range_Clause == True:
  246. if range_ref_String == "HIGH TARGET" and Money_Flow < 300000000:
  247. print("MARKET MAKER HIGH TARGET")
  248. if range_ref_String == "LOW TARGET" and Money_Flow > 300000000:
  249. print("MARKET MAKER LOW TARGET")'''
  250.  
  251. else:
  252. Range_Clause = False
  253. tHigh = False
  254. tLow = False
  255. rFound = False
  256.  
  257.  
  258.  
  259.  
  260. if menu_ans == '1' and Liquidity_Data == 'y':
  261. if Close_Price > Open_Price and Liq_change > 0:
  262. Price_Tick = 1
  263. Liq_Tick = 1
  264. elif Close_Price >= Open_Price and Liq_change < 0:
  265. Price_Tick = 0
  266. Liq_Tick = -1
  267. elif Close_Price <= Open_Price and Liq_change > 0:
  268. Price_Tick = -1
  269. Liq_Tick = 0
  270. elif Close_Price <= Open_Price and Liq_change < 0:
  271. Price_Tick = -1
  272. Liq_Tick = -1
  273.  
  274. Tick = Liq_Tick + Price_Tick
  275. Strength += Tick
  276. percent_Strength = round(Strength / ref_Num, 4)
  277.  
  278.  
  279. if Tick == 2:
  280. Tick_String = Fore.BLUE+Back.GREEN+'STRONG BUYERS'+Style.RESET_ALL+' '+Fore.GREEN+str(Strength)
  281. if Tick == -1 and Price_Tick == 0:
  282. Tick_String = Fore.WHITE+'PRICE UP LIQ DOWN'+Style.RESET_ALL+' '+Fore.RED+str(Strength)
  283. if Tick == -2:
  284. Tick_String = Fore.RED+Back.YELLOW+'STRONG SELLERS'+Style.RESET_ALL+' '+Fore.WHITE+str(Strength)
  285. if Tick == -1 and Liq_Tick == 0:
  286. Tick_String = Fore.RED+'SHORT COVERING'+Style.RESET_ALL+' '+Fore.YELLOW+Back.BLUE+str(Strength)
  287. Range_List[ref_Num] = Range_Found
  288. else:
  289.  
  290. if Range_Clause == True:
  291. if range_ref_String == "HIGH TARGET" and Money_Flow < 300000000:
  292. if Liq_change > 1000000:
  293. print("MARKET MAKER HIGH TARGET")
  294. if range_ref_String == "LOW TARGET" and Money_Flow > 300000000:
  295. if Liq_change < 1000000:
  296. print("MARKET MAKER LOW TARGET")
  297.  
  298.  
  299. if lr_filled == False:
  300. if filled == False:
  301. if range_ref_String == "LOW TARGET" and Low_Price <= Low_Range:
  302. filled_Price = Low_Price
  303. time.sleep(.5)
  304. print(Fore.WHITE + Back.RED + "LOW RANGE FILLED" + Style.RESET_ALL)
  305. time.sleep(1)
  306. lr_filled = True
  307. lt_filled = False
  308. lrf = 1
  309. low_Ranges_Filled += lrf
  310. if lt_filled == False and lr_filled == True:
  311. if Close_Price <= Low_Target:
  312. filled_target_price = Close_Price
  313. time.sleep(.5)
  314. print(Fore.RED + Back.YELLOW + 'LOW TARGET FILLED' + Style.RESET_ALL)
  315. time.sleep(1)
  316. lt_filled = True
  317. filled = True
  318. low_Targets_Filled += 1
  319. if hr_filled == False:
  320. if filled == False:
  321. if range_ref_String == "HIGH TARGET" and High_Price >= High_Range:
  322. filled_range_price = High_Price
  323. time.sleep(.5)
  324. print(Fore.CYAN + "HIGH RANGE FILLED" + Style.RESET_ALL)
  325. time.sleep(1)
  326. hr_filled = True
  327. ht_filled = False
  328. hrf = 1
  329. high_Ranges_Filled += hrf
  330. if ht_filled == False and hr_filled == True:
  331. if Close_Price >= High_Target:
  332. filled_target_price = High_Price
  333. print(Fore.CYAN + "HIGH TARGET FILLED")
  334. time.sleep(1)
  335. ht_filled = True
  336. filled = True
  337. high_Targets_Filled += 1
  338.  
  339.  
  340. if menu_ans == '4' or menu_ans == '1':
  341. if rFound == True:
  342. if tHigh == True:
  343. HRS = str(High_Range)
  344. HRT = str(High_Target)
  345. LRS = str(Low_Range)
  346. LRT = str(Low_Target)
  347. 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)
  348. time.sleep(2)
  349. if NoStop == True:
  350. with open(rangedir+str(filename)+'.csv', 'a') as csv_file:
  351. CandleDuration = CandleDur
  352. file_PriceList = [Date, military_time, range_ref_String, Close_Price, M_Price, HRT, Money_Flow, f_Vol, LRS, LRT, Liquidity, Liq_change, liq_flowPrice, MIV_Index, CandleDuration, ref_Num]
  353. wr = csv.writer(csv_file)
  354. wr.writerow(file_PriceList)
  355.  
  356. else:
  357. add_Range_Target = input('Would you like to add this range to file?: [y/n]:')
  358. if add_Range_Target == 'y':
  359. CandleDuration = str(filename[-1:])+'Min'
  360. with open(rangedir+str(filename)+'.csv', 'a') as csv_file:
  361. file_PriceList = [Date, military_time, range_ref_String, Close_Price, M_Price, HRT, Money_Flow, f_Vol, LRS, LRT, Liquidity, Liq_change, liq_flowPrice, MIV_Index, CandleDuration, ref_Num]
  362. wr = csv.writer(csv_file)
  363. wr.writerow(file_PriceList)
  364.  
  365. else:
  366. tHigh = False
  367. else:
  368. rFound = False
  369. Close_Price = Close_Price
  370.  
  371. if rFound == True:
  372. if tLow == True:
  373. HRS = str(High_Range)
  374. HRT = str(High_Target)
  375. LRS = str(Low_Range)
  376. LRT = str(Low_Target)
  377. Low_Prices = {'LOW RANGE: $': Low_Range, 'LOW TARGET: $': Low_Target} ##### May not need this line
  378. 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)
  379. time.sleep(2)
  380. if NoStop == True:
  381. with open(rangedir+str(filename)+'.csv', 'a') as csv_file:
  382. CandleDuration = CandleDur
  383. file_PriceList = [Date, military_time, range_ref_String, Close_Price, M_Price, LRT, Money_Flow, f_Vol, HRS, HRT, Liquidity, Liq_change, liq_flowPrice, MIV_Index, CandleDuration, ref_Num]
  384. wr = csv.writer(csv_file)
  385. wr.writerow(file_PriceList)
  386. else:
  387. add_Range_Target = input('Would you like to add this range to file?: [y/n]:')
  388. if add_Range_Target == 'y':
  389. CandleDuration = '1Min'
  390. with open(rangedir+str(filename)+'.csv', 'a') as csv_file:
  391. file_PriceList = [Date, military_time, range_ref_String, Close_Price, M_Price, LRT, Money_Flow, f_Vol, HRS, HRT, Liquidity, Liq_change, liq_flowPrice, MIV_Index, CandleDuration, ref_Num]
  392. wr = csv.writer(csv_file)
  393. wr.writerow(file_PriceList)
  394. else:
  395. tLow = False
  396. else:
  397. rFound = False
  398.  
  399.  
  400. if Liq_change < -1000000:
  401. 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.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)
  402. time.sleep(1)
  403. if abs(Liq_change) > 500000:
  404. time.sleep(.005)
  405. 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)
  406. elif Liquidity > 0:
  407. if Liq_change > 0:
  408. time.sleep(.005)
  409. print(Fore.YELLOW + '[' + Date + ']', military_time,
  410. Fore.GREEN + 'Current Liquidity:' + '{:20,.2f}'.format(
  411. Liquidity) + Fore.GREEN + ' Liq Change: ' + '{:20,.2f}'.format(Liq_change) + ' ' + Fore.YELLOW + Back.BLUE,'Last Price [$' + str(Close_Price) + '] ' + Tick_String + Style.RESET_ALL)
  412. if Liq_change < 0:
  413. time.sleep(.005)
  414. print(Fore.YELLOW + '[' + Date + ']', military_time,
  415. Fore.GREEN + 'Current Liquidity:' + '{:20,.2f}'.format(
  416. 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)
  417. elif Liq_change > 0:
  418. time.sleep(.005)
  419. 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)
  420. elif Liq_change < 0:
  421. time.sleep(.005)
  422. 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)
  423.  
  424. MIV_Index = round(100 * (f_Vol / prevVol) - 100 * ((Money_Flow * HLCC) / (prevFlow * prevPrice)), 3)
  425. runningValueIndex = round(MIV_Index + prevIndexValue, 3)
  426. prevPrice = Close_Price
  427. prevFlow = Money_Flow
  428. prevVol = f_Vol
  429. prevIndexValue = MIV_Index
  430. MIV_Index_String = str(MIV_Index)
  431. liq_flowPrice = abs(Liq_change / Money_Flow)
  432. runningValueIndex_String = str(runningValueIndex)
  433. if abs(MIV_Index) > .25:
  434. if MIV_Index > .25:
  435. MIV_Index_String = str(round(MIV_Index, 2))
  436. 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)
  437. elif MIV_Index < -.25:
  438. MIV_Index_String = str(round(MIV_Index, 2))
  439. 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)
  440.  
  441.  
  442. '''if runningValueIndex > 0 and MIV_Index > 0:
  443. print(' '+Fore.BLACK+Back.WHITE+'MIV_Index:+'+MIV_Index_String+'% '+Style.RESET_ALL+' '+Fore.BLACK+Back.GREEN+'Running Value:+'+runningValueIndex_String+'%'+Style.RESET_ALL)
  444. if MIV_Index < 0 and runningValueIndex > 0:
  445. print(' '+Fore.RED+Back.YELLOW+'MIV_Index:'+MIV_Index_String+'% '+Style.RESET_ALL+' '+Fore.BLACK+Back.GREEN+'Running Value:+'+runningValueIndex_String+'%'+Style.RESET_ALL)
  446. if MIV_Index > 0 and runningValueIndex < 0:
  447. print(' '+Fore.WHITE+'MIV_Index:+'+MIV_Index_String+'% '+Style.RESET_ALL+' '+Fore.RED+Back.YELLOW+'Running Value:'+runningValueIndex_String+'%'+Style.RESET_ALL)
  448. if MIV_Index < 0 and runningValueIndex < 0:
  449. print(' '+Fore.RED+'MIV_Index:'+MIV_Index_String+'% '+Style.RESET_ALL+' '+Fore.RED+'Running Value:'+runningValueIndex_String+'%'+Style.RESET_ALL)'''
  450.  
  451. '''else:
  452. runningValueIndex += MIV_Index
  453. runningValueIndex_String = str(round(runningValueIndex, 2))
  454. if runningValueIndex > 0:
  455. print(Fore.GREEN+'MIV_Index: '+runningValueIndex_String, '%')
  456. else:
  457. runningValueIndex_String = str(round(runningValueIndex, 2))
  458. print(Fore.RED+'MIV_Index: '+runningValueIndex_String, '%')'''
  459.  
  460.  
  461. if menu_ans == '3':
  462. printRangeFile = input('Would you like to see other found ranges?: [y/n]')
  463. if printRangeFile == 'y':
  464. file_Choose = input('Which file would you like to use?: (ex. NVDA5 - $NVDA 5 Min Candle Ranges ) ')
  465. with open(rangedir+str(file_Choose)+'.csv', 'r') as csv_file:
  466. csv_reader = csv.reader(csv_file)
  467. for row in csv_reader:
  468. Date = row[0]
  469. Time = row[1]
  470. range_ref_String = row[2]
  471. Close_Price = float(row[3])
  472. M_Price = float(row[4])
  473. TargetPrice = row[5]
  474. Money_Flow = float(row[6])
  475. f_Vol = float(row[7])
  476. OppRange = row[8]
  477. OppTarget = row[9]
  478. Liquidity = float(row[10])
  479. Liq_change = float(row[11])
  480. LFP = float(row[12])
  481. MIVI = float(row[13])
  482. ref_Num = int(row[15])
  483. CandleDuration = str(row[14])
  484. list = [Date, Time, range_ref_String]
  485. Targets = [M_Price, TargetPrice]
  486. MIV_Index = str(MIVI) + str('%')
  487. liq_flowPrice = str(round(LFP, 3))
  488. oppositePrices = [OppRange, OppTarget]
  489. Liq_change_String = str('$' + '{:20,.2f}'.format(Liq_change))
  490. listlist = []
  491. dict = {'': list, 'Targets: ':Targets, 'Found price: ':Close_Price,'Opposite Ranges/Targets':oppositePrices}
  492. range_info = {'MIV Index:': MIV_Index, 'Liq Change:':Liq_change_String,'Candle Duration:':CandleDuration, 'REF#':ref_Num}
  493. if MIVI < 0 and Liq_change > 0:
  494. infotext = colored(str(range_info), 'grey', 'on_cyan', attrs=['reverse', 'underline'])
  495. else:
  496. infotext = colored(str(range_info), 'grey', 'on_red', attrs=['reverse', 'underline'])
  497. for k, v in dict.items():
  498. time.sleep(.001)
  499. print(Fore.YELLOW, k, v)
  500. cprint(infotext)
  501. print('\n')
  502. break
  503. if menu_ans == '5':
  504. print('Sorry, still testing')
  505. '''choose_info = input('[2] MIV_Index [3] Liquidity [4] Liq Change [5] % Strength [6] Volume [7] Money Flow [8] Liq Flow Price')
  506. if choose_info == '2':
  507. MIV_Index = round(100 * (f_Vol / prevVol) - 100 * ((Money_Flow * HLCC) / (prevFlow * prevPrice)), 3)
  508. runningValueIndex = round(MIV_Index + prevIndexValue, 3)
  509. prevPrice = Close_Price
  510. prevFlow = Money_Flow
  511. prevVol = f_Vol
  512. prevIndexValue = MIV_Index
  513. MIV_Index_String = str(MIV_Index)
  514. liq_flowPrice = abs(Liq_change / Money_Flow)
  515. percent_Strength = round(Strength / ref_Num, 4)
  516. info = [Date, military_time, MIV_Index, Liquidity, Liq_change, percent_Strength]
  517. print(MIV_Index)'''
  518.  
  519.  
  520.  
  521.  
  522.  
  523. print(Fore.CYAN + 'REF#:', ref_Num)
  524. time.sleep(.25)
  525. print(Fore.WHITE + Time)
  526. time.sleep(.25)
  527. print("Last:", "$" + str(Close_Price))
  528. time.sleep(.25)
  529. print("HLCC:", "$" + str(HLCC))
  530. time.sleep(.25)
  531. print("Money Price: ", "$" + str(round(M_Price, 2)))
  532. time.sleep(.25)
  533. print('Price Diff: ' + '$' + str(Diff))
  534. time.sleep(.25)
  535. if f_Vol > 1000000:
  536. print(Fore.YELLOW + 'Volume:' + '{:20,.2f}'.format(f_Vol))
  537. else:
  538. print(Fore.WHITE + 'Volume:' + '{:20,.2f}'.format(f_Vol))
  539. time.sleep(.25)
  540. if Money_Flow > 350000000:
  541. print(Fore.YELLOW + '$Flow:' + '{:20,.2f}'.format(Money_Flow))
  542. else:
  543. print(Fore.WHITE + '$Flow:' + '{:20,.2f}'.format(Money_Flow))
  544. time.sleep(.25)
  545. if Liq_change < 0:
  546. print(Fore.RED + 'Liq Change:', '{:20,.2f}'.format(Liq_change), Style.RESET_ALL)
  547. else:
  548. print(Fore.CYAN + 'Liq Change:', '{:20,.2f}'.format(Liq_change))
  549. time.sleep(.25)
  550. if Liquidity < 0:
  551. print(Fore.RED + 'Current Liquidity:' + '{:20,.2f}'.format(Liquidity), Style.RESET_ALL)
  552. else:
  553. print(Fore.CYAN + 'Current Liquidity:' + '{:20,.2f}'.format(Liquidity), Style.RESET_ALL)
  554. time.sleep(.25)
  555. if percent_Strength >= -.68:
  556. percent_Strength_String_end = Fore.GREEN+'Current Strength: '+str(percent_Strength)+'%'
  557. if percent_Strength <-.68:
  558. percent_Strength_String_end = Fore.RED+'Current Strength: '+str(percent_Strength)+'%'
  559. if percent_Strength < 1 and percent_Strength > -.99:
  560. percent_Strength_String_end = colored('Current Strength: '+'#N/A', 'white', 'on_grey', attrs=['blink'])
  561. cprint(percent_Strength_String_end)
  562. else:
  563. print(percent_Strength_String_end)
  564. new_Strength = 100-(100*abs(percent_Strength- -.3153) / .9333)
  565. if new_Strength > 70:
  566. new_Strength_String = Fore.CYAN+'Bullishness Percentile: '+str(round(new_Strength, 2))+'%'+Style.RESET_ALL
  567. else:
  568. new_Strength_String = Fore.RED+'Bullishness Percentile: '+str(round(new_Strength, 2))+'%'+Style.RESET_ALL
  569. print(new_Strength_String)
  570. print('\nLow Ranges/Targets Found|Filled:',lows_found, '| ', low_Ranges_Filled)
  571. print('\nHigh Ranges/Targets Found|Filled: ',highs_found, '| ', high_Ranges_Filled)
  572. print(found)
  573.  
  574. '''if found >0:
  575. tList = tList
  576. if tList[1] == 'High':
  577. print(Fore.GREEN+'LAST RANGE FOUND: [$' + str(Low_Range)+']','[$' + str(High_Range)+']', ' [' + range_ref_String + ': $' + str(Target)+']'+Style.RESET_ALL)
  578. print(Fore.GREEN+'POTENTIAL TARGETS: [$' + str(Low_Target)+']', '[$' + str(High_Target)+']'+Style.RESET_ALL)
  579. print(Fore.GREEN+'Found price: [$' + found_price + ']', 'Target implies a move of [' + implied_move + '%]'+'from current price ['+str(Close_Price)+']'+Style.RESET_ALL)
  580. else:
  581. tList = tList
  582. if tList[1] == 'Low':
  583. print(Fore.RED+'LAST RANGE FOUND: [$' + str(Low_Range)+']','$' + str(High_Range) + ' [' + range_ref_String + ': $' + str(Target)+Style.RESET_ALL)
  584. print(Fore.RED+'POTENTIAL TARGETS: [$' + str(Low_Target)+']', '$' + str(High_Target)+Style.RESET_ALL)
  585. print(Fore.RED+'Found price: [$' + (found_price) + ']', 'Target implies a move of [' + implied_move + '%]' + 'from current price [' + str(Close_Price) + ']'+Style.RESET_ALL)'''
  586.  
  587. '''input = input('Would you like to see other found ranges?: [y/n]')
  588. if input == 'y':
  589. with open('/Users/ericdeckerDesktop/RangeTargets.csv' 'r') as csv_file:
  590. csv_reader = csv.reader(csv_file)
  591. for row in csv_file:
  592. row[0] = Date
  593. row[1] = Time
  594. row[2] = range_ref_String
  595. row[3] = Close_Price
  596. row[4] = M_Price
  597. row[5] = TargetPrice
  598. print('\nLow Ranges/Targets Found|Filled: ', lows_found, '| ', low_Ranges_Filled, str(round(low_range_Accuracy, 2)), '%')
  599. low_range_Accuracy = low_Ranges_Filled / lows_found
  600.  
  601. row[6] = Money_Flow
  602. row[7] = f_Vol
  603. row[8] = OppRange
  604. row[9] = OppTarget'''
  605.  
  606. '''if abs(Liq_change) > 500000:
  607. time.sleep(.005)
  608. 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)
  609. else if Liquidity > 0:
  610. if Liq_change > 0:
  611. time.sleep(.005)
  612. 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)
  613. if Liq_change < 0:
  614. time.sleep(.005)
  615. 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)
  616. else if Liq_change > 0:
  617. time.sleep(.005)
  618. 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)
  619. else if Liq_change < 0:
  620. time.sleep(.005)
  621. 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)'''
  622.  
  623. '''if menu_ans == '1' and Liquidity_Data == 'list':
  624. print(Fore.CYAN + 'REF#:', ref_Num)
  625. time.sleep(.05)
  626. print(Fore.WHITE + Time)
  627. time.sleep(.05)
  628. print("Last:", "$" + str(Close_Price))
  629. time.sleep(.05)
  630. print("HLCC:", "$" + str(HLCC))
  631. time.sleep(.05)
  632. print("Money Price: ", "$" + str(round(M_Price, 2)))
  633. time.sleep(.05)
  634. print('Price Diff: ' + '$' + str(Diff))
  635. time.sleep(.05)
  636. if f_Vol > 1000000:
  637. print(Fore.YELLOW + 'Volume:' + '{:20,.2f}'.format(f_Vol))
  638. else:
  639. print(Fore.WHITE + 'Volume:' + '{:20,.2f}'.format(f_Vol))
  640. time.sleep(.05)
  641. if Money_Flow > 350000000:
  642. print(Fore.YELLOW + '$Flow:' + '{:20,.2f}'.format(Money_Flow))
  643. else:
  644. print(Fore.WHITE + '$Flow:' + '{:20,.2f}'.format(Money_Flow))
  645. time.sleep(.05)
  646. if Liq_change < 0:
  647. print(Fore.RED + 'Liq Change:', '{:20,.2f}'.format(Liq_change), Style.RESET_ALL)
  648. else:
  649. print(Fore.CYAN + 'Liq Change:', '{:20,.2f}'.format(Liq_change))
  650. time.sleep(.05)
  651. if Liquidity < 0:
  652. print(Fore.RED + 'Current Liquidity:' + '{:20,.2f}'.format(Liquidity), Style.RESET_ALL)
  653. else:
  654. print(Fore.CYAN + 'Current Liquidity:' + '{:20,.2f}'.format(Liquidity), Style.RESET_ALL)
  655. time.sleep(.1)
  656. if NoStop == True:
  657. with open('/Users/ericdeckerDesktop/SPY_RangeTargets/NoStop.csv', 'r') as csv_file:
  658. csv_reader = csv.reader(csv_file)
  659. for row in csv_reader:
  660. Date = row[0]
  661. Time = row[1]
  662. range_ref_String = row[2]
  663. Close_Price = float(row[3])
  664. M_Price = float(row[4])
  665. TargetPrice = row[5]
  666. Money_Flow = float(row[6])
  667. f_Vol = float(row[7])
  668. OppRange = row[8]
  669. OppTarget = row[9]
  670. Liquidity = float(row[10])
  671. Liq_change = float(row[11])
  672. LFP = round(float(row[12]), 3)
  673. MIVI = float(row[13])
  674. ref_Num = int(row[14])
  675. list = [Date, Time, range_ref_String]
  676. Targets = [M_Price, TargetPrice]
  677. MIV_Index = str(MIVI)+str('%')
  678. liq_flowPrice = str(round(LFP, 3))
  679. oppositePrices = [OppRange, OppTarget]
  680. Liq_change_String = str('$'+'{:20,.2f}'.format(Liq_change))
  681. listlist = [MIV_Index, Liq_change, ref_Num]
  682. dict = {'':list, 'Targets: ':Targets, 'Found price: ':Close_Price, 'Opposite Ranges/Targets':oppositePrices}
  683. range_info = {'MIV Index: ':MIV_Index, ' Liq Change:':Liq_change_String, 'REF#':ref_Num}
  684. if MIVI < 0 and Liq_change > 0:
  685. infotext = colored(str(range_info), 'grey', 'on_cyan', attrs=['reverse', 'underline'])
  686. else:
  687. infotext = colored(str(range_info), 'grey', 'on_white', attrs=['reverse', 'underline'])
  688. for k,v in dict.items():
  689. time.sleep(.001)
  690. print(Fore.YELLOW, k,v)
  691.  
  692. cprint(infotext)
  693. print('\n')'''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement