Advertisement
ImDerekD

Scratch016.py

Apr 26th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 52.04 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. import hashlib
  16. import statistics
  17.  
  18. MIV_Spike_List = []
  19. MIV_Spike_Count = int()
  20. MIV_Spike = float()
  21. Avg_MIV_Spike = float()
  22.  
  23.  
  24.  
  25. with open('/Users/King/data.csv', 'r') as csv_file:
  26. csv_reader = csv.reader(csv_file)
  27. header = next(csv_reader)
  28.  
  29.  
  30. ref = [] # Start off w/ empty list
  31. ref_Num = int(0) # First to go in list = ref # (390 cells in 1 day)(using ref+=1 for each row)
  32. data = [] # Not sure but I could rearrange for liquidity?
  33. Liquidity = float()
  34. found = int(0)
  35. Range = []
  36. Target = []
  37. filled = bool
  38. filled_Price = float()
  39. Range_List = {}
  40. Low_Range_Found = {}
  41. High_Range_Found = {}
  42. ht_filled = bool
  43. hr_filled = bool
  44. lr_filled = bool
  45. lt_filled = bool
  46. lows_found = int()
  47. highs_found = int()
  48. Tick = int()
  49. Range_Found = {}
  50. range_ref_String = ('')
  51. dTime = []
  52. printRanges = str()
  53. range_identifier_low = 'Low'
  54. range_identifier_high = 'High'
  55. range_identifier_all = 'All'
  56. All_Range_References = []
  57. All_Referenced_Prices = []
  58. 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')
  59. if menu_ans == '1':
  60. Liquidity_Data = input('Would you like to print liquidity data? [y/n]: ')
  61. if menu_ans == '2':
  62. printRanges = input('Which ranges would you like to see?: [High/Low/All]\n')
  63. if menu_ans == '4':
  64. NoStop = True
  65. CandleDur = input('Candle Duration: ')
  66. else:
  67. NoStop = False
  68. if menu_ans == '3':
  69. option3 = True
  70. range_identifier = ''
  71. new_range = bool
  72. t = bool
  73. tLow = bool
  74. tHigh = bool
  75. Target = float()
  76. Range_Dict = {}
  77. TickString = str()
  78. Tick_String = ''
  79. Strength = int()
  80. StartTraceback = {}
  81. day_Count = int()
  82. tList = []
  83. last = float()
  84. LT = float()
  85. HT = float()
  86. last = float()
  87. ATR = float()
  88. OC_ATR = float()
  89. Avg_ATR = float()
  90. TrendStrength = ''
  91. Previous = []
  92. allfoundallfilled = {}
  93. lowfilled = float()
  94. highfilled = float()
  95. rangefilled = bool
  96. low_Ranges_Filled = int()
  97. high_Ranges_Filled = int()
  98. high_Targets_Filled = int()
  99. low_Targets_Filled = int()
  100. prevVol = float(1)
  101. prevFlow = float(1)
  102. prevIndexValue = float(1)
  103. prevPrice = float(1)
  104. Status = str('')
  105. RangeTarget = float()
  106. rFound = bool
  107. count = int(0)
  108. PCT_Range_Str = ''
  109.  
  110. sum_OC_Range = float()
  111. sum_HL_Range = float()
  112. sum_OHLC_Range = float()
  113. WarningString = ''
  114. sum_Liq = float()
  115. avg_Liq_change = float()
  116. HighRangeFlow = float()
  117. LowRangeFlow = float()
  118. LiqFlowPrice = float()
  119. LiqFlowPriceClone = float()
  120. EntryStr = str()
  121.  
  122. StrengthReference = float()
  123. AvgStrengthReference = float()
  124. counter = int()
  125.  
  126. liqList = []
  127. PULQ = bool
  128.  
  129. BuyVolume = float()
  130. BuyPower = float()
  131. ShortVolume = float()
  132. ShortPower = float()
  133. SellVolume = float()
  134. SellPower = float()
  135. BuySellRatio = float()
  136.  
  137.  
  138. Price1 = float()
  139. prevPrice1 = float()
  140. Last = float()
  141. gapDown = int()
  142. gapUp = int()
  143.  
  144. prevMPrice = float()
  145. prevMPrice2 = float()
  146. prevPrice1 = float()
  147. lastMPrice = float()
  148.  
  149.  
  150. for row in csv_reader:
  151. range_ref_String = ''
  152. LRS = '$'
  153. LRT = '$'
  154. HRS = '$'
  155. HRT = '$'
  156. found_Price_String = '$'
  157. end_String = 'Price while found: $'
  158. # row = [Time, Open, Close, High, Low, realVol, Money_Flow]
  159. ref_Num += 1 # Starting at 0
  160. dTime = str(datetime.strptime(row[0], '%a %b %d %H:%M'))
  161. Time = dTime[-14:]
  162. Open_Price = float(row[1]) # Price Data Dictionary
  163. Close_Price = float(row[2]) # Price Data Dictionary
  164. High_Price = float(row[3]) # Price Data Dictionary
  165. Low_Price = float(row[4]) # Price Data Dictionary
  166. Money_Flow = float(row[6]) # Price Data Dictionary
  167. Vol = row[5] # Price Data Dictionary
  168. f_Vol = float(Vol[:-1]) # Price Data Dictionary
  169. m_Vol = str(Vol[-1:]) # Price Data Dictionary
  170. if m_Vol == "K": # Price Data Dictionary
  171. f_Vol = f_Vol * 1000 # Price Data Dictionary
  172. if m_Vol == "M": # Price Data Dictionary
  173. f_Vol = f_Vol * 1000000
  174. if m_Vol != "K" and m_Vol != "M":
  175. f_Vol = float(row[5]) # Price Data Dictionary
  176. if f_Vol < 1:
  177. M_Price = HLCC
  178. else:
  179. M_Price = round(float(Money_Flow) / f_Vol, 2)
  180. HLCC = float(High_Price + Low_Price + Close_Price + Close_Price)/4 # Price Data Dictionary & RangeReference Dictionary # Price Data Dictionary & RangeReference Dictionary
  181. Diff = round(HLCC - M_Price, 2) # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  182. MMM = float(f_Vol * HLCC) # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  183. Liq_change = float(Money_Flow - MMM) # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  184. Liquidity += Liq_change # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  185. Date = str(Time[:5]) # Important
  186. military_time = str(Time[-8:])
  187. criteria = abs(.003*HLCC)
  188. hashTime = hashlib.md5(str.encode(military_time))
  189. Liq_Tick = int()
  190. Price_Tick = int()
  191. tREF = int()
  192. rFound = False
  193.  
  194. OC_Range = abs(Close_Price - Open_Price)
  195. HL_Range = abs(High_Price - Low_Price)
  196. sum_OC_Range += OC_Range
  197. sum_HL_Range += HL_Range
  198.  
  199. sum_Liq += abs(Liq_change)
  200. liqList.append(sum_Liq)
  201. avg_HL_Range = float()
  202. avg_OC_Range = float()
  203. abs_Liq = abs(Liq_change)
  204. prevLiq = float()
  205.  
  206.  
  207.  
  208.  
  209. if ref_Num >=2:
  210. prevPrice1 = Close_Price
  211. prevMPrice = M_Price
  212.  
  213.  
  214. if ref_Num % 2 != 0:
  215. Price1 = Close_Price
  216. prevMPrice1 = M_Price
  217.  
  218. if ref_Num % 2 == 0:
  219. Price2 = Close_Price
  220. prevMPrice2 = M_Price
  221.  
  222.  
  223. if ref_Num % 2 != 0 and ref_Num > 2:
  224. Last = Price2
  225. lastMPrice = prevMPrice2
  226.  
  227.  
  228. if ref_Num % 2 == 0 and ref_Num >= 2:
  229. Last = Price1
  230. lastMPrice = prevMPrice1
  231.  
  232.  
  233. percent_Strength = Strength / ref_Num
  234. allData = [ref_Num,Date, military_time, High_Price,Low_Price,Close_Price, HLCC, M_Price, f_Vol, Money_Flow,MMM, Liquidity,Liq_change]
  235. Data_Dict = {'REF#':[ref_Num],'Date':[Date],'Time':[military_time], 'Close_Price':[Close_Price], 'M_Price':[M_Price], 'Volume':[f_Vol]}
  236. '''USING THIS DATA
  237. [0]REFERENCE NUMBER
  238. [1]DATE
  239. [2]MILITARY_TIME
  240. [3]HIGH_PRICE
  241. [4]LOW_PRICE
  242. [5]CLOSE_PRICE
  243. [6]HLCC
  244. [7]M_Price
  245. [8]F_VOL
  246. [9]MONEY_FLOW
  247. [10]MARKETMAKERMOVE 'MMM'
  248. [11]LIQUIDITY
  249. [12]LIQ_CHANGE
  250. '''
  251.  
  252.  
  253.  
  254. if abs(allData[7]-allData[6]) >= criteria:
  255. diff = abs(M_Price - Close_Price)
  256. Range_Clause = True
  257. range_identifier_all = 'All'
  258. else:
  259. Range_Clause = False
  260. if Range_Clause == True:
  261. r_price = M_Price
  262. found_Price = HLCC
  263. Low_Range = round(HLCC - abs(float(M_Price - HLCC)), 2)
  264. High_Range = round(HLCC + abs(float(M_Price - HLCC)), 2)
  265. Low_Target = round(Low_Range - abs(float(M_Price - HLCC)), 2)
  266. High_Target = round(High_Range + abs(float(M_Price - HLCC)), 2)
  267. RT_Reference1 = [Low_Range, High_Range, Low_Target, High_Target]
  268. LRS = '$' + str(Low_Range)
  269. LRT = '$' + str(Low_Target)
  270. HRS = '$' + str(High_Range)
  271. HRT = '$' + str(High_Target)
  272. found_Price_String = '$' + str(found_Price)
  273. RT_Reference = [LRS, LRT, HRS, HRT]
  274. lows = [LRS, LRT]
  275. highs = [HRS, HRT]
  276. range_ref_String = range_ref_String
  277. target_String = range_ref_String + ': $'
  278. end_String = 'Price while found: $' + str(Close_Price)
  279. Target_String = '$' + str(Target)
  280.  
  281. LiqFlowPrice = .01*round(Money_Flow / abs(Liq_change), 3)
  282. VolLiqPrice = round(f_Vol / abs(Liq_change), 2)
  283. LiqFlowPriceClone = round(1000 * (abs(Liq_change) / Money_Flow), 4) * .01
  284.  
  285.  
  286. if M_Price >= High_Range:
  287. found += 1
  288. range_ref_String = "HIGH TARGET"
  289. tHigh = True
  290. RangeTarget = High_Target
  291. Target = M_Price
  292. range_identifier = 'High'
  293. found_Price = HLCC
  294. range_identifier_all = 'All'
  295. thList = ['HIGH TARGET', High_Target, highfilled]
  296. filled = False
  297. ht_filled = False
  298. hr_filled = False
  299. highs_found += 1
  300. rFound = True
  301. HighRangeFlow += Money_Flow
  302. elif M_Price<= Low_Range:
  303. found += 1
  304. range_ref_String = "LOW TARGET"
  305. tLow = True
  306. RangeTarget = Low_Target
  307. Target = M_Price
  308. range_identifier = 'Low'
  309. range_identifier_all = 'All'
  310. found_Price = HLCC
  311. tlList = ['LOW TARGET', Low_Target, lowfilled]
  312. filled = False
  313. lt_filled = False
  314. lr_filled = False
  315. lows_found += 1
  316. rFound = True
  317. LowRangeFlow += Money_Flow
  318.  
  319. if lows_found > 0:
  320. AvgLowRangeFlow = LowRangeFlow / lows_found
  321. if highs_found > 0:
  322. AvgHighRangeFlow = HighRangeFlow / highs_found
  323.  
  324.  
  325. if printRanges == range_identifier and range_identifier == range_identifier_low:
  326. Low_Range_Reference = [Date, military_time, range_ref_String, Target_String, end_String]
  327. Low_Range_Found = {'\nData Found':Low_Range_Reference, 'Watch for: $':lows, 'Potential Resistance: ':highs}
  328. Low_Range = Low_Range_Found
  329. for k, v in dict.items(Low_Range):
  330. print(Fore.RED, k, v)
  331.  
  332. if printRanges == range_identifier and range_identifier == range_identifier_high:
  333. High_Range_Reference = [Date, military_time, range_ref_String, end_String]
  334. High_Range_Found = {'\nData Found': High_Range_Reference, 'Watch for: $':highs, 'Potential Support: ':lows}
  335. High_Range = High_Range_Found
  336. for k, v in dict.items(High_Range):
  337. print(Fore.CYAN, k, v)
  338.  
  339. elif printRanges == range_identifier_all:
  340. if range_ref_String == 'LOW TARGET' or range_ref_String == 'HIGH TARGET':
  341. money_string = '$'
  342. Target_String = '$' + str(Target)
  343. Close_Price_String = money_string+str(Close_Price)
  344. Range_Reference = [Date, military_time, Close_Price_String, range_ref_String, Target_String]
  345. Low_Ranges = [LRS, LRT]
  346. High_Ranges = [HRS, HRT]
  347. Range_Found = {'<-- Reference':Range_Reference, 'Low Ranges':Low_Ranges, 'High Ranges':High_Ranges, 'REF#':ref_Num}
  348. Range_List[ref_Num] = Range_Found
  349. text = colored(str(found)+' '+str(Range_Found), 'cyan', 'on_grey', attrs=['reverse'])
  350. cprint(text)
  351.  
  352.  
  353. '''if Range_Clause == True:
  354. if range_ref_String == "HIGH TARGET" and Money_Flow < 300000000:
  355. print("MARKET MAKER HIGH TARGET")
  356. if range_ref_String == "LOW TARGET" and Money_Flow > 300000000:
  357. print("MARKET MAKER LOW TARGET")'''
  358.  
  359. else:
  360. Range_Clause = False
  361. tHigh = False
  362. tLow = False
  363. rFound = False
  364.  
  365.  
  366.  
  367.  
  368. if menu_ans == '1' and Liquidity_Data == 'y':
  369.  
  370.  
  371. avg_HL_Range = sum_HL_Range / ref_Num
  372. avg_OC_Range = sum_OC_Range / ref_Num
  373. avg_Liq_change = sum_Liq / ref_Num
  374.  
  375.  
  376.  
  377.  
  378. if Money_Flow > 0:
  379. MIV_Index = round(100 * (f_Vol / prevVol) - 100 * ((Money_Flow * HLCC) / (prevFlow * prevPrice)), 3)
  380. runningValueIndex = round(MIV_Index + prevIndexValue, 3)
  381. prevPrice = Close_Price
  382. prevFlow = Money_Flow
  383. prevVol = f_Vol
  384. prevIndexValue = MIV_Index
  385. MIV_Index_String = str(MIV_Index)
  386.  
  387. liq_flowPrice = abs(Liq_change / Money_Flow)*1000000
  388. runningValueIndex_String = str(runningValueIndex)
  389. MIV_Index_String = str(round(MIV_Index, 2))
  390.  
  391.  
  392.  
  393.  
  394. if abs(MIV_Index) >= .25 and ref_Num > 1:
  395. MIV_Spike += abs(MIV_Index)
  396. MIV_Spike_Count += 1
  397. MIV_Spike_List.append(abs(MIV_Index))
  398. Avg_MIV_Spike = round(MIV_Spike / MIV_Spike_Count, 3)
  399. if abs(MIV_Index) >= .25 and ref_Num > 1:
  400. Avg_MIV_Spike_String = str(Avg_MIV_Spike)
  401. if MIV_Index > 0:
  402. MIV_Index_String = str(round(MIV_Index, 2))
  403. 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+Style.BRIGHT+'Avg Spike: '+Style.RESET_ALL+Fore.BLACK+Back.RED+'[+',Avg_MIV_Spike,'%]'+Style.RESET_ALL+Fore.WHITE+'Volume:'+'{:,.2f}'.format(f_Vol)+Style.RESET_ALL)
  404.  
  405. elif MIV_Index < 0:
  406. MIV_Index_String = str(round(MIV_Index, 2))
  407. print(Fore.BLACK+Back.CYAN+Style.BRIGHT+'MIV_Index: '+Style.RESET_ALL+Fore.BLACK+Back.CYAN+'['+MIV_Index_String+'%]'+Style.RESET_ALL+Fore.BLACK+Back.CYAN+Style.BRIGHT+'Avg Spike: '+Style.RESET_ALL+Fore.BLACK+Back.CYAN+'[',Avg_MIV_Spike,'%]'+Style.RESET_ALL+Fore.WHITE+'Volume:'+'{:,.2f}'.format(f_Vol)+Style.RESET_ALL)
  408.  
  409.  
  410. if Close_Price >= Open_Price and Liq_change > 0:
  411. Price_Tick = 1
  412. Liq_Tick = 1
  413. BuyVolume += f_Vol
  414. BuyPower += Liq_change
  415. SellPower += Liq_change * -1
  416. if Liquidity < 0:
  417. ShortPower += Liq_change*-1
  418. PULQ = False
  419. elif Close_Price >= Open_Price and Liq_change < 0:
  420. Price_Tick = 0
  421. Liq_Tick = -1
  422. ShortVolume += f_Vol
  423. BuyVolume += Liq_change * -1
  424. ShortPower += Liq_change * -1
  425. PULQ = True
  426. elif Close_Price <= Open_Price and Liq_change > 0:
  427. Price_Tick = -1
  428. Liq_Tick = 0
  429. ShortPower += Liq_change
  430. BuyPower += Liq_change
  431. SellPower += Liq_change
  432.  
  433. PULQ = False
  434. elif Close_Price <= Open_Price and Liq_change < 0:
  435. Price_Tick = -1
  436. Liq_Tick = -1
  437. SellVolume += f_Vol
  438. SellPower += abs(Liq_change)
  439. BuyPower += Liq_change
  440. PULQ = False
  441. Tick = Liq_Tick + Price_Tick
  442. Strength += Tick
  443. percent_Strength = round(Strength / ref_Num, 4)
  444. new_Strength = round(100-(100*abs(percent_Strength- -.3153) / .8794), 2)
  445. SS = str(new_Strength)
  446. abs_Liq = abs(Liq_change)
  447. counter += 1
  448. if ref_Num < 10:
  449. AvgStrengthReference += new_Strength
  450. if ref_Num == 20:
  451. AvgStrengthReference = StrengthReference / ref_Num
  452. StrengthReference = AvgStrengthReference
  453. counter = 1
  454. if ref_Num >= 20:
  455. counter += 1
  456. AvgStrengthReference = AvgStrengthReference + new_Strength
  457.  
  458. if counter < 20 and counter >= 1:
  459. AvgStrengthReference = AvgStrengthReference / counter
  460. StrengthReference = (AvgStrengthReference + new_Strength) / counter
  461.  
  462. if counter == 20:
  463. counter = counter * 0
  464. AvgStrengthReference = AvgStrengthReference * 0 + StrengthReference
  465. StrengthReference = StrengthReference
  466.  
  467.  
  468.  
  469. if M_Price == lastMPrice:
  470. WarningString = '!!!'
  471. if OC_Range >= avg_HL_Range:
  472. if Liq_change > avg_Liq_change:
  473. if Close_Price > Open_Price:
  474. WarningString = Fore.CYAN+'[xxx]'+Style.RESET_ALL
  475. if Close_Price < Open_Price:
  476. WarningString = Fore.RED+'[xxx]'+Style.RESET_ALL
  477. else:
  478. WarningString = Fore.YELLOW+'[xxx]'
  479.  
  480. else:
  481. WarningString = ''
  482.  
  483. if PULQ == True and OC_Range <= avg_OC_Range *.3:
  484. if abs(Liq_change) < 500 and Liq_change < 0:
  485. if abs(Liq_change) < avg_Liq_change * .05:
  486. WarningString = '[*]'
  487. else:
  488. WarningString = ''
  489.  
  490.  
  491.  
  492.  
  493. OC_RangePct = round(OC_Range / avg_OC_Range * 100, 2)
  494. HL_RangePct = round(HL_Range / avg_HL_Range * 100, 2)
  495. OC_HL_RangePct = round(OC_Range / (HL_Range / avg_HL_Range) * 1000, 4)
  496. OCHL_RangePct = round(OC_Range / HL_Range * 100, 4)
  497.  
  498. if M_Price == lastMPrice and OC_Range < avg_OC_Range:
  499. if abs(Liq_change) > avg_Liq_change * .5 or abs(Liq_change) > 1000:
  500. if Liquidity > 0:
  501. if OC_HL_RangePct < 10:
  502. if Close_Price < M_Price and last < lastMPrice:
  503. Tick_String = Fore.BLUE+Style.BRIGHT+Back.WHITE+'BULLISH ACCUMULATION'+Style.RESET_ALL+WarningString+' OC / HL [%s] HL PCTile[%s] ' % (OCHL_RangePct, HL_RangePct)
  504. if Close_Price >= M_Price:
  505. if lastMPrice >= lastMPrice or Close_Price == last:
  506. Tick_String = Fore.YELLOW+Style.BRIGHT+'BEARISH INV SHIFT'+Style.RESET_ALL+WarningString+' OC / HL [%s] HL PCTile[%s] ' % (OCHL_RangePct, HL_RangePct)
  507.  
  508. elif OC_HL_RangePct > 30:
  509. if Liq_change > 0:
  510. Tick_String = Fore.YELLOW+Style.BRIGHT+Back.BLUE+'CURRENT SUPPORT'+Style.RESET_ALL+WarningString+' OC / HL [%s] HL PCTile[%s] ' % (OCHL_RangePct, HL_RangePct)
  511. elif Liq_change < 0:
  512. Tick_String = Fore.RED+Style.BRIGHT+Back.CYAN+'CURRENT RESISTANCE'+Style.RESET_ALL+WarningString+' OC / HL [%s] HL PCTile[%s] ' % (OCHL_RangePct, HL_RangePct)
  513.  
  514. if Liquidity < 0:
  515. Tick_String = Fore.RED+'SHORT COVERING'+Style.RESET_ALL+WarningString+' '
  516.  
  517. elif OC_HL_RangePct < 10:
  518. if Liq_change > 100:
  519. Tick_String = Style.BRIGHT+Fore.BLUE+Back.YELLOW+'BOTTOM FEEDERS'+Style.RESET_ALL+WarningString+' OC / HL [%s] HL PCTile[%s] ' % (OCHL_RangePct, HL_RangePct)
  520. if abs(Liq_change) < 100:
  521. if HL_RangePct < 50:
  522. Tick_String = Fore.YELLOW+Style.BRIGHT+Back.RED+'LARGE DISTRIBUTION'+Style.RESET_ALL+WarningString+' OC / HL [%s] HL PCTile[%s] ' % (OCHL_RangePct, HL_RangePct)
  523. if HL_RangePct > 50:
  524. Tick_String = Fore.BLUE+Style.BRIGHT+Back.CYAN+'MASSIVE ACCUMULATION'+Style.RESET_ALL+WarningString+' OC / HL [%s] HL PCTile[%s] ' % (OCHL_RangePct, HL_RangePct)
  525.  
  526. elif abs(Liq_change) < avg_Liq_change * .2 and abs(Liq_change) < 1000:
  527. if HL_RangePct >= 100 and OC_RangePct < 10:
  528. if OC_HL_RangePct > 50:
  529. if Close_Price == Last:
  530. Tick_String = Fore.RED+Style.BRIGHT+Back.YELLOW+'LARGE DISTRIBUTION'+Style.RESET_ALL+WarningString+' OC / HL [%s] HL PCTile[%s] ' % (OCHL_RangePct, HL_RangePct)
  531. elif HL_Range >= 100 and Close_Price > lastMPrice:
  532. Tick_String = Fore.BLUE+Style.BRIGHT+Back.WHITE+'LARGE ACCUMULATION'+Style.RESET_ALL+WarningString+' OC / HL [%s] HL PCTile[%s] ' % (OCHL_RangePct, HL_RangePct)
  533. elif HL_RangePct > 50 and OC_RangePct > 50:
  534. if Liquidity < 0:
  535. Tick_String = Fore.WHITE+Back.RED+'SELLERS IN CONTROL'+Style.RESET_ALL+WarningString+' OC / HL [%s] HL PCTile[%s] ' % (OCHL_RangePct, HL_RangePct)
  536. if Liquidity > 0:
  537. if Close_Price < lastMPrice:
  538. Tick_String = Fore.CYAN+Back.BLUE+'HIDDEN BUYERS'+Style.RESET_ALL+WarningString+' OC / HL [%s] HL PCTile[%s] ' % (OCHL_RangePct, HL_RangePct)
  539. if Close_Price > lastMPrice:
  540. Tick_String = Fore.BLUE+Back.WHITE+Style.DIM+'HIDDEN SELLERS'+Style.RESET_ALL+WarningString+' OC / HL [%s] HL PCTile[%s] ' % (OCHL_RangePct, HL_RangePct)
  541.  
  542. else:
  543. if Close_Price >= M_Price and last >= lastMPrice:
  544. Tick_String = Fore.RED+Back.WHITE+Style.BRIGHT+'BEARS RUN IT'+Style.RESET_ALL+WarningString+' OC / HL [%s] HL PCTile[%s] ' % (OCHL_RangePct, HL_RangePct)
  545. if Close_Price < M_Price and last < lastMPrice:
  546. Tick_String = Fore.CYAN+Back.BLUE+'BULLS RUN IT'+Style.RESET_ALL+WarningString+' OC / HL [%s] HL PCTile[%s] ' % (OCHL_RangePct, HL_RangePct)
  547.  
  548. else:
  549.  
  550. if Tick == 2:
  551. if abs_Liq >= avg_Liq_change*1.5:
  552. if Liquidity > 0:
  553. Tick_String = Fore.GREEN+Style.BRIGHT+'AGGRESSIVE BUYERS'+Style.RESET_ALL+WarningString+' '
  554.  
  555. else:
  556. Tick_String = Fore.GREEN+Back.RED+Style.BRIGHT+'BEARISH BUYING'+Style.RESET_ALL+WarningString+' '
  557.  
  558. elif abs_Liq >= avg_Liq_change:
  559. Tick_String = Fore.GREEN+Style.BRIGHT+'STRONG BUYERS'+Style.RESET_ALL+WarningString+' '
  560.  
  561. else:
  562. Tick_String = Fore.BLUE+Back.GREEN+'UPTICK'+Style.RESET_ALL+WarningString+' '
  563.  
  564. if Tick == -1 and Price_Tick == 0:
  565. if Liq_Tick == -1:
  566. if abs(Liq_change) < 300 and OC_Range <= avg_OC_Range *.3:
  567. if WarningString == '[*]':
  568. if new_Strength < 60:
  569. Tick_String = Fore.RED+Style.BRIGHT+Back.YELLOW+'<SELL ENTRY>'+Style.RESET_ALL+WarningString+' '
  570. if new_Strength > 60 or StrengthReference >= 65:
  571. Tick_String = Fore.BLUE+Style.BRIGHT+Back.YELLOW+'<BUY ENTRY>'+Style.RESET_ALL+WarningString+' '
  572.  
  573. # if WarningString == '':
  574. # Tick_String = Fore.BLUE+Style.BRIGHT+Back.YELLOW+'<BUY ENTRY>'+Style.RESET_ALL+WarningString+' '
  575. #
  576. elif WarningString == '':
  577. if new_Strength < 50:
  578. Tick_String = Fore.YELLOW+Style.BRIGHT+'BREAKDOWN'+Style.RESET_ALL+WarningString+' '
  579.  
  580. elif new_Strength < StrengthReference and StrengthReference < 65:
  581. Tick_String = Fore.YELLOW+Style.BRIGHT+'BREAKDOWN'+Style.RESET_ALL+WarningString+' '
  582.  
  583. elif new_Strength >= StrengthReference or StrengthReference >= 65:
  584. Tick_String = Fore.CYAN+Style.BRIGHT+'BREAKOUT'+Style.RESET_ALL+WarningString+' '
  585.  
  586. elif abs(Liq_change) < 300 and avg_Liq_change * .05:
  587. if WarningString == '[*]':
  588. if new_Strength > StrengthReference:
  589. Tick_String = Fore.WHITE+Style.BRIGHT+Back.BLUE+'<VOLATILITY COMING (UPSIDE)>'+Style.RESET_ALL+WarningString+' '
  590. if new_Strength < StrengthReference:
  591. Tick_String = Fore.WHITE+Style.BRIGHT+Back.RED+'<VOLATILITY COMING (DOWNSIDE)>'+Style.RESET_ALL+WarningString+' '
  592.  
  593. else:
  594. Tick_String = Fore.RED+Style.BRIGHT+Back.YELLOW+'<VOLATILITY COMING>'+Style.RESET_ALL+WarningString+' '
  595.  
  596.  
  597.  
  598. else:
  599. Tick_String = Fore.WHITE+'PRICE UP LIQ DOWN'+Style.RESET_ALL+WarningString+' '
  600.  
  601. if Tick == -2:
  602. if abs_Liq < avg_Liq_change:
  603. Tick_String = Fore.BLUE+'PROFIT TAKING'+Style.RESET_ALL+WarningString+' '
  604.  
  605. if abs_Liq > avg_Liq_change*.75:
  606. Tick_String = Fore.RED+Style.BRIGHT+'STRONG SELLERS'+Style.RESET_ALL+WarningString+' '
  607.  
  608. if Tick == -1 and Liq_Tick == 0:
  609. prevLiq = Liquidity - Liq_change
  610. if abs_Liq >= avg_Liq_change*.8 and prevLiq < 0:
  611. Tick_String = Fore.RED+Style.BRIGHT+'AGGRESSIVE COVERING'+Style.RESET_ALL+WarningString+' '
  612.  
  613. if OC_Range >= avg_HL_Range*.9 and abs_Liq < avg_Liq_change*.75:
  614. Tick_String = Fore.RED+Style.BRIGHT+'MM\'s BEARISH'+WarningString+' '
  615.  
  616. elif abs_Liq < avg_Liq_change*.25 and OC_Range < avg_HL_Range:
  617. Tick_String = Fore.YELLOW+'DIP BUYERS'+Style.RESET_ALL+WarningString+' '
  618.  
  619. else:
  620. Tick_String = Fore.CYAN+'PRICE DOWN LIQ UP'+Style.RESET_ALL+WarningString+' '
  621.  
  622.  
  623. Range_List[ref_Num] = Range_Found
  624. # else:
  625. # Tick_String = Fore.WHITE+'PRICE UP LIQ DOWN'+Style.RESET_ALL+WarningString+' '+Fore.WHITE+str(Strength)
  626.  
  627.  
  628. # if abs(Liq_change) <= avg_Liq_change:
  629. # Tick_String = Fore.RED+'SHORT RALLY'+Style.RESET_ALL+WarningString+' '+Fore.RED+str(Strength)
  630. # # else:
  631. # Tick_String = Fore.WHITE+'PRICE UP LIQ DOWN'+Style.RESET_ALL+WarningString+' '+Fore.WHITE+str(Strength)
  632.  
  633. # if Tick == -1 and Liq_Tick == 0:
  634. # if Liquidity < 0:
  635. # if abs(Liq_change) > avg_Liq_change*2:
  636. # Tick_String = Fore.RED+'MM\'s BEARISH'+Style.RESET_ALL+WarningString+' '+Fore.YELLOW+str(Strength)
  637. # else:
  638. # Tick_String = Fore.RED+'SHORT COVERING'+Style.RESET_ALL+WarningString+' '+Fore.YELLOW+Back.BLUE+Style.BRIGHT+str(Strength)
  639.  
  640. Range_List[ref_Num] = Range_Found
  641. else:
  642.  
  643. if Range_Clause == True:
  644. if range_ref_String == "HIGH TARGET" and Money_Flow < 300000000:
  645. if Liq_change > 1000000:
  646. print("MARKET MAKER HIGH TARGET")
  647. if range_ref_String == "LOW TARGET" and Money_Flow > 300000000:
  648. if Liq_change < 1000000:
  649. print("MARKET MAKER LOW TARGET")
  650.  
  651. if lr_filled == False:
  652. if filled == False:
  653. if range_ref_String == "LOW TARGET" and Low_Price <= Low_Range:
  654. filled_Price = Low_Price
  655. time.sleep(.5)
  656. print(Fore.WHITE + Back.RED + "LOW RANGE FILLED" + Style.RESET_ALL)
  657. time.sleep(1)
  658. lr_filled = True
  659. lt_filled = False
  660. lrf = 1
  661. low_Ranges_Filled += lrf
  662. if lt_filled == False and lr_filled == True:
  663. if Close_Price <= Low_Target:
  664. filled_target_price = Close_Price
  665. time.sleep(.5)
  666. print(Fore.RED + Back.YELLOW + 'LOW TARGET FILLED' + Style.RESET_ALL)
  667. time.sleep(1)
  668. lt_filled = True
  669. filled = True
  670. low_Targets_Filled += 1
  671. if hr_filled == False:
  672. if filled == False:
  673. if range_ref_String == "HIGH TARGET" and High_Price >= High_Range:
  674. filled_range_price = High_Price
  675. time.sleep(.5)
  676. print(Fore.CYAN + "HIGH RANGE FILLED" + Style.RESET_ALL)
  677. time.sleep(1)
  678. hr_filled = True
  679. ht_filled = False
  680. hrf = 1
  681. high_Ranges_Filled += hrf
  682. if ht_filled == False and hr_filled == True:
  683. if Close_Price >= High_Target:
  684. filled_target_price = High_Price
  685. print(Fore.CYAN + "HIGH TARGET FILLED")
  686. time.sleep(1)
  687. ht_filled = True
  688. filled = True
  689. high_Targets_Filled += 1
  690.  
  691.  
  692. if menu_ans == '4' or menu_ans == '1':
  693. if rFound == True:
  694. if tHigh == True:
  695. HRS = str(High_Range)
  696. HRT = str(High_Target)
  697. LRS = str(Low_Range)
  698. LRT = str(Low_Target)
  699. MIV_Index_String = str(MIV_Index)
  700.  
  701. 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+']'+Fore.WHITE+' '+MIV_Index_String+'%'+Style.RESET_ALL+Fore.CYAN+' Avg High Flow: $'+'{:20,.2f}'.format(AvgHighRangeFlow), 'MoneyFlow: $','{:20,.2f}'.format(Money_Flow)+Style.RESET_ALL+Fore.WHITE+'Volume: '+'{:20,.2f}'.format(f_Vol))
  702. time.sleep(2)
  703.  
  704.  
  705. else:
  706. tHigh = False
  707. else:
  708. rFound = False
  709. Close_Price = Close_Price
  710.  
  711. if rFound == True:
  712. if tLow == True:
  713. HRS = str(High_Range)
  714. HRT = str(High_Target)
  715. LRS = str(Low_Range)
  716. LRT = str(Low_Target)
  717. lowFlow = str(AvgLowRangeFlow)
  718. flow = str(Money_Flow)
  719. MIV_Index_String = str(MIV_Index)
  720.  
  721. Low_Prices = {'LOW RANGE: $': Low_Range, 'LOW TARGET: $': Low_Target} ##### May not need this line
  722. 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+']'+Fore.WHITE+' '+MIV_Index_String+'%'+Style.RESET_ALL+Fore.RED+' Avg Low Flow: $','{:20,.2f}'.format(AvgLowRangeFlow),'MoneyFlow: $','{:20,.2f}'.format(Money_Flow)+Style.RESET_ALL+Fore.WHITE+'Volume: '+'{:20,.2f}'.format(f_Vol))
  723. time.sleep(2)
  724.  
  725. else:
  726. tLow = False
  727. else:
  728. rFound = False
  729.  
  730.  
  731. if Liq_change < -1000000:
  732. print(Fore.YELLOW + '[' + Date + ']', military_time,PCT_Range_Str,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, M_Price)
  733. time.sleep(1)
  734. if abs(Liq_change) > 500000:
  735. time.sleep(.005)
  736. print(Fore.CYAN + '[' + Date + ']', military_time,PCT_Range_Str,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 + ' ' + Fore.WHITE+SS+'%'+Style.RESET_ALL, M_Price)
  737. elif Liquidity > 0:
  738. if Liq_change > 0:
  739. time.sleep(.005)
  740. print(Fore.YELLOW + '[' + Date + ']', military_time,PCT_Range_Str,
  741. Fore.GREEN + 'Current Liquidity:' + '{:20,.2f}'.format(
  742. Liquidity) + Fore.GREEN + ' Liq Change: ' + '{:20,.2f}'.format(Liq_change) + ' ' + Fore.YELLOW + Back.BLUE,'Last Price [$' + str(Close_Price) + '] ' + Style.RESET_ALL+ Tick_String + Style.RESET_ALL+Fore.WHITE+' '+SS+'%'+Style.RESET_ALL, M_Price)
  743. if Liq_change < 0:
  744. time.sleep(.005)
  745. print(Fore.YELLOW + '[' + Date + ']', military_time,PCT_Range_Str,
  746. Fore.GREEN + 'Current Liquidity:' + '{:20,.2f}'.format(
  747. 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) + '] ' + Style.RESET_ALL+ Tick_String + Style.RESET_ALL+Fore.WHITE+' '+SS+'%'+Style.RESET_ALL, M_Price)
  748. elif Liq_change > 0:
  749. time.sleep(.005)
  750. print(Fore.YELLOW + '[' + Date + ']', military_time,PCT_Range_Str,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) + '] ' +Style.RESET_ALL + Tick_String + Style.RESET_ALL + ' ' + Fore.WHITE+SS+'%'+Style.RESET_ALL, M_Price)
  751. elif Liq_change < 0:
  752. time.sleep(.005)
  753. print(Fore.YELLOW + '[' + Date + ']', military_time,PCT_Range_Str,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) + '] ' +Style.RESET_ALL + Tick_String+ Style.RESET_ALL + ' ' + Fore.WHITE+SS+'%'+Style.RESET_ALL, M_Price)
  754.  
  755.  
  756.  
  757.  
  758. '''if runningValueIndex > 0 and MIV_Index > 0:
  759. print(' '+Fore.BLACK+Back.WHITE+'MIV_Index:+'+MIV_Index_String+'% '+Style.RESET_ALL+' '+Fore.BLACK+Back.GREEN+'Running Value:+'+runningValueIndex_String+'%'+Style.RESET_ALL)
  760. if MIV_Index < 0 and runningValueIndex > 0:
  761. print(' '+Fore.RED+Back.YELLOW+'MIV_Index:'+MIV_Index_String+'% '+Style.RESET_ALL+' '+Fore.BLACK+Back.GREEN+'Running Value:+'+runningValueIndex_String+'%'+Style.RESET_ALL)
  762. if MIV_Index > 0 and runningValueIndex < 0:
  763. print(' '+Fore.WHITE+'MIV_Index:+'+MIV_Index_String+'% '+Style.RESET_ALL+' '+Fore.RED+Back.YELLOW+'Running Value:'+runningValueIndex_String+'%'+Style.RESET_ALL)
  764. if MIV_Index < 0 and runningValueIndex < 0:
  765. print(' '+Fore.RED+'MIV_Index:'+MIV_Index_String+'% '+Style.RESET_ALL+' '+Fore.RED+'Running Value:'+runningValueIndex_String+'%'+Style.RESET_ALL)'''
  766.  
  767. '''else:
  768. runningValueIndex += MIV_Index
  769. runningValueIndex_String = str(round(runningValueIndex, 2))
  770. if runningValueIndex > 0:
  771. print(Fore.GREEN+'MIV_Index: '+runningValueIndex_String, '%')
  772. else:
  773. runningValueIndex_String = str(round(runningValueIndex, 2))
  774. print(Fore.RED+'MIV_Index: '+runningValueIndex_String, '%')'''
  775.  
  776.  
  777. if menu_ans == '3':
  778. printRangeFile = input('Would you like to see other found ranges?: [y/n]')
  779. if printRangeFile == 'y':
  780. file_Choose = input('Which file would you like to use? [1 = 1 min Ranges] [2 = 2 min ranges] [5 = 5 min ranges]: ')
  781. if file_Choose == '1':
  782. filename = ('/Users/King/iFiles/iRanges/SPY1.csv')
  783. if file_Choose == '2':
  784. filename = ('/Users/King/iFiles/iRanges/SPY2.csv')
  785. if file_Choose == '5':
  786. filename = ('/Users/King/iFiles/iRanges/SPY5.csv')
  787. with open(filename, 'r') as csv_file:
  788. csv_reader = csv.reader(csv_file)
  789. for row in csv_reader:
  790. Date = row[0]
  791. Time = row[1]
  792. range_ref_String = row[2]
  793. Close_Price = float(row[3])
  794. M_Price = float(row[4])
  795. TargetPrice = row[5]
  796. Money_Flow = float(row[6])
  797. f_Vol = float(row[7])
  798. OppRange = row[8]
  799. OppTarget = row[9]
  800. Liquidity = float(row[10])
  801. Liq_change = float(row[11])
  802. LFP = float(row[12])
  803. MIVI = float(row[13])
  804. ref_Num = int(row[15])
  805. CandleDuration = str(row[14])
  806. list = [Date, Time, range_ref_String]
  807. Targets = [M_Price, TargetPrice]
  808. MIV_Index = str(MIVI) + str('%')
  809. liq_flowPrice = str(round(LFP, 3))
  810. oppositePrices = [OppRange, OppTarget]
  811. Liq_change_String = str('$' + '{:20,.2f}'.format(Liq_change))
  812. listlist = []
  813. dict = {'': list, 'Targets: ':Targets, 'Found price: ':Close_Price,'Opposite Ranges/Targets':oppositePrices}
  814. range_info = {'MIV Index:': MIV_Index, 'Liq Change:':Liq_change_String,'Candle Duration:':CandleDuration, 'REF#':ref_Num}
  815. if MIVI < 0 and Liq_change > 0:
  816. infotext = colored(str(range_info), 'grey', 'on_cyan', attrs=['reverse', 'underline'])
  817. else:
  818. infotext = colored(str(range_info), 'grey', 'on_red', attrs=['reverse', 'underline'])
  819. for k, v in dict.items():
  820. time.sleep(.001)
  821. print(Fore.YELLOW, k, v)
  822. cprint(infotext)
  823. print('\n')
  824. break
  825.  
  826.  
  827.  
  828.  
  829. print('MIV Spike Count: ',MIV_Spike_Count)
  830. print('Avg MIV Spike',Avg_MIV_Spike,'%')
  831. print(Fore.CYAN + 'REF#:', ref_Num)
  832. time.sleep(.25)
  833. print(Fore.WHITE + Time)
  834. time.sleep(.25)
  835. print("Last:", "$" + str(Close_Price))
  836. time.sleep(.25)
  837. print("HLCC:", "$" + str(HLCC))
  838. time.sleep(.25)
  839. if HLCC >= M_Price:
  840. print(Fore.CYAN+"Money Price: "+" $" + str(round(M_Price, 2))+Style.RESET_ALL)
  841. time.sleep(.25)
  842. print(Fore.CYAN+'Price Diff: ' + '$' + str(Diff)+Style.RESET_ALL)
  843.  
  844. if HLCC < M_Price:
  845. print(Fore.RED+"Money Price: "+Fore.RED+" $" + str(round(M_Price, 2))+Style.RESET_ALL)
  846. time.sleep(.25)
  847. print(Fore.RED+'Price Diff: ' + '$' + str(Diff)+Style.RESET_ALL)
  848.  
  849.  
  850. time.sleep(.25)
  851. if f_Vol > 1000000:
  852. print(Fore.YELLOW + 'Volume:' + '{:20,.2f}'.format(f_Vol))
  853. else:
  854. print(Fore.WHITE + 'Volume:' + '{:20,.2f}'.format(f_Vol))
  855. time.sleep(.25)
  856. if Money_Flow > 350000000:
  857. print(Fore.YELLOW + '$Flow:' + '{:20,.2f}'.format(Money_Flow))
  858. else:
  859. print(Fore.WHITE + '$Flow:' + '{:20,.2f}'.format(Money_Flow))
  860. time.sleep(.25)
  861. if Liq_change < 0:
  862. print(Fore.RED + 'Liq Change:', '{:20,.2f}'.format(Liq_change), Style.RESET_ALL)
  863. else:
  864. print(Fore.CYAN + 'Liq Change:', '{:20,.2f}'.format(Liq_change))
  865. time.sleep(.25)
  866. if Liquidity < 0:
  867. print(Fore.RED + 'Current Liquidity:' + '{:20,.2f}'.format(Liquidity), Style.RESET_ALL)
  868. else:
  869. print(Fore.CYAN + 'Current Liquidity:' + '{:20,.2f}'.format(Liquidity), Style.RESET_ALL)
  870. time.sleep(.25)
  871. print('Avg MIV Spike: ',Avg_MIV_Spike,'%')
  872. if percent_Strength >= -.68:
  873. percent_Strength_String = Fore.GREEN+'Current Strength: '+str(percent_Strength)+'%'
  874. print(percent_Strength_String)
  875. if percent_Strength <-.68:
  876. percent_Strength_String = Fore.RED+'Current Strength: '+str(percent_Strength)+'%'
  877. print(percent_Strength_String)
  878.  
  879. new_Strength = 100-(100*abs(percent_Strength- -.3153) / .8794)
  880. if new_Strength > 70:
  881. new_Strength_String = Fore.CYAN+'Bullishness Percentile: '+str(round(new_Strength, 2))+'%'+Style.RESET_ALL
  882. else:
  883. new_Strength_String = Fore.RED+'Bullishness Percentile: '+str(round(new_Strength, 2))+'%'+Style.RESET_ALL
  884. print(new_Strength_String)
  885. pctShortBuying = round(BuyPower / ShortPower, 4)*100
  886. pctNetSelling = round(SellPower / ShortPower, 4)*100
  887. pctNetBuying = round(BuyPower / SellPower, 4)*100
  888. pctNetBuyingStr = str(pctNetBuying)
  889. pctNetSellingStr = str(pctNetSelling)
  890. pctShortBuyingStr = str(pctShortBuying)
  891. SellBuy = round(SellPower / BuyPower, 4)*100
  892. print('Buy Power', '{:5,.2f}'.format(BuyPower), 'Short Power:','{:5,.2f}'.format(ShortPower))
  893. print('Buy Power as % of Short Selling: ['+pctShortBuyingStr+'%]')
  894. print('Sell Power as % of Short Selling: ['+pctNetSellingStr+'%]')
  895. BullBearRatio = round(float(pctShortBuying / pctNetSelling), 4)
  896. print('SellBuy: ',SellBuy)
  897. print('Bull Bear Ratio: ',BullBearRatio)
  898.  
  899. if lows_found >= 1 or highs_found >= 1:
  900. print('\nLow Ranges/Targets Found|Filled:',lows_found, '| ', low_Ranges_Filled)
  901. print('\nHigh Ranges/Targets Found|Filled: ',highs_found, '| ', high_Ranges_Filled)
  902. print('Total found: ',found)
  903.  
  904. '''if found >0:
  905. tList = tList
  906. if tList[1] == 'High':
  907. print(Fore.GREEN+'LAST RANGE FOUND: [$' + str(Low_Range)+']','[$' + str(High_Range)+']', ' [' + range_ref_String + ': $' + str(Target)+']'+Style.RESET_ALL)
  908. print(Fore.GREEN+'POTENTIAL TARGETS: [$' + str(Low_Target)+']', '[$' + str(High_Target)+']'+Style.RESET_ALL)
  909. print(Fore.GREEN+'Found price: [$' + found_price + ']', 'Target implies a move of [' + implied_move + '%]'+'from current price ['+str(Close_Price)+']'+Style.RESET_ALL)
  910. else:
  911. tList = tList
  912. if tList[1] == 'Low':
  913. print(Fore.RED+'LAST RANGE FOUND: [$' + str(Low_Range)+']','$' + str(High_Range) + ' [' + range_ref_String + ': $' + str(Target)+Style.RESET_ALL)
  914. print(Fore.RED+'POTENTIAL TARGETS: [$' + str(Low_Target)+']', '$' + str(High_Target)+Style.RESET_ALL)
  915. print(Fore.RED+'Found price: [$' + (found_price) + ']', 'Target implies a move of [' + implied_move + '%]' + 'from current price [' + str(Close_Price) + ']'+Style.RESET_ALL)'''
  916.  
  917. '''input = input('Would you like to see other found ranges?: [y/n]')
  918. if input == 'y':
  919. with open('/Users/King/Desktop/RangeTargets.csv' 'r') as csv_file:
  920. csv_reader = csv.reader(csv_file)
  921. for row in csv_file:
  922. row[0] = Date
  923. row[1] = Time
  924. row[2] = range_ref_String
  925. row[3] = Close_Price
  926. row[4] = M_Price
  927. row[5] = TargetPrice
  928. print('\nLow Ranges/Targets Found|Filled: ', lows_found, '| ', low_Ranges_Filled, str(round(low_range_Accuracy, 2)), '%')
  929. low_range_Accuracy = low_Ranges_Filled / lows_found
  930.  
  931. row[6] = Money_Flow
  932. row[7] = f_Vol
  933. row[8] = OppRange
  934. row[9] = OppTarget'''
  935.  
  936. '''if abs(Liq_change) > 500000:
  937. time.sleep(.005)
  938. 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)
  939. else if Liquidity > 0:
  940. if Liq_change > 0:
  941. time.sleep(.005)
  942. 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)
  943. if Liq_change < 0:
  944. time.sleep(.005)
  945. 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)
  946. else if Liq_change > 0:
  947. time.sleep(.005)
  948. 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)
  949. else if Liq_change < 0:
  950. time.sleep(.005)
  951. 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)'''
  952.  
  953. '''if menu_ans == '1' and Liquidity_Data == 'list':
  954. print(Fore.CYAN + 'REF#:', ref_Num)
  955. time.sleep(.05)
  956. print(Fore.WHITE + Time)
  957. time.sleep(.05)
  958. print("Last:", "$" + str(Close_Price))
  959. time.sleep(.05)
  960. print("HLCC:", "$" + str(HLCC))
  961. time.sleep(.05)
  962. print("Money Price: ", "$" + str(round(M_Price, 2)))
  963. time.sleep(.05)
  964. print('Price Diff: ' + '$' + str(Diff))
  965. time.sleep(.05)
  966. if f_Vol > 1000000:
  967. print(Fore.YELLOW + 'Volume:' + '{:20,.2f}'.format(f_Vol))
  968. else:
  969. print(Fore.WHITE + 'Volume:' + '{:20,.2f}'.format(f_Vol))
  970. time.sleep(.05)
  971. if Money_Flow > 350000000:
  972. print(Fore.YELLOW + '$Flow:' + '{:20,.2f}'.format(Money_Flow))
  973. else:
  974. print(Fore.WHITE + '$Flow:' + '{:20,.2f}'.format(Money_Flow))
  975. time.sleep(.05)
  976. if Liq_change < 0:
  977. print(Fore.RED + 'Liq Change:', '{:20,.2f}'.format(Liq_change), Style.RESET_ALL)
  978. else:
  979. print(Fore.CYAN + 'Liq Change:', '{:20,.2f}'.format(Liq_change))
  980. time.sleep(.05)
  981. if Liquidity < 0:
  982. print(Fore.RED + 'Current Liquidity:' + '{:20,.2f}'.format(Liquidity), Style.RESET_ALL)
  983. else:
  984. print(Fore.CYAN + 'Current Liquidity:' + '{:20,.2f}'.format(Liquidity), Style.RESET_ALL)
  985. time.sleep(.1)
  986. if NoStop == True:
  987. with open('/Users/King/Desktop/SPY_RangeTargets/NoStop.csv', 'r') as csv_file:
  988. csv_reader = csv.reader(csv_file)
  989. for row in csv_reader:
  990. Date = row[0]
  991. Time = row[1]
  992. range_ref_String = row[2]
  993. Close_Price = float(row[3])
  994. M_Price = float(row[4])
  995. TargetPrice = row[5]
  996. Money_Flow = float(row[6])
  997. f_Vol = float(row[7])
  998. OppRange = row[8]
  999. OppTarget = row[9]
  1000. Liquidity = float(row[10])
  1001. Liq_change = float(row[11])
  1002. LFP = round(float(row[12]), 3)
  1003. MIVI = float(row[13])
  1004. ref_Num = int(row[14])
  1005. list = [Date, Time, range_ref_String]
  1006. Targets = [M_Price, TargetPrice]
  1007. MIV_Index = str(MIVI)+str('%')
  1008. liq_flowPrice = str(round(LFP, 3))
  1009. oppositePrices = [OppRange, OppTarget]
  1010. Liq_change_String = str('$'+'{:20,.2f}'.format(Liq_change))
  1011. listlist = [MIV_Index, Liq_change, ref_Num]
  1012. dict = {'':list, 'Targets: ':Targets, 'Found price: ':Close_Price, 'Opposite Ranges/Targets':oppositePrices}
  1013. range_info = {'MIV Index: ':MIV_Index, ' Liq Change:':Liq_change_String, 'REF#':ref_Num}
  1014. if MIVI < 0 and Liq_change > 0:
  1015. infotext = colored(str(range_info), 'grey', 'on_cyan', attrs=['reverse', 'underline'])
  1016. else:
  1017. infotext = colored(str(range_info), 'grey', 'on_white', attrs=['reverse', 'underline'])
  1018. for k,v in dict.items():
  1019. time.sleep(.001)
  1020. print(Fore.YELLOW, k,v)
  1021.  
  1022. cprint(infotext)
  1023. print('\n')'''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement