Polytrader
An web application where an agent trades on polymarket for you. Only worry about choosing the market and reviewing the agent's analysis - Poly will do the rest for you.
Created on 14th February 2025
•
Polytrader
An web application where an agent trades on polymarket for you. Only worry about choosing the market and reviewing the agent's analysis - Poly will do the rest for you.
The problem Polytrader solves
Polytrader allows you to save time when it comes to making trads on Polymarket.
People offload time spent on researching and analyzing markets to Poly, the agent. By simply choosing the market you want to partake in, the agent does:
- Research
- web research using Exa and
deep research, a recursive implementation. - Qualitative Research
- web research using Exa and
- Analysis
- By utilizing the Polymarket’s GLOB and Gamma APIs - the agent has tools to extract more information about the market.
- Quantitative Research
- Trade
- Based off the information to this point, the agent chooses BUY, SELL, or NO_TRADE, the side (Yes or No), the size, and gives its reasoning
and if it decides to do make a trade, depending on the amount it has in it's wallet to allocate, it will execute the order. Assuming you accept the order of course.
Challenges I ran into
-
The Polymarket API seems to be a bit outdated, so reading through the clob-client implementation was needed to be made bother in the backend (for agent info) and the frontend (mainly for fetching
Marketdata).- Setting up scripts to get large swaths of data from polymarket, and then manually looking over them to determine to true schema. From this, I was able to build custom types which helped build the market list.
- Polymarket built a agent repo a few months ago, so it was very helpful looking over there code and using it within my project. There was tweaks that needed to be made, but rather than attempting to reinvent the wheel, I used their code as a base and tweaked it for my needs.
-
Different versions of LangGraph SDK in python and JS. In python, there is an interrupt function that allows you to easily add human-in-the-loop functionality, but in JS, it's not as straightforward.
- Creating two different nodes to handle the interruption, one for JS and one for Python. Python version is fairly straight forward, however, for the web app version, I needed to great a empty node that would be used to trigger the interrupt. I added a breakpoint to run right before this node ran, and then trigger the user input. Once the user input was received, I would update the state, interrupt the previous execution run, and start a new one from the place we left off.
-
Handling execution flow of Langgraph state when it came to reflecting on data that was certain to be valid.
- Since each agent relied on tools + reflection nodes, setting up the pipeline to determine what should happen next proved tto be non-trivial (especially given I have only used LangGraph for 2 weeks)
- So I developed a workflow that would always check the last message that was sent, determine if the last message was a tool message (not strictly, but to an extent this pattern applied across all major nodes) and read the metadata that came wwith it. Depending on some state values were up
- Since each agent relied on tools + reflection nodes, setting up the pipeline to determine what should happen next proved tto be non-trivial (especially given I have only used LangGraph for 2 weeks)
Tracks Applied (1)
