Advertisement
ImDerekD

Untitled

Dec 23rd, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.21 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. from colorama import init
  8. import time
  9. from time import sleep
  10. with open('/Users/King/Desktop/iSPY.csv', 'r') as csv_file:
  11. csv_reader = csv.reader(csv_file)
  12. header = next(csv_reader)
  13.  
  14.  
  15. ref = [] # Start off w/ empty list
  16. ref_Num = int(0) # First to go in list = ref # (390 cells in 1 day)(using ref+=1 for each row)
  17. data = [] # Not sure but I could rearrange for liquidity?
  18. Liquidity = float()
  19. found = int(0)
  20. Range = []
  21. Target = []
  22. Range_List = {}
  23. Low_Range_Found = {}
  24. High_Range_Found = {}
  25. Range_Found = {}
  26. range_ref_String = ('')
  27. dTime = []
  28. printRanges = str()
  29. range_identifier_low = 'Low'
  30. range_identifier_high = 'High'
  31. range_identifier_all = 'All'
  32. All_Range_References = []
  33. All_Referenced_Prices = []
  34. menu_ans = input('What would you like to do? \n [1] Print Liquidity Data | [2] See previous ranges \n')
  35. if menu_ans == '1':
  36. Liquidity_Data = input('Would you like to print liquidity data? [y/n]: ')
  37. if menu_ans == '2':
  38. printRanges = input('Which ranges would you like to see?: [High/Low/All]\n')
  39. new_range = bool
  40. High_Prices = {}
  41. Low_Prices = {}
  42. t = bool
  43. tLow = bool
  44. tHigh = bool
  45. Target = float()
  46. Range_Dict = {}
  47. Low_ref_Num = int()
  48. High_ref_Num = int()
  49. Current_Price = float()
  50.  
  51. for row in csv_reader:
  52. # row = [Time, Open, Close, High, Low, realVol, Money_Flow]
  53. ref_Num += 1 #Starting at 0
  54. dTime = str(datetime.strptime(row[0], '%a %b %d %H:%M'))
  55. Time = dTime[-14:]
  56. Open_Price = float(row[1]) # Price Data Dictionary
  57. Close_Price = float(row[2]) # Price Data Dictionary
  58. High_Price = float(row[3]) # Price Data Dictionary
  59. Low_Price = float(row[4]) # Price Data Dictionary
  60. Money_Flow = float(row[6])
  61. OHLC_Current = float(Open_Price+High_Price+Low_Price+Close_Price)/4
  62. Current_Price = OHLC_Current
  63. last = Close_Price # Price Data Dictionary
  64. Vol = str(row[5]) # Price Data Dictionary
  65. f_Vol = float(Vol[:-1]) # Price Data Dictionary
  66. m_Vol = str(Vol[-1:]) # Price Data Dictionary
  67. if m_Vol == "K": # Price Data Dictionary
  68. f_Vol = f_Vol * 1000 # Price Data Dictionary
  69. if m_Vol == "M": # Price Data Dictionary
  70. f_Vol = f_Vol * 1000000 # Price Data Dictionary
  71. HLCC = float(High_Price + Low_Price + Close_Price + Close_Price)/4 # Price Data Dictionary & RangeReference Dictionary
  72. M_Price = round(float(Money_Flow) / f_Vol, 2) # Price Data Dictionary & RangeReference Dictionary
  73. Diff = HLCC - M_Price # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  74. MMM = float(f_Vol * HLCC) # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  75. Liq_change = float(Money_Flow - MMM) # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  76. Liquidity += Liq_change # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
  77. Date = str(Time[:5]) # Important
  78. military_time = str(Time[-8:]) # Important
  79. allData = [ref_Num,Date, military_time, High_Price,Low_Price,Close_Price, HLCC, M_Price, f_Vol, Money_Flow,MMM, Liquidity,Liq_change]
  80. Data_Dict = {'REF#':[ref_Num],'Date':[Date],'Time':[military_time], 'Close_Price':[Close_Price], 'M_Price':[M_Price], 'Volume':[f_Vol]}
  81. '''USING THIS DATA
  82. [0]REFERENCE NUMBER
  83. [1]DATE
  84. [2]MILITARY_TIME
  85. [3]HIGH_PRICE
  86. [4]LOW_PRICE
  87. [5]CLOSE_PRICE
  88. [6]HLCC
  89. [7]M_Price
  90. [8]F_VOL
  91. [9]MONEY_FLOW
  92. [10]MARKETMAKERMOVE 'MMM'
  93. [11]LIQUIDITY
  94. [12]LIQ_CHANGE
  95. '''
  96. for i in allData[6:7]:
  97. criteria = abs(1)
  98. if abs(allData[7]-allData[6]) > criteria:
  99. found +=1
  100. diff = abs(M_Price - Close_Price)
  101. Range_Clause = True
  102. range_identifier_all = 'All'
  103. if Range_Clause == True:
  104. found_Price = HLCC
  105. Low_Range = round(HLCC - abs(float(M_Price - HLCC)), 2)
  106. High_Range = round(HLCC + abs(float(M_Price - HLCC)), 2)
  107. Low_Target = round(Low_Range - abs(float(M_Price - HLCC)), 2)
  108. High_Target = round(High_Range + abs(float(M_Price - HLCC)), 2)
  109. if M_Price >= found_Price+diff:
  110. ref_Num = ref_Num
  111. High_Ref_Num = ref_Num
  112. range_ref_String = "HIGH TARGET"
  113. tHigh = True
  114. Target = M_Price
  115. range_identifier = 'High'
  116. elif M_Price<= found_Price-diff:
  117. ref_Num = ref_Num
  118. Low_ref_Num = ref_Num
  119. range_ref_String = "LOW TARGET"
  120. tLow = True
  121. Target = M_Price
  122. range_identifier = 'Low'
  123. RT_Reference1 = [Low_Range, High_Range, Low_Target, High_Target]
  124. LRS = '$'+str(Low_Range)
  125. LRT = '$'+str(Low_Target)
  126. HRS = '$'+str(High_Range)
  127. HRT = '$'+str(High_Target)
  128. found_Price_String = '$'+str(found_Price)
  129. RT_Reference = [LRS, LRT, HRS, HRT]
  130. Target = round(Target, 2)
  131. Target_String = '$'+str(Target)
  132. lows = [LRS, LRT]
  133. highs = [HRS, HRT]
  134. targeting_String = range_ref_String+': $'
  135. end_String = 'Price while found: $'+str(Close_Price)
  136. Percent_Gain = (HLCC - Close_Price) / Close_Price
  137. if printRanges == range_identifier and range_identifier == range_identifier_low:
  138. Low_Range_Reference = [Date, military_time, range_ref_String, Target_String, end_String]
  139. Low_Range_Found = {'\nData Found':Low_Range_Reference, 'Watch for: $':lows, 'Potential Resistance: ':highs}
  140. Low_Range = Low_Range_Found
  141. for k, v in dict.items(Low_Range):
  142. print(Fore.RED, k, v)
  143. if printRanges == range_identifier and range_identifier == range_identifier_high:
  144. High_Range_Reference = [Date, military_time, range_ref_String, Target_String, end_String]
  145. High_Range_Found = {'\nData Found': High_Range_Reference, 'Watch for: $':highs, 'Potential Support: ':lows}
  146. High_Range = High_Range_Found
  147. for k, v in dict.items(High_Range):
  148. print(Fore.CYAN, k, v)
  149. if printRanges == range_identifier_all and range_identifier_all == range_identifier_all:
  150. Range_Reference = [Date, military_time, Close_Price, range_ref_String]
  151. TRange_Reference = [LRS, HRS, LRT, HRT]
  152. Range_Found = {'<-- Reference': Range_Reference, 'TRange Reference': TRange_Reference}
  153. Range_List[found] = Range_Found
  154. for k, v in dict.items(Range_List):
  155. print(k, v)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement