Advertisement
ImDerekD

TargetPrograms.py_March3rd

Mar 3rd, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.33 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import csv
  4. from datetime import datetime
  5. import time
  6. from colorama import Back, Fore, Style
  7.  
  8.  
  9.  
  10. Liquidity = float()
  11. ref_Num = int()
  12. prevVol = float(1)
  13. prevPrice = float(1)
  14. prevFlow = float(1)
  15.  
  16. ValuePrice = float()
  17.  
  18. SumFlow = float()
  19. SumVol = float()
  20. Bearish = bool
  21. Bullish = bool
  22.  
  23. Price1 = float()
  24. Price2 = float()
  25. prevPrice1 = float()
  26.  
  27. Last = float()
  28. PL = float()
  29. PLString = str()
  30. Chg = float()
  31. SignalList = []
  32.  
  33. MIV_Spike = float()
  34. MIV_Spike_Count = int()
  35.  
  36.  
  37. with open('/Users/King/Spy_current.csv', 'r') as csv_file:
  38. reader = csv.reader(csv_file)
  39. header = next(reader)
  40. for row in reader:
  41. ref_Num += 1
  42. dTime = str(datetime.strptime(row[0], '%a %b %d %H:%M'))
  43. Time = dTime[-14:]
  44. Open_Price = float(row[1])
  45. Close_Price = float(row[2])
  46. High_Price = float(row[3])
  47. Low_Price = float(row[4])
  48. Money_Flow = float(row[6])
  49. last = Close_Price
  50. Vol = row[5]
  51. f_Vol = float(Vol[:-1])
  52. m_Vol = str(Vol[-1:])
  53. if m_Vol == "K":
  54. f_Vol = f_Vol * 1000
  55. if m_Vol == "M":
  56. f_Vol = f_Vol * 1000000
  57. if m_Vol != "K" and m_Vol != "M":
  58. f_Vol = float(row[5])
  59. if f_Vol < 1:
  60. M_Price = HLCC
  61. else:
  62. M_Price = round(float(Money_Flow) / f_Vol, 2)
  63. HLCC = float(High_Price + Low_Price + Close_Price + Close_Price) / 4
  64. Diff = round(HLCC - M_Price, 2)
  65. MMM = float(f_Vol * HLCC)
  66. Liq_change = float(Money_Flow - MMM)
  67. Liquidity += Liq_change
  68. Date = str(Time[:5])
  69. military_time = str(Time[-8:])
  70. criteria = abs(.0035 * HLCC)
  71. HLC3 = float(High_Price+ Low_Price + Close_Price + Close_Price + Close_Price) / 5
  72. Paway = round(100*((M_Price - Close_Price) / Close_Price), 3)
  73.  
  74.  
  75. SumVol += f_Vol
  76. SumFlow += Money_Flow
  77. ValuePrice = round(SumFlow / SumVol, 2)
  78.  
  79.  
  80. if ref_Num >=2:
  81. prevPrice1 = Close_Price
  82.  
  83. if HLCC <= ValuePrice:
  84. Bearish = True
  85. Bullish = False
  86. Signal = 'SELL'
  87. SignalStr = Fore.RED+Signal+Style.RESET_ALL
  88.  
  89.  
  90. if HLCC >= ValuePrice:
  91. Bearish = False
  92. Bullish = True
  93. Signal = 'BUY'
  94. SignalStr = Fore.CYAN+Signal+Style.RESET_ALL
  95.  
  96.  
  97. if Liq_change > 0:
  98. liqchgstr = '{:20,.2f}'.format(Liq_change)+Style.RESET_ALL
  99. LiqChangeStr = Fore.CYAN+liqchgstr+Style.RESET_ALL
  100.  
  101. if Liq_change < 0:
  102. liqchgstr = '{:20,.2f}'.format(Liq_change)+Style.RESET_ALL
  103. LiqChangeStr = Fore.RED+liqchgstr+Style.RESET_ALL
  104.  
  105. DateStr = Fore.YELLOW+str(Date)+Style.RESET_ALL
  106. TimeStr = Fore.YELLOW+str(military_time)+Style.RESET_ALL
  107.  
  108. if Liquidity > 0:
  109. Liqstr = '{:20,.2f}'.format(Liquidity)
  110. LiqStr = Fore.CYAN+Liqstr+Style.RESET_ALL
  111.  
  112. if Liquidity < 0:
  113. Liqstr = '{:20,.2f}'.format(Liquidity)
  114. LiqStr = Fore.WHITE+Liqstr+Style.RESET_ALL
  115.  
  116.  
  117.  
  118.  
  119. if Money_Flow > 0:
  120. MIV_Index = round(100 * (f_Vol / prevVol) - 100 * ((Money_Flow * HLCC) / (prevFlow * prevPrice)), 3)
  121. prevPrice = Close_Price
  122. prevFlow = Money_Flow
  123. prevVol = f_Vol
  124. MIV_Index_String = str(MIV_Index)
  125. LiqFlowPrice = abs(Liq_change / Money_Flow)
  126.  
  127. if MIV_Index >= .25:
  128. MIV_Spike += MIV_Index
  129. MIV_Spike_Count += 1
  130. Avg_MIV_Spike = MIV_Spike / MIV_Spike_Count
  131.  
  132.  
  133. if abs(Liq_change) > 0:
  134. LiqFlowPrice = .01*round(Money_Flow / abs(Liq_change), 3)
  135. VolLiqPrice = round(f_Vol / abs(Liq_change), 2)
  136. LiqFlowPriceClone = round(1000 * (abs(Liq_change) / Money_Flow), 4) * .01
  137.  
  138. if abs(M_Price - HLCC) >= criteria:
  139.  
  140. diff = abs(M_Price - Close_Price)
  141. Range_Clause = True
  142. range_identifier_all = 'All'
  143.  
  144. if Range_Clause == True:
  145. t_price = M_Price
  146. found_Price = Close_Price
  147. range_ref_String = ''
  148. Low_Range = round(HLCC - abs(float(M_Price - HLCC)), 2)
  149. High_Range = round(HLCC + abs(float(M_Price - HLCC)), 2)
  150. Low_Target = round(Low_Range - abs(float(M_Price - HLCC)), 2)
  151. High_Target = round(High_Range + abs(float(M_Price - HLCC)), 2)
  152.  
  153. if M_Price >= High_Range:
  154. r_Price = M_Price
  155. t_Price = High_Target
  156. oppRange = Low_Range
  157. oppTarget = Low_Target
  158. tHigh = True
  159. found_Price = Close_Price
  160. tLow = False
  161. range_ref_String = 'HIGH TARGET'
  162. if MIV_Index > 0:
  163. range_ref_String = 'FALSE HIGH TARGET (CAPPER)'
  164. elif M_Price <= Low_Range:
  165. r_Price = M_Price
  166. t_Price = Low_Target
  167. oppRange = High_Range
  168. oppTarget = High_Target
  169. tLow = True
  170. tHigh = False
  171. found_Price = Close_Price
  172. range_ref_String = 'LOW TARGET'
  173.  
  174. if range_ref_String == 'LOW TARGET':
  175. if LiqFlowPriceClone >= .039:
  176. if LiqFlowPrice <= 2.6 and LiqFlowPrice >= 2.45:
  177. Program = 'MODERATE CONFIDENCE'
  178. if LiqFlowPrice < 2.45:
  179. Program = 'HIGH CONFIDENCE'
  180. else:
  181. Program = 'LOW CONFIDENCE / LIQUIDITY SEARCH'
  182.  
  183. if LiqFlowPriceClone >= .04:
  184. if range_ref_String == 'HIGH TARGET':
  185. if LiqFlowPrice > 2.6:
  186. oppRange = str(Low_Range)
  187. oppTarget = str(Low_Target)
  188. Program = 'SCALP OPPOSITE'+' $'+oppTarget+'-$'+oppRange
  189. else:
  190. Program = 'LOW CONFIDENCE'
  191. if range_ref_String == 'LOW TARGET':
  192. if LiqFlowPrice < 2.45:
  193. oppTarget = str(High_Target)
  194. oppRange = str(High_Range)
  195. Program = 'VOLATILE LOW (HIGH CONFIDENCE)'
  196.  
  197. if LiqFlowPriceClone >=.039 and range_ref_String == 'HIGH TARGET':
  198. if LiqFlowPrice < 2.6:
  199. Program = 'VOLATILE BULL TRAP (MODERATE CONFIDENCE)'
  200. if LiqFlowPrice > 2.6 and LiqFlowPrice < 2.8:
  201. Program = 'MODERATE CONFIDENCE'
  202.  
  203. if LiqFlowPriceClone <= .037:
  204. if range_ref_String == 'HIGH TARGET':
  205. if LiqFlowPrice >= 2.75:
  206. oppTargetStr = str(oppTarget)
  207. if abs(MIV_Index)
  208. Program = '<<LONG TERM>> BULLISH (BTMFD)'+oppTargetStr
  209. if LiqFlowPrice <= 2.75:
  210. Program = 'VERY HIGH CONFIDENCE'
  211.  
  212. if range_ref_String == 'LOW TARGET':
  213. if LiqFlowPrice >= 2.75:
  214. Program = 'BUY THE FUCKING DIP'
  215. if LiqFlowPrice <= 2.75:
  216. Program = 'POTENTIAL BOTTOM'
  217.  
  218.  
  219.  
  220. if LiqFlowPriceClone >= .043 and LiqFlowPrice <= 2.40:
  221. if range_ref_String == 'HIGH TARGET':
  222. oppRangeStr = str(High_Range)
  223. Program = 'TOUCH N GO (SELL %s)' % oppRangeStr
  224. elif LiqFlowPriceClone >= .04 and LiqFlowPrice <= 2.46:
  225. if range_ref_String == 'LOW TARGET':
  226. Program = 'AGGRESSIVE LOW TARGET'+' $ '+str(Low_Target)
  227. if range_ref_String == 'HIGH TARGET':
  228. Program = 'BULL TRAP RESISTANCE'+' $'+str(High_Target)
  229.  
  230.  
  231.  
  232. if range_ref_String == 'LOW TARGET':
  233. if MIV_Index >= Avg_MIV_Spike * 2.5:
  234. Program = 'WALL OF CHINA OVERHEAD'
  235.  
  236. if LiqFlowPrice < .037:
  237. Program = 'BOTTOM SIDE REVERSAL TARGET [$',Low_Target,']'
  238.  
  239. if LiqFlowPrice >= 2.6 and MIV_Index >= 0:
  240. if MIV_Index < Avg_MIV_Spike and LiqFlowPriceClone <= .038:
  241. if LiqFlowPrice >= 2.7:
  242. Program = 'MMs IN CONTROL (BULLISH)'
  243. if MIV_Index >= Avg_MIV_Spike and LiqFlowPrice <= 2.7:
  244. Program = 'MMs IN CONTROL (BEARISH)'
  245.  
  246.  
  247.  
  248.  
  249. print(Date, military_time,' Current Liquidity:', '{:20,.2f}'.format(Liquidity), ' Liq Change:','{:20,.2f}'.format(Liq_change), ' Last Price:', Close_Price, range_ref_String+' Type: '+Program+' MIV [',MIV_Index,'%]',' LFP [',LiqFlowPrice,']',' LFP Clone [',LiqFlowPriceClone,']')
  250. time.sleep(2.5)
  251.  
  252. else:
  253. Range_Clause = False
  254.  
  255. time.sleep(.0075)
  256.  
  257. if ref_Num % 2 != 0:
  258. Price1 = Close_Price
  259.  
  260. if ref_Num % 2 == 0:
  261. Price2 = Close_Price
  262.  
  263.  
  264. if ref_Num % 2 != 0 and ref_Num > 2:
  265. Last = Price2
  266. Chg = 100*round((Close_Price - Last) / Last, 4)
  267.  
  268. if ref_Num % 2 == 0 and ref_Num >= 2:
  269. Last = Price1
  270. Chg = 100*round((Close_Price - Last) / Last, 4)
  271.  
  272. SignalList.append(Signal)
  273. for i in SignalList[-2:-1]:
  274. if i == 'BUY':
  275. PL += Chg
  276. if i == 'SELL':
  277. PL += Chg*-1
  278. # if Bullish == True:
  279. # PL += Chg
  280. # if Bearish == True:
  281. # PL += Chg*-1
  282.  
  283. PLR = round(PL, 3)
  284. if PL > 0:
  285. PLString = Fore.CYAN+str(PLR)+'%'
  286. if PL < 0:
  287. PLString = Fore.RED+str(PLR)+'%'
  288.  
  289.  
  290. print(DateStr, TimeStr,' Current Liquidity:'+LiqStr,' Liq Change:'+LiqChangeStr,' Last Price:',Close_Price, SignalStr+Style.RESET_ALL+' ['+PLString+Style.RESET_ALL+']')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement