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
- '''from colorama import Back, Fore, Style
- from colorama import init
- import sys
- import colored
- from colored import fg, bg, attr
- 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()
- Range = []
- Target = []
- found = int(0)
- Range_List = {}
- range_ref_String = ('')
- dTime = []
- Liquidity_Data = input('Would you like to print liquidity data? [y/n]: ')
- printRanges = input('Would you like to print previous ranges?[y/n]: ')
- new_range = bool
- High_Prices = {}
- Low_Prices = {}
- t = bool
- tLow = bool
- tHigh = bool
- found = 0
- Target = float()
- Range_Dict = {}
- 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]) # 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]}
- for i in allData[6:7]:
- criteria = abs(1)
- if abs(allData[7]-allData[6]) > criteria:
- Found = 0
- diff = abs(M_Price - Close_Price)
- Range_Clause = True
- if Range_Clause == True:
- Found +=1
- 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:
- range_ref_String = "HIGH TARGET"
- tHigh = True
- Target = High_Range
- highRangeFoundString = str(Fore.CYAN + str(Range_List))
- elif M_Price<= found_Price-diff:
- range_ref_String = "LOW TARGET"
- tLow = True
- Target = Low_Range
- lowRangeFoundString = str(Fore.RED + str(Range_List))
- 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)
- info_range_Reference = [Date, military_time, found_Price_String, range_ref_String, Target_String]
- Range_Found = {'INFO: ':info_range_Reference, ' ':RT_Reference}
- Range_List[ref_Num] = Range_Found
- Percent_Gain = (HLCC - Close_Price) / Close_Price
- for i in Range_List:
- for k,v in dict.items(Range_List):
- if tHigh == True:
- print(highRangeFoundString)
- else:
- print(lowRangeFoundString)
- else:
- Range_Clause = False
- tHigh = False
- tLow = False
- '''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
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement