Advertisement
ImDerekD

Untitled

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