Advertisement
ImDerekD

FIXED RANGES_01_16

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