예제 #1
0
def getdailyadjclose(symbol: str, startdate: str, enddate: str) -> [float]:
    Utilities.verifydate(startdate)
    Utilities.verifydate(enddate)
    # bug: does not verify the date range matches. would require a more extensive cache system
    if symbol in __dailyadjcache.keys():
        return __dailyadjcache[symbol]
    share = yf.Share(symbol)
    history = share.get_historical(startdate, enddate)
    history.reverse()
    adjclose = [float]
    for h in history:
        adjclose.append(float(h["Adj_Close"]))
    __dailyadjcache[symbol] = adjclose
    return adjclose
예제 #2
0
파일: main.py 프로젝트: vibbix/PyStockCalc
def main():
    importfile = 'ex.json' if len(sys.argv) == 1 else sys.argv[1]
    portfolios = []
    with open(importfile) as jsonfile:
        p = json.loads(jsonfile.read())
        portfolios = Portfolio.getportfolios(p)
    profit = StockCalc.calculateprofit(
        portfolios, ("2016-01-01", Utilities.getformattedtoday()))
    StockCalc.printgraph(profit)
예제 #3
0
	def clean(self) :
		self.df = self.df.replace('', np.nan)
		self.df = self.df.dropna(subset=['FacilityLatitude','FacilityLongitude'])
		if 'GEOJSON.COORDINATES' in self.df.columns :
			self.df = self.df.drop(['GEOJSON.COORDINATES'], axis=1)
		if 'GEOJSON.TYPE' in self.df.columns:
			self.df = self.df.drop(['GEOJSON.TYPE'], axis=1)

		# drop duplicates
		#print("dropping duplicates")
		self.df = Utilities.dedupe_by_distance(self.df, 1, 'FacilityLatitude', 'FacilityLongitude', 'LastUpdatedDate')
예제 #4
0
    def clean(self):
        self.df = self.df.replace('', np.nan)
        self.df = self.df.dropna(
            subset=['FacilityLatitude', 'FacilityLongitude'])
        if 'GEOJSON.COORDINATES' in self.df.columns:
            self.df = self.df.drop(['GEOJSON.COORDINATES'], axis=1)
        if 'GEOJSON.TYPE' in self.df.columns:
            self.df = self.df.drop(['GEOJSON.TYPE'], axis=1)

        # drop duplicates
        #print("dropping duplicates")
        self.df = Utilities.dedupe_by_distance(self.df, 1, 'FacilityLatitude',
                                               'FacilityLongitude',
                                               'LastUpdatedDate')
예제 #5
0
	def run_merge(self, df_sub, df_super):
		merge_idx = Utilities.get_merge_index(df_sub,df_super, 0.2)
		df_super = df_super.assign(merge_index=merge_idx.astype(int))
		df_sub = df_sub[df_sub.columns[~df_sub.columns.isin(df_super.columns)]]
		merged = pd.merge(df_super, df_sub, how='left', left_on='merge_index', right_index = True)
		return merged
예제 #6
0
파일: tests.py 프로젝트: vibbix/PyStockCalc
 def testpreviousweekday(self):
     day = "2016-11-12"
     pv = Utilities.getpreviousweekday(day)
     self.assertEqual("2016-11-10", pv)
예제 #7
0
파일: tests.py 프로젝트: vibbix/PyStockCalc
 def multiarray(self):
     v1 = [5,5,5,5]
     v2 = [1,2,3,4]
     self.assertEqual([5,10,15,20], Utilities.multiplyarray(v1,v2))
예제 #8
0
 def merge(self, dp: []):
     dps = [self.profitdelta]
     for cdp in dp:
         dps.append(cdp.profitdelta)
     self.profitdelta = Utilities.ziparrays(dps[1:])
예제 #9
0
 def setdaterange(self, dr: (str, str)):
     dr1 = Utilities.verifydate(dr[0])
     dr2 = Utilities.verifydate(dr[0])
     self.daterange = (dr1, dr2)
예제 #10
0
def getdailyrevenue(symbol: str, stocks: int, startdate: str, enddate: str) -> [float]:
    adj = getdailyadjclose(symbol, startdate, enddate)[1:]
    v2 = Utilities.generatefullvector(stocks, len(adj))[0]
    return Utilities.multiplyarray(adj[1:], v2[0])