Spaces:
Running
Running
File size: 1,870 Bytes
d4c51f2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #!/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()
|