web / scripts /06_post.py
LinJennyLin's picture
Deploy SharpFlow (nav + example wallets + Polymarket copy)
d4c51f2 verified
Raw History Blame Contribute Delete
1.87 kB
#!/usr/bin/env python3
"""Step 6 — turn today's digest into ready-to-post distribution assets.
python scripts/06_post.py # last 24h
python scripts/06_post.py --hours 72 --url https://sharpflow.app
Writes:
data/thread_<date>.txt the X/Twitter thread (copy-paste or feed to an API)
data/card_<date>.png dark-theme image card for the first tweet
"""
import argparse
import sys
from pathlib import Path
import pandas as pd
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from pmct import digest as dg
from pmct import post as po
from pmct.client import PolymarketClient
from pmct.util import load_config, cache_path
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--hours", type=int, default=24)
ap.add_argument("--url", default="", help="site URL for the CTA tweet")
args = ap.parse_args()
cfg = load_config()
df = pd.read_csv(cache_path(cfg, "wallets.csv"))
selected = dg.select_smart_money(df, dg.SelectionConfig())
if selected.empty:
raise SystemExit("No traders passed the wedge filter.")
client = PolymarketClient(sleep_sec=0.15)
moves = dg.fresh_moves(client, selected, hours=args.hours)
print(f"{len(selected)} traders · {len(moves)} fresh moves.")
stamp = f"{pd.Timestamp.now('UTC'):%Y%m%d_%H%M}"
thread = po.x_thread(selected, moves, hours=args.hours, site_url=args.url)
txt = cache_path(cfg, f"thread_{stamp}.txt")
txt.write_text("\n\n---\n\n".join(thread), encoding="utf-8")
png = po.table_png(moves, cache_path(cfg, f"card_{stamp}.png"), hours=args.hours)
print(f"\nThread -> {txt}")
print(f"Card -> {png if png else '(no moves / matplotlib unavailable)'}\n")
for i, t in enumerate(thread, 1):
print(f"--- tweet {i} ({len(t)} chars) ---\n{t}\n")
if __name__ == "__main__":
main()