Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/bash python
- import csv
- import datetime
- from datetime import datetime
- from colorama import Back, Fore, Style
- from colorama import init
- import time
- from time import sleep
- with open('/Users/King/Desktop/iSPY.csv', 'r') as csv_file:
- csv_reader = csv.reader(csv_file)
- header = next(csv_reader)
- ref = [] # Start off w/ empty list
- ref_Num = int(0) # First to go in list = ref # (390 cells in 1 day)(using ref+=1 for each row)
- data = [] # Not sure but I could rearrange for liquidity?
- Liquidity = float()
- found = int(0)
- Range = []
- Target = []
- Range_List = {}
- Low_Range_Found = {}
- High_Range_Found = {}
- Range_Found = {}
- range_ref_String = ('')
- dTime = []
- printRanges = str()
- range_identifier_low = 'Low'
- range_identifier_high = 'High'
- range_identifier_all = 'All'
- All_Range_References = []
- All_Referenced_Prices = []
- menu_ans = input('What would you like to do? \n [1] Print Liquidity Data | [2] See previous ranges \n')
- if menu_ans == '1':
- Liquidity_Data = input('Would you like to print liquidity data? [y/n]: ')
- if menu_ans == '2':
- printRanges = input('Which ranges would you like to see?: [High/Low/All]\n')
- new_range = bool
- High_Prices = {}
- Low_Prices = {}
- t = bool
- tLow = bool
- tHigh = bool
- Target = float()
- Range_Dict = {}
- Low_ref_Num = int()
- High_ref_Num = int()
- Current_Price = float()
- for row in csv_reader:
- # row = [Time, Open, Close, High, Low, realVol, Money_Flow]
- ref_Num += 1 #Starting at 0
- dTime = str(datetime.strptime(row[0], '%a %b %d %H:%M'))
- Time = dTime[-14:]
- Open_Price = float(row[1]) # Price Data Dictionary
- Close_Price = float(row[2]) # Price Data Dictionary
- High_Price = float(row[3]) # Price Data Dictionary
- Low_Price = float(row[4]) # Price Data Dictionary
- Money_Flow = float(row[6])
- OHLC_Current = float(Open_Price+High_Price+Low_Price+Close_Price)/4
- Current_Price = OHLC_Current
- last = Close_Price # Price Data Dictionary
- Vol = str(row[5]) # Price Data Dictionary
- f_Vol = float(Vol[:-1]) # Price Data Dictionary
- m_Vol = str(Vol[-1:]) # Price Data Dictionary
- if m_Vol == "K": # Price Data Dictionary
- f_Vol = f_Vol * 1000 # Price Data Dictionary
- if m_Vol == "M": # Price Data Dictionary
- f_Vol = f_Vol * 1000000 # Price Data Dictionary
- HLCC = float(High_Price + Low_Price + Close_Price + Close_Price)/4 # Price Data Dictionary & RangeReference Dictionary
- M_Price = round(float(Money_Flow) / f_Vol, 2) # Price Data Dictionary & RangeReference Dictionary
- Diff = HLCC - M_Price # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
- MMM = float(f_Vol * HLCC) # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
- Liq_change = float(Money_Flow - MMM) # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
- Liquidity += Liq_change # Price Data Dictionary & RangeReference Dictionary & Data Dictionary
- Date = str(Time[:5]) # Important
- military_time = str(Time[-8:]) # Important
- allData = [ref_Num,Date, military_time, High_Price,Low_Price,Close_Price, HLCC, M_Price, f_Vol, Money_Flow,MMM, Liquidity,Liq_change]
- Data_Dict = {'REF#':[ref_Num],'Date':[Date],'Time':[military_time], 'Close_Price':[Close_Price], 'M_Price':[M_Price], 'Volume':[f_Vol]}
- '''USING THIS DATA
- [0]REFERENCE NUMBER
- [1]DATE
- [2]MILITARY_TIME
- [3]HIGH_PRICE
- [4]LOW_PRICE
- [5]CLOSE_PRICE
- [6]HLCC
- [7]M_Price
- [8]F_VOL
- [9]MONEY_FLOW
- [10]MARKETMAKERMOVE 'MMM'
- [11]LIQUIDITY
- [12]LIQ_CHANGE
- '''
- for i in allData[6:7]:
- criteria = abs(1)
- if abs(allData[7]-allData[6]) > criteria:
- found +=1
- diff = abs(M_Price - Close_Price)
- Range_Clause = True
- range_identifier_all = 'All'
- if Range_Clause == True:
- found_Price = HLCC
- Low_Range = round(HLCC - abs(float(M_Price - HLCC)), 2)
- High_Range = round(HLCC + abs(float(M_Price - HLCC)), 2)
- Low_Target = round(Low_Range - abs(float(M_Price - HLCC)), 2)
- High_Target = round(High_Range + abs(float(M_Price - HLCC)), 2)
- if M_Price >= found_Price+diff:
- ref_Num = ref_Num
- High_Ref_Num = ref_Num
- range_ref_String = "HIGH TARGET"
- tHigh = True
- Target = M_Price
- range_identifier = 'High'
- elif M_Price<= found_Price-diff:
- ref_Num = ref_Num
- Low_ref_Num = ref_Num
- range_ref_String = "LOW TARGET"
- tLow = True
- Target = M_Price
- range_identifier = 'Low'
- RT_Reference1 = [Low_Range, High_Range, Low_Target, High_Target]
- LRS = '$'+str(Low_Range)
- LRT = '$'+str(Low_Target)
- HRS = '$'+str(High_Range)
- HRT = '$'+str(High_Target)
- found_Price_String = '$'+str(found_Price)
- RT_Reference = [LRS, LRT, HRS, HRT]
- Target = round(Target, 2)
- Target_String = '$'+str(Target)
- lows = [LRS, LRT]
- highs = [HRS, HRT]
- targeting_String = range_ref_String+': $'
- end_String = 'Price while found: $'+str(Close_Price)
- Percent_Gain = (HLCC - Close_Price) / Close_Price
- if printRanges == range_identifier and range_identifier == range_identifier_low:
- Low_Range_Reference = [Date, military_time, range_ref_String, Target_String, end_String]
- Low_Range_Found = {'\nData Found':Low_Range_Reference, 'Watch for: $':lows, 'Potential Resistance: ':highs}
- Low_Range = Low_Range_Found
- for k, v in dict.items(Low_Range):
- print(Fore.RED, k, v)
- if printRanges == range_identifier and range_identifier == range_identifier_high:
- High_Range_Reference = [Date, military_time, range_ref_String, Target_String, end_String]
- High_Range_Found = {'\nData Found': High_Range_Reference, 'Watch for: $':highs, 'Potential Support: ':lows}
- High_Range = High_Range_Found
- for k, v in dict.items(High_Range):
- print(Fore.CYAN, k, v)
- if printRanges == range_identifier_all and range_identifier_all == range_identifier_all:
- Range_Reference = [Date, military_time, Close_Price, range_ref_String]
- TRange_Reference = [LRS, HRS, LRT, HRT]
- Range_Found = {'<-- Reference': Range_Reference, 'TRange Reference': TRange_Reference}
- Range_List[found] = Range_Found
- for k, v in dict.items(Range_List):
- print(k, v)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement