Skip to content

Commit

Permalink
Have to go to class
Browse files Browse the repository at this point in the history
  • Loading branch information
iwilson001 committed Dec 12, 2022
1 parent d0ef0c1 commit d0e0571
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions NewWay.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
regex_for_ticker = "\$[A-Z]{3}[A-Z]?[A-Z]?"

# openai key, delete before pushes
openai.api_key = "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"
openai.api_key = "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"

# list of tickers and if they have supporting posts
# stock_list = []
Expand All @@ -44,6 +44,7 @@

sobr_daily = get_data("sobr", start_date="11/27/2022", end_date="12/09/2022", index_as_date=True, interval="1d")
sobr_daily2 = get_data("sobr", start_date="12/01/2022", end_date="12/02/2022", index_as_date=True, interval="1d")
sobr_daily3 = get_data("sobr", start_date="12/06/2022", end_date="12/07/2022", index_as_date=True, interval="1d")

money = 10000.0
standard_num_shares = 100
Expand All @@ -70,6 +71,12 @@ def daterange(s_d, e_d):
one_day_later = single_date + dt.timedelta(days=1)
temp_start_epoch = int((dt.datetime.combine(single_date, dt.datetime.min.time())).timestamp())
temp_end_epoch = int((dt.datetime.combine(one_day_later, dt.datetime.min.time())).timestamp())
for num_days_left in time_to_sell_list:
num_days_left -= 1
print("NUMBER DAYS LEFT: " + str(num_days_left))
if num_days_left == 0:
money += 100 * sobr_daily3.open[0]

print(
single_date.strftime("%Y-%m-%d, %H:%M:%S") + " one day later: " + one_day_later.strftime("%Y-%m-%d, %H:%M:%S"))
myList = api.search_submissions(after=temp_start_epoch,
Expand Down Expand Up @@ -106,24 +113,25 @@ def daterange(s_d, e_d):
print("Sentiment of the body is: " + responseBody["choices"][0]["text"].replace("\n", ""))
if submission.link_flair_text == ":DDNerd: DD :DD:":
if temp_ticker not in ticker_list:
if submission.score >= 5 and responseTitle["choices"][0]["text"].replace("\n", "") == "Positive" or \
responseBody["choices"][0]["text"].replace("\n", "") == "Positive":
if submission.score >= 5 and (responseTitle["choices"][0]["text"].replace("\n", "") == "Positive" or \
responseBody["choices"][0]["text"].replace("\n", "") == "Positive"):
ticker_list.append(temp_ticker)
has_multiple_posts.append(False)
time_to_sell_list.append(-1)
print("SUBMISSION FOUND")
print(temp_ticker)
print("Score: " + str(submission.score))
else:
if has_multiple_posts[ticker_list.index(temp_ticker)] is False and responseTitle["choices"][0][
if has_multiple_posts[ticker_list.index(temp_ticker)] is False and (responseTitle["choices"][0][
"text"].replace("\n", "") == "Positive" or responseBody["choices"][0]["text"].replace("\n",
"") == "Positive":
"") == "Positive"):
has_multiple_posts[ticker_list.index(temp_ticker)] = True
print("The stock: " + temp_ticker + " has been backed : " + str(
has_multiple_posts[ticker_list.index(temp_ticker)]))
# buy the stock
money -= standard_num_shares * sobr_daily2.open[0]
print("money : " + money)
print("money : " + str(money))
time_to_sell_list[ticker_list.index(temp_ticker)] = 5


for i in ticker_list:
Expand All @@ -132,6 +140,7 @@ def daterange(s_d, e_d):
# sobr_daily = get_data("sobr", start_date="11/27/2022", end_date="12/09/2022", index_as_date=True, interval="1d")
# pprint(vars(sobr_daily))
display(sobr_daily2)
print("Ending money: " + str(money))

# sobr_daily.plot()

Expand Down

0 comments on commit d0e0571

Please sign in to comment.