Advertisement
ImDerekD

ScratchCopy.py

Jan 4th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.76 KB | None | 0 0
  1. #!/usr/bin/bash python
  2.  
  3. ### 01_04 (PM)
  4. ### Fixed percent_Strength indicator at bottom (doesn't print if menu_ans == '1') - Still unresolved
  5. ### All files now in iFiles dir
  6. ### iSpy.csv will be SPY1 (SPY2 & SPY3 Start Oct 8th)
  7. ### Will soon update more menu options to provide a 'go back' type variable
  8. ### Will use part of eric.py to define which files I want to manipulate
  9.  
  10. import csv
  11. import datetime
  12. from datetime import datetime
  13. from colorama import Back, Fore, Style
  14. import sys
  15. from termcolor import colored, cprint
  16. from colorama import init
  17. import numbers
  18. import time
  19. import itertools
  20. from itertools import zip_longest
  21. from time import sleep
  22. with open('/Users/King/iFiles/SPY1.csv', 'r') as csv_file:
  23. csv_reader = csv.reader(csv_file)
  24. header = next(csv_reader)
  25.  
  26.  
  27. ref = [] # Start off w/ empty list
  28. ref_Num = int(0) # First to go in list = ref # (390 cells in 1 day)(using ref+=1 for each row)
  29. data = [] # Not sure but I could rearrange for liquidity?
  30. Liquidity = float()
  31. found = int(0)
  32. Range = []
  33. Target = []
  34. filled = bool
  35. filled_Price = float()
  36. Range_List = {}
  37. Low_Range_Found = {}
  38. High_Range_Found = {}
  39. ht_filled = bool
  40. hr_filled = bool
  41. lr_filled = bool
  42. lt_filled = bool
  43. lows_found = int()
  44. highs_found = int()
  45. Range_Found = {}
  46. range_ref_String = ('')
  47. dTime = []
  48. printRanges = str()
  49. range_identifier_low = 'Low'
  50. range_identifier_high = 'High'
  51. range_identifier_all = 'All'
  52. All_Range_References = []
  53. All_Referenced_Prices = []
  54. 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')
  55. if menu_ans == '1':
  56. Liquidity_Data = input('Would you like to print liquidity data? [y/n]: ')
  57. if menu_ans == '2':
  58. printRanges = input('Which ranges would you like to see?: [High/Low/All]\n')
  59. if menu_ans == '4':
  60. NoStop = True
  61. CandleDur = input('Candle Duration: ')
  62. else:
  63. NoStop = False
  64. if menu_ans == '3':
  65. option3 = True
  66. range_identifier = ''
  67. new_range = bool
  68. t = bool
  69. tLow = bool
  70. tHigh = bool
  71. Target = float()
  72. Range_Dict = {}
  73. TickString = str()
  74. Tick_String = ''
  75. Strength = int()
  76. StartTraceback = {}
  77. day_Count = int()
  78. tList = []
  79. last = float()
  80. LT = float()
  81. HT = float()
  82. last = float()
  83. TrendStrength = ''
  84. Previous = []
  85. allfoundallfilled = {}
  86. lowfilled = float()
  87. highfilled = float()
  88. rangefilled = bool
  89. low_Ranges_Filled = int()
  90. high_Ranges_Filled = int()
  91. high_Targets_Filled = int()
  92. low_Targets_Filled = int()
  93. prevVol = float(1)
  94. prevFlow = float(1)
  95. prevIndexValue = float(1)
  96. prevPrice = float(1)
  97. Status = str('')
  98. RangeTarget = float()
  99. rFound = bool
  100. for row in csv_reader:
  101. range_ref_String = ''
  102. LRS = '$'
  103. LRT = '$'
  104. HRS = '$'
  105. HRT = '$'
  106. found_Price_String = '$'
  107. end_String = 'Price while found: $'
  108. # row = [Time, Open, Close, High, Low, realVol, Money_Flow]
  109. ref_Num += 1 # Starting at 0
  110. dTime = str(datetime.strptime(row[0], '%a %b %d %H:%M'))
  111. Time = dTime[-14:]
  112. Open_Price = float(row[1]) # Price Data Dictionary
  113. Close_Price = float(row[2]) # Price Data Dictionary
  114. High_Price = float(row[3]) # Price Data Dictionary
  115. Low_Price = float(row[4]) # Price Data Dictionary
  116. Money_Flow = float(row[6]) # Price Data Dictionary
  117. Vol = row[5] # Price Data Dictionary
  118. f_Vol = float(Vol[:-1]) # Price Data Dictionary
  119. m_Vol = str(Vol[-1:]) # Price Data Dictionary
  120. if m_Vol == "K": # Price Data Dictionary
  121. f_Vol = f_Vol * 1000 # Price Data Dictionary
  122. if m_Vol == "M": # Price Data Dictionary
  123. f_Vol = f_Vol * 1000000
  124. if m_Vol != "K" and m_Vol != "M":
  125. f_Vol = float(row[5]) # Price Data Dictionary
  126. if f_Vol < 1:
  127. M_Price = HLCC
  128. else:
  129. M_Price = round(float(Money_Flow) / f_Vol, 2)
  130. HLCC = float(High_Price + Low_Price + Close_Price + Close_Price)/4 # Price Data Dictionary & RangeReference Dictionary # Price Data Dictionary & RangeReference Dictionary
  131. Diff = round(HLCC - M_Price, 2) # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  132. MMM = float(f_Vol * HLCC) # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  133. Liq_change = float(Money_Flow - MMM) # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  134. Liquidity += Liq_change # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  135. Date = str(Time[:5]) # Important
  136. military_time = str(Time[-8:])
  137. criteria = abs(.003*HLCC)
  138. Liq_Tick = int()
  139. Price_Tick = int()
  140. tREF = int()
  141. rFound = False
  142. percent_Strength = Strength / ref_Num
  143. allData = [ref_Num,Date, military_time, High_Price,Low_Price,Close_Price, HLCC, M_Price, f_Vol, Money_Flow,MMM, Liquidity,Liq_change]
  144. Data_Dict = {'REF#':[ref_Num],'Date':[Date],'Time':[military_time], 'Close_Price':[Close_Price], 'M_Price':[M_Price], 'Volume':[f_Vol]}
  145. '''USING THIS DATA
  146. [0]REFERENCE NUMBER
  147. [1]DATE
  148. [2]MILITARY_TIME
  149. [3]HIGH_PRICE
  150. [4]LOW_PRICE
  151. [5]CLOSE_PRICE
  152. [6]HLCC
  153. [7]M_Price
  154. [8]F_VOL
  155. [9]MONEY_FLOW
  156. [10]MARKETMAKERMOVE 'MMM'
  157. [11]LIQUIDITY
  158. [12]LIQ_CHANGE
  159. '''
  160. if abs(allData[7]-allData[6]) >= criteria:
  161. diff = abs(M_Price - Close_Price)
  162. Range_Clause = True
  163. range_identifier_all = 'All'
  164. else:
  165. Range_Clause = False
  166. if Range_Clause == True:
  167. t_price = M_Price
  168. found_Price = HLCC
  169. Low_Range = round(HLCC - abs(float(M_Price - HLCC)), 2)
  170. High_Range = round(HLCC + abs(float(M_Price - HLCC)), 2)
  171. Low_Target = round(Low_Range - abs(float(M_Price - HLCC)), 2)
  172. High_Target = round(High_Range + abs(float(M_Price - HLCC)), 2)
  173. RT_Reference1 = [Low_Range, High_Range, Low_Target, High_Target]
  174. LRS = '$' + str(Low_Range)
  175. LRT = '$' + str(Low_Target)
  176. HRS = '$' + str(High_Range)
  177. HRT = '$' + str(High_Target)
  178. found_Price_String = '$' + str(found_Price)
  179. RT_Reference = [LRS, LRT, HRS, HRT]
  180. lows = [LRS, LRT]
  181. highs = [HRS, HRT]
  182. range_ref_String = range_ref_String
  183. target_String = range_ref_String + ': $'
  184. end_String = 'Price while found: $' + str(Close_Price)
  185. Target_String = '$' + str(Target)
  186. if M_Price >= found_Price+diff:
  187. found += 1
  188. range_ref_String = "HIGH TARGET"
  189. tHigh = True
  190. RangeTarget = High_Target
  191. Target = M_Price
  192. range_identifier = 'High'
  193. found_Price = HLCC
  194. range_identifier_all = 'All'
  195. thList = ['HIGH TARGET', High_Target, highfilled]
  196. filled = False
  197. ht_filled = False
  198. hr_filled = False
  199. highs_found += 1
  200. rFound = True
  201. elif M_Price<= found_Price-diff:
  202. found += 1
  203. range_ref_String = "LOW TARGET"
  204. tLow = True
  205. RangeTarget = Low_Target
  206. Target = M_Price
  207. range_identifier = 'Low'
  208. range_identifier_all = 'All'
  209. found_Price = HLCC
  210. tlList = ['LOW TARGET', Low_Target, lowfilled]
  211. filled = False
  212. lt_filled = False
  213. lr_filled = False
  214. lows_found += 1
  215. rFound = True
  216.  
  217.  
  218. if printRanges == range_identifier and range_identifier == range_identifier_low:
  219. Low_Range_Reference = [Date, military_time, range_ref_String, Target_String, end_String]
  220. Low_Range_Found = {'\nData Found':Low_Range_Reference, 'Watch for: $':lows, 'Potential Resistance: ':highs}
  221. Low_Range = Low_Range_Found
  222. for k, v in dict.items(Low_Range):
  223. print(Fore.RED, k, v)
  224.  
  225. if printRanges == range_identifier and range_identifier == range_identifier_high:
  226. High_Range_Reference = [Date, military_time, range_ref_String, end_String]
  227. High_Range_Found = {'\nData Found': High_Range_Reference, 'Watch for: $':highs, 'Potential Support: ':lows}
  228. High_Range = High_Range_Found
  229. for k, v in dict.items(High_Range):
  230. print(Fore.CYAN, k, v)
  231.  
  232. elif printRanges == range_identifier_all:
  233. if range_ref_String == 'LOW TARGET' or range_ref_String == 'HIGH TARGET':
  234. money_string = '$'
  235. Target_String = '$' + str(Target)
  236. Close_Price_String = money_string+str(Close_Price)
  237. Range_Reference = [Date, military_time, Close_Price_String, range_ref_String, Target_String]
  238. Low_Ranges = [LRS, LRT]
  239. High_Ranges = [HRS, HRT]
  240. Range_Found = {'<-- Reference':Range_Reference, 'Low Ranges':Low_Ranges, 'High Ranges':High_Ranges, 'REF#':ref_Num}
  241. Range_List[ref_Num] = Range_Found
  242. text = colored(str(found)+' '+str(Range_Found), 'cyan', 'on_grey', attrs=['reverse'])
  243. cprint(text)
  244.  
  245.  
  246.  
  247. else:
  248. Range_Clause = False
  249. tHigh = False
  250. tLow = False
  251. rFound = False
  252.  
  253.  
  254.  
  255.  
  256. if menu_ans == '1' and Liquidity_Data == 'y':
  257. if Close_Price > Open_Price and Liq_change > 0:
  258. Price_Tick = 1
  259. Liq_Tick = 1
  260. elif Close_Price >= Open_Price and Liq_change < 0:
  261. Price_Tick = 0
  262. Liq_Tick = -1
  263. elif Close_Price <= Open_Price and Liq_change > 0:
  264. Price_Tick = -1
  265. Liq_Tick = 0
  266. elif Close_Price <= Open_Price and Liq_change < 0:
  267. Price_Tick = -1
  268. Liq_Tick = -1
  269.  
  270. Tick = Liq_Tick + Price_Tick
  271. Strength += Tick
  272. percent_Strength = round(Strength / ref_Num, 4)
  273.  
  274.  
  275. if Tick == 2:
  276. Tick_String = Fore.BLUE+Back.GREEN+'STRONG BUYERS'+Style.RESET_ALL+' '+Fore.GREEN+str(Strength)
  277. if Tick == -1 and Price_Tick == 0:
  278. Tick_String = Fore.WHITE+'PRICE UP LIQ DOWN'+Style.RESET_ALL+' '+Fore.RED+str(Strength)
  279. if Tick == -2:
  280. Tick_String = Fore.RED+Back.YELLOW+'STRONG SELLERS'+Style.RESET_ALL+' '+Fore.WHITE+str(Strength)
  281. if Tick == -1 and Liq_Tick == 0:
  282. Tick_String = Fore.RED+'SHORT COVERING'+Style.RESET_ALL+' '+Fore.YELLOW+Back.BLUE+str(Strength)
  283. Range_List[ref_Num] = Range_Found
  284.  
  285. if Range_Clause == True:
  286. if range_ref_String == "HIGH TARGET" and Money_Flow < 300000000:
  287. if Liq_change > 1000000:
  288. print("MARKET MAKER HIGH TARGET")
  289. if range_ref_String == "LOW TARGET" and Money_Flow > 300000000:
  290. if Liq_change < 1000000:
  291. print("MARKET MAKER LOW TARGET")
  292.  
  293. if lr_filled == False:
  294. if filled == False:
  295. if range_ref_String == "LOW TARGET" and Low_Price <= Low_Range:
  296. filled_Price = Low_Price
  297. time.sleep(.5)
  298. print(Fore.WHITE + Back.RED + "LOW RANGE FILLED" + Style.RESET_ALL)
  299. time.sleep(1)
  300. lr_filled = True
  301. lt_filled = False
  302. lrf = 1
  303. low_Ranges_Filled += lrf
  304. if lt_filled == False and lr_filled == True:
  305. if Close_Price <= Low_Target:
  306. filled_target_price = Close_Price
  307. time.sleep(.5)
  308. print(Fore.RED + Back.YELLOW + 'LOW TARGET FILLED' + Style.RESET_ALL)
  309. time.sleep(1)
  310. lt_filled = True
  311. filled = True
  312. low_Targets_Filled += 1
  313. if hr_filled == False:
  314. if filled == False:
  315. if range_ref_String == "HIGH TARGET" and High_Price >= High_Range:
  316. filled_range_price = High_Price
  317. time.sleep(.5)
  318. print(Fore.CYAN + "HIGH RANGE FILLED" + Style.RESET_ALL)
  319. time.sleep(1)
  320. hr_filled = True
  321. ht_filled = False
  322. hrf = 1
  323. high_Ranges_Filled += hrf
  324. if ht_filled == False and hr_filled == True:
  325. if Close_Price >= High_Target:
  326. filled_target_price = High_Price
  327. print(Fore.CYAN + "HIGH TARGET FILLED")
  328. time.sleep(1)
  329. ht_filled = True
  330. filled = True
  331. high_Targets_Filled += 1
  332.  
  333.  
  334. if menu_ans == '4' or menu_ans == '1':
  335. if rFound == True:
  336. if tHigh == True:
  337. HRS = str(High_Range)
  338. HRT = str(High_Target)
  339. LRS = str(Low_Range)
  340. LRT = str(Low_Target)
  341. 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)
  342. time.sleep(2)
  343. if NoStop == True:
  344. with open('/Users/King/iFiles/iRanges/SPY1.csv', 'a') as csv_file:
  345. CandleDuration = CandleDur
  346. 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]
  347. wr = csv.writer(csv_file)
  348. wr.writerow(file_PriceList)
  349.  
  350. else:
  351. add_Range_Target = input('Would you like to add this range to file?: [y/n]:')
  352. if add_Range_Target == 'y':
  353. CandleDuration = '1Min'
  354. with open('/Users/King/iFiles/iRanges/SPY1.csv', 'a') as csv_file:
  355. 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]
  356. wr = csv.writer(csv_file)
  357. wr.writerow(file_PriceList)
  358.  
  359. else:
  360. tHigh = False
  361. else:
  362. rFound = False
  363. Close_Price = Close_Price
  364.  
  365. if rFound == True:
  366. if tLow == True:
  367. HRS = str(High_Range)
  368. HRT = str(High_Target)
  369. LRS = str(Low_Range)
  370. LRT = str(Low_Target)
  371. Low_Prices = {'LOW RANGE: $': Low_Range, 'LOW TARGET: $': Low_Target} ##### May not need this line
  372. 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)
  373. time.sleep(2)
  374. if NoStop == True:
  375. with open('/Users/King/iFiles/iRanges/Spy1.csv', 'a') as csv_file:
  376. CandleDuration = CandleDur
  377. 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]
  378. wr = csv.writer(csv_file)
  379. wr.writerow(file_PriceList)
  380. else:
  381. add_Range_Target = input('Would you like to add this range to file?: [y/n]:')
  382. if add_Range_Target == 'y':
  383. CandleDuration = '1Min'
  384. with open('/Users/King/iFiles/iRanges/Spy1.csv', 'a') as csv_file:
  385. 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]
  386. wr = csv.writer(csv_file)
  387. wr.writerow(file_PriceList)
  388. else:
  389. tLow = False
  390. else:
  391. rFound = False
  392.  
  393.  
  394. if Liq_change < -1000000:
  395. 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)
  396. time.sleep(1)
  397. if abs(Liq_change) > 500000:
  398. time.sleep(.005)
  399. 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)
  400. elif Liquidity > 0:
  401. if Liq_change > 0:
  402. time.sleep(.005)
  403. print(Fore.YELLOW + '[' + Date + ']', military_time,
  404. Fore.GREEN + 'Current Liquidity:' + '{:20,.2f}'.format(
  405. Liquidity) + Fore.GREEN + ' Liq Change: ' + '{:20,.2f}'.format(Liq_change) + ' ' + Fore.YELLOW + Back.BLUE,'Last Price [$' + str(Close_Price) + '] ' + Tick_String + Style.RESET_ALL)
  406. if Liq_change < 0:
  407. time.sleep(.005)
  408. print(Fore.YELLOW + '[' + Date + ']', military_time,
  409. Fore.GREEN + 'Current Liquidity:' + '{:20,.2f}'.format(
  410. 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)
  411. elif Liq_change > 0:
  412. time.sleep(.005)
  413. 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)
  414. elif Liq_change < 0:
  415. time.sleep(.005)
  416. 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)
  417.  
  418. MIV_Index = round(100 * (f_Vol / prevVol) - 100 * ((Money_Flow * HLCC) / (prevFlow * prevPrice)), 3)
  419. runningValueIndex = round(MIV_Index + prevIndexValue, 3)
  420. prevPrice = Close_Price
  421. prevFlow = Money_Flow
  422. prevVol = f_Vol
  423. prevIndexValue = MIV_Index
  424. MIV_Index_String = str(MIV_Index)
  425. liq_flowPrice = abs(Liq_change / Money_Flow)
  426. runningValueIndex_String = str(runningValueIndex)
  427. if abs(MIV_Index) > .25:
  428. if MIV_Index > .25:
  429. MIV_Index_String = str(round(MIV_Index, 2))
  430. 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)
  431. elif MIV_Index < -.25:
  432. MIV_Index_String = str(round(MIV_Index, 2))
  433. 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)
  434.  
  435.  
  436. '''if runningValueIndex > 0 and MIV_Index > 0:
  437. print(' '+Fore.BLACK+Back.WHITE+'MIV_Index:+'+MIV_Index_String+'% '+Style.RESET_ALL+' '+Fore.BLACK+Back.GREEN+'Running Value:+'+runningValueIndex_String+'%'+Style.RESET_ALL)
  438. if MIV_Index < 0 and runningValueIndex > 0:
  439. print(' '+Fore.RED+Back.YELLOW+'MIV_Index:'+MIV_Index_String+'% '+Style.RESET_ALL+' '+Fore.BLACK+Back.GREEN+'Running Value:+'+runningValueIndex_String+'%'+Style.RESET_ALL)
  440. if MIV_Index > 0 and runningValueIndex < 0:
  441. print(' '+Fore.WHITE+'MIV_Index:+'+MIV_Index_String+'% '+Style.RESET_ALL+' '+Fore.RED+Back.YELLOW+'Running Value:'+runningValueIndex_String+'%'+Style.RESET_ALL)
  442. if MIV_Index < 0 and runningValueIndex < 0:
  443. print(' '+Fore.RED+'MIV_Index:'+MIV_Index_String+'% '+Style.RESET_ALL+' '+Fore.RED+'Running Value:'+runningValueIndex_String+'%'+Style.RESET_ALL)'''
  444.  
  445. '''else:
  446. runningValueIndex += MIV_Index
  447. runningValueIndex_String = str(round(runningValueIndex, 2))
  448. if runningValueIndex > 0:
  449. print(Fore.GREEN+'MIV_Index: '+runningValueIndex_String, '%')
  450. else:
  451. runningValueIndex_String = str(round(runningValueIndex, 2))
  452. print(Fore.RED+'MIV_Index: '+runningValueIndex_String, '%')'''
  453.  
  454.  
  455. if menu_ans == '3':
  456. printRangeFile = input('Would you like to see other found ranges?: [y/n]')
  457. if printRangeFile == 'y':
  458. file_Choose = input('Which file would you like to use? [1 = 1 min Ranges] [2 = 2 min ranges] [5 = 5 min ranges]: ')
  459. if file_Choose == '1':
  460. filename = ('/Users/King/iFiles/iRanges/SPY1.csv')
  461. if file_Choose == '2':
  462. filename = ('/Users/King/iFiles/iRanges/SPY2.csv')
  463. if file_Choose == '5':
  464. filename = ('/Users/King/iFiles/iRanges/SPY5.csv')
  465. with open(filename, '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 = Fore.GREEN+'Current Strength: '+str(percent_Strength)+'%'
  557. if percent_Strength <-.68:
  558. percent_Strength_String = Fore.RED+'Current Strength: '+str(percent_Strength)+'%'
  559. if percent_Strength < 1 and percent_Strength > -.99:
  560. percent_Strength_String = colored('Current Strength: '+'#N/A', 'white', 'on_grey', attrs=['blink'])
  561. cprint(percent_Strength_String)
  562. else:
  563. print(percent_Strength_String)
  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/King/Desktop/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/King/Desktop/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