This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
In response to the order imbalance posts recently, I spent the last couple days learning about order imbalances, opening/closing auctions, and python.
TL;DR
According to NYSE Auctions Data: yesterday (8/30) GME posted the largest closing auction BUY average imbalance quantity of the last 3 months...by far
Now, I am super financially artarded, but happen to be a .NET developer by trade. So, naturally, I asked ChatGPT to write some Python and after some analysis over G_ME, A_MC, and CH_WY.............I see no real correlation between this metric and anything concerning the stock price.
BUT WAIT
There's a lot more to the story, and I plan on continuing to analyze until MOASS or until boredom.
First off, what the fuck is a closing auction?
Honestly, I just asked ChatGPT and I'm still not really sure I understand it - "A closing auction is a process used in financial markets to determine the final price of a security at the end of a trading session. It allows market participants to place buy and sell orders for a security at the market close, and then matches these orders to establish a final price."
IDK, not even gonna attempt to summarize, all I know is you can get closing auction data here
NYSE Auctions Data
Also, same thing happens with opening auctions, but slightly different because its opening vs closing. Ask a GPT or your economics professor or the crackhead on the corner or something, I truly don't know.
I HAVE PYTHON
Even though I don't know what the fuck anything means, I can still tinker with python code and put data into CSVs. So here's how you can do that too. If you just want my raw CSV data DM me and I can send ya somethin (no dicks please, but if you have to, give me the Brett Favre POV, none of this mirror BS...).
Sorry the indenting didn't carry over, if you care you can figure it out ;)
First script, queries the NYSE opening and closing auction sites for data on the three stocks mentioned above over the last 6 months. Creates CSVs
import requests
import json
import csv
from bs4 import BeautifulSoup
from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
def fetch_data_for_symbols(symbols):
today = datetime.today()
six_months_ago = today - relativedelta(months=6)
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36"
}
auction_types = ["closing", "opening"]
for auction_type in auction_types:
for symbol in symbols:
current_date = today
first = True
filename = f"1 Data/{auction_type}/{symbol}_data.csv"
while current_date >= six_months_ago:
url = f"https://www.nyse.com/api/auction-charts?symbol={symbol}&tradeDate={current_date.strftime('%m-%d-%Y')}&auctionType={auction_type}"
print(f"Requesting URL: {url}")
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.content, 'html.parser')
json_data = json.loads(soup.__str__())
if len(json_data) > 0:
fieldnames = json_data[0].keys()
with open(filename, mode='a', newline='') as file:
writer = csv.DictWriter(file, fieldnames=fieldnames)
if first:
writer.writeheader()
first = False
for entry in reversed(json_data):
writer.writerow(entry)
current_date -= timedelta(days=1)
if __name__ == "__main__":
symbols_list = ["G_ME", "C_HWY", "A_MC"] //fix these
fetch_data_for_symbols(symbols_list)
Second script works off the first scripts CSV outputs. Groups by date and generates some statistical values for the columns of each grouped date
import pandas as pd
import os
closing_columns_to_read = ['tradeDate', 'closingQty', 'closingPrice', 'quantity', 'price', 'avgPairedQty', 'avgImbalanceQty', 'avgBookClearingPrice']
opening_columns_to_read = ['tradeDate', 'quantity', 'price', 'avgPairedQty', 'avgImbalanceQty', 'avgBookClearingPrice']
auction_types = ["closing", "opening"]
data_folder = "1 Data"
for auction_type in auction_types:
columns_to_read = opening_columns_to_read if auction_type == "opening" else closing_columns_to_read
filenames = os.listdir(f"{data_folder}/{auction_type}")
for filename in filenames:
print(f"processing {auction_type} file {filename}")
df = pd.read_csv(f"{data_folder}/{auction_type}/{filename}", usecols=columns_to_read)
data_list = df.to_dict(orient='records')
df = pd.DataFrame(data_list)
df['tradeDate'] = pd.to_datetime(df['tradeDate']).dt.date
grouped = df.groupby('tradeDate')
if auction_type == "opening":
agg = grouped.agg(
quantity=('quantity', 'max'),
price=('price', 'max'),
start_avgPairedQty=('avgPairedQty', lambda x: x.loc[x.index[x.index == x.idxmax()]].values[0]),
end_avgPairedQty=('avgPairedQty', lambda x: x.loc[x.index[x.index == x.idxmin()]].values[0]),
max_avgPairedQty=('avgPairedQty', 'max'),
min_avgPairedQty=('avgPairedQty', 'min'),
start_avgImbalanceQty=('avgImbalanceQty', lambda x: x.loc[x.index[x.index == x.idxmax()]].values[0]),
end_avgImbalanceQty=('avgImbalanceQty', lambda x: x.loc[x.index[x.index == x.idxmin()]].values[0]),
max_avgImbalanceQty=('avgImbalanceQty', 'max'),
min_avgImbalanceQty=('avgImbalanceQty', 'min'),
start_avgBookClearingPrice=('avgBookClearingPrice', lambda x: x.loc[x.index[x.index == x.idxmax()]].values[0]),
end_avgBookClearingPrice=('avgBookClearingPrice', lambda x: x.loc[x.index[x.index == x.idxmin()]].values[0]),
max_avgBookClearingPrice=('avgBookClearingPrice', 'max'),
min_avgBookClearingPrice=('avgBookClearingPrice', 'min')
)
else:
agg = grouped.agg(
closingQty=('closingQty', 'max'),
closingPrice=('closingPrice', 'max'),
quantity=('quantity', 'max'),
price=('price', 'max'),
start_avgPairedQty=('avgPairedQty', lambda x: x.loc[x.index[x.index == x.idxmax()]].values[0]),
end_avgPairedQty=('avgPairedQty', lambda x: x.loc[x.index[x.index == x.idxmin()]].values[0]),
max_avgPairedQty=('avgPairedQty', 'max'),
min_avgPairedQty=('avgPairedQty', 'min'),
start_avgImbalanceQty=('avgImbalanceQty', lambda x: x.loc[x.index[x.index == x.idxmax()]].values[0]),
end_avgImbalanceQty=('avgImbalanceQty', lambda x: x.loc[x.index[x.index == x.idxmin()]].values[0]),
max_avgImbalanceQty=('avgImbalanceQty', 'max'),
min_avgImbalanceQty=('avgImbalanceQty', 'min'),
start_avgBookClearingPrice=('avgBookClearingPrice', lambda x: x.loc[x.index[x.index == x.idxmax()]].values[0]),
end_avgBookClearingPrice=('avgBookClearingPrice', lambda x: x.loc[x.index[x.index == x.idxmin()]].values[0]),
max_avgBookClearingPrice=('avgBookClearingPrice', 'max'),
min_avgBookClearingPrice=('avgBookClearingPrice', 'min')
)
output_filename = f"2 Agg/{auction_type}/agg_{filename}"
agg.to_csv(output_filename)
print(f"complete")
Conclusions
- Vertical lines on a graph get me superduper hard
- Vertical lines on a graph sometimes mean absolutely nothing
- Haven't found any opening/closing auction indicators
- Will continue to evaluate
- Like python
- Love Richard Newton (goddamn tie that hair back for me baby)
Finally
I truly enjoyed doing this. G_ME may be the greatest enigma of our time. Not necessarily because of gamestop or RC or RK or RN, but because of what its exposed - the complete corruption and control of our stock markets by a privileged few.
I've been DRSed since 2021, have a SHIT ASS cost basis, and am zen AF.
PS
Please hit me up if you have any worthy endeavors for me to put my coding experience towards, enjoy working even if the results end up worthless :)
EDIT
Part 2 with CSVs and indented python here
Order Imbalance DD - Part 2 Spreadsheet Boogaloo : r/Superstonk (reddit.com)
Subreddit
Post Details
- Posted
- 2 months ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/Superstonk/...