Skip to content

Commit

Permalink
Modified Arithimitic for Price Change Function
Browse files Browse the repository at this point in the history
  • Loading branch information
basedafdev committed Sep 2, 2018
1 parent 55299cc commit 09e74b0
Show file tree
Hide file tree
Showing 3,297 changed files with 220,395 additions and 220,427 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file modified __pycache__/company.cpython-36.pyc
Binary file not shown.
Binary file modified __pycache__/directory.cpython-36.pyc
Binary file not shown.
Binary file modified __pycache__/load_files.cpython-36.pyc
Binary file not shown.
30 changes: 30 additions & 0 deletions analytics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from directory import Directory
from company import Company
from directory import selectionSort
def probability_of_returns(og_date, directory):
temp = Company('GOOG')
date = temp.dates.index(og_date)
next_date = date+8
results = directory.get_reversals_up(og_date)
selectionSort(results[1], results[0],1)
results = results[0]
print(len(results))
probability = 0
for company in results:
change = 0

change = company.get_average_rate(company.dates[date],company.dates[next_date],"PRICE")
print(company, change)

if change < 0:
probability += 1

probability /= len(results)
print(probability)
def gains(og_date, directory):
pass
if __name__ == "__main__":
x = Directory()
probability_of_returns(20180618,x)
probability_of_returns(20180619,x)
probability_of_returns(20180620,x)
21 changes: 0 additions & 21 deletions company.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,7 @@ def get_change_in_price(self, start, end):
end_index = self.dates.index(end)
return (self.close_prices[end_index] - self.open_prices[start_index])/self.open_prices[start_index]

def get_average_rate(self, start: int, end: int, category: str):
"""
Return the average rate of change for a specific time-range
start: start_date int
end: end_date int
category: price or volume
"""

if start not in self.dates or end not in self.dates:
raise IndexError

start_index = self.dates.index(start)
end_index = self.dates.index(end)

if category == "PRICE":
return (self.close_prices[start_index] +\
((self.close_prices[end_index]-self.close_prices[start_index])/ \
(end_index-start_index)))/self.close_prices[start_index] - 1
else:
return (self.volumes[start_index] + \
((self.volumes[end_index]-self.volumes[start_index])/\
(end_index-start_index)))/self.volumes[start_index] - 1

def getavg(self, start: int, end: int, category: str):
"""
Expand Down
62 changes: 31 additions & 31 deletions company_library/AABA.csv
Original file line number Diff line number Diff line change
@@ -1,35 +1,4 @@
symbol,begins_at,close_price,high_price,interpolated,low_price,open_price,session,volume
AABA,2017-07-20,58.450000,58.580000,False,58.020000,58.460000,reg,8756962
AABA,2017-07-21,58.160000,58.400000,False,57.760000,58.190000,reg,8832362
AABA,2017-07-24,58.150000,58.500000,False,58.020000,58.280000,reg,3671434
AABA,2017-07-25,58.070000,58.365000,False,57.865000,57.980000,reg,3264422
AABA,2017-07-26,58.900000,59.030000,False,57.930000,57.950000,reg,5443708
AABA,2017-07-27,58.430000,60.215000,False,57.560000,59.610000,reg,8395031
AABA,2017-07-28,59.200000,59.640000,False,57.980000,58.110000,reg,5871045
AABA,2017-07-31,58.400000,59.890000,False,58.070000,59.700000,reg,6738130
AABA,2017-08-01,58.500000,58.800000,False,58.110000,58.600000,reg,4164450
AABA,2017-08-02,57.660000,59.250000,False,56.900000,58.950000,reg,5846199
AABA,2017-08-03,58.150000,58.330000,False,57.130000,57.870000,reg,4726578
AABA,2017-08-04,58.510000,58.570000,False,58.013600,58.430000,reg,7330487
AABA,2017-08-07,60.030000,60.160000,False,58.756300,58.850000,reg,5540180
AABA,2017-08-08,59.860000,60.440000,False,59.620000,59.770000,reg,4207240
AABA,2017-08-09,59.770000,59.950000,False,59.070000,59.230000,reg,3071198
AABA,2017-08-10,58.030000,59.510000,False,57.870000,59.170000,reg,4420250
AABA,2017-08-11,57.920000,58.232500,False,56.840000,57.780000,reg,5552460
AABA,2017-08-14,58.870000,59.020000,False,58.500000,58.700000,reg,7409532
AABA,2017-08-15,59.990000,60.135000,False,58.790000,59.280000,reg,7863461
AABA,2017-08-16,60.650000,60.850000,False,60.210000,60.430000,reg,7640557
AABA,2017-08-17,62.200000,63.460000,False,62.090000,63.050000,reg,11943624
AABA,2017-08-18,63.070000,63.700000,False,62.055000,62.360000,reg,13009004
AABA,2017-08-21,63.600000,64.000000,False,62.900000,63.150000,reg,4594092
AABA,2017-08-22,65.420000,65.520000,False,63.755000,63.760000,reg,5627242
AABA,2017-08-23,65.820000,66.000000,False,64.640000,65.010000,reg,4131526
AABA,2017-08-24,65.500000,66.199900,False,65.340000,66.060000,reg,4055765
AABA,2017-08-25,64.510000,65.560000,False,64.260000,65.410000,reg,5941278
AABA,2017-08-28,63.530000,64.430000,False,63.130000,64.430000,reg,5567391
AABA,2017-08-29,63.170000,63.720000,False,62.100000,62.300000,reg,3590107
AABA,2017-08-30,64.160000,64.580000,False,63.630000,63.650000,reg,5288699
AABA,2017-08-31,64.080000,64.760000,False,63.835000,64.500000,reg,3676518
AABA,2017-09-01,64.050000,64.380000,False,63.860000,64.170000,reg,2191331
AABA,2017-09-05,63.860000,64.300000,False,63.280000,63.530000,reg,3277325
AABA,2017-09-06,63.320000,64.278700,False,62.900000,63.710000,reg,4875988
Expand Down Expand Up @@ -251,3 +220,34 @@ AABA,2018-07-16,74.660000,74.890000,False,74.080000,74.310000,reg,9835239
AABA,2018-07-17,75.360000,75.550000,False,73.620000,73.980000,reg,8570675
AABA,2018-07-18,74.660000,75.570000,False,74.471100,75.440000,reg,11081304
AABA,2018-07-19,73.360000,74.290000,False,73.140000,74.140000,reg,8135164
AABA,2018-07-20,73.270000,74.070000,False,73.030000,73.600000,reg,7184869
AABA,2018-07-23,73.150000,73.450000,False,72.310000,73.100000,reg,6877046
AABA,2018-07-24,74.150000,75.660000,False,73.910800,74.160000,reg,12963288
AABA,2018-07-25,77.530000,77.720000,False,74.290000,74.290000,reg,9100834
AABA,2018-07-26,76.190000,76.790000,False,75.530000,76.150000,reg,10315811
AABA,2018-07-27,74.100000,77.000000,False,73.210000,76.890000,reg,15501759
AABA,2018-07-30,72.390000,74.580000,False,71.320000,74.330000,reg,19783664
AABA,2018-07-31,73.450000,74.100000,False,72.160000,73.140000,reg,18425155
AABA,2018-08-01,73.180000,74.590000,False,72.670000,73.200000,reg,22297599
AABA,2018-08-02,72.090000,72.220000,False,71.030000,71.800000,reg,26039039
AABA,2018-08-03,71.580000,72.750000,False,71.310000,72.740000,reg,25890977
AABA,2018-08-06,70.890000,71.510000,False,70.320000,71.380000,reg,35841735
AABA,2018-08-07,71.500000,72.450000,False,71.240100,71.460000,reg,11515375
AABA,2018-08-08,70.990000,71.750000,False,70.460000,71.750000,reg,22470346
AABA,2018-08-09,70.490000,71.450000,False,70.310000,70.820000,reg,37448086
AABA,2018-08-10,70.970000,71.440000,False,69.770000,69.840000,reg,25773369
AABA,2018-08-13,70.200000,71.202400,False,70.080000,71.140000,reg,12439745
AABA,2018-08-14,68.150000,69.890000,False,67.830000,69.890000,reg,15583842
AABA,2018-08-15,67.040000,67.110000,False,65.780000,66.180000,reg,9798485
AABA,2018-08-16,68.140000,69.450000,False,67.930000,67.940000,reg,9290053
AABA,2018-08-17,68.170000,68.940000,False,67.040000,67.870000,reg,13238109
AABA,2018-08-20,69.260000,70.270000,False,68.620000,68.840000,reg,11537278
AABA,2018-08-21,70.250000,70.690000,False,69.610000,69.670000,reg,4675208
AABA,2018-08-22,70.320000,70.700000,False,69.430000,70.290000,reg,7280936
AABA,2018-08-23,68.220000,73.150000,False,68.140000,72.510000,reg,27034721
AABA,2018-08-24,68.900000,69.600000,False,68.170000,69.080000,reg,4898927
AABA,2018-08-27,70.840000,70.890000,False,69.530000,69.680000,reg,3550185
AABA,2018-08-28,70.300000,71.450000,False,69.950000,71.280000,reg,3095438
AABA,2018-08-29,70.430000,70.615000,False,69.870000,70.320000,reg,2642494
AABA,2018-08-30,69.330000,70.290000,False,69.090000,70.020000,reg,8258839
AABA,2018-08-31,69.550000,69.930000,False,68.732000,68.900000,reg,5783610
Loading

0 comments on commit 09e74b0

Please sign in to comment.