ImDerekD

*OFFICIAL*(01_06_11:51)

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