Advertisement
ImDerekD

Fuck7.py_01_16

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