# Core Architecture

## Core Architecture <a href="#core-architecture" id="core-architecture"></a>

The fractrade.xyz platform consists of multiple components. The main components are:

* **fractrade.xyz:** Main website with some infos
* **fractrade.xyz App:** The webapp is the main interface for interacting with your Agents, creating new agents, researching strategies, etc.&#x20;
* **fractrade docs:** This documentation
* **Fractrade ExecutionClient:** Open-source Python client for executing trades on Hyperliquid, receives signals from your Agents. Having a local execution clients which users can setup on their own infrastructure allows you, to keep your Hyperliquid API keys private and add custom functionality.
* **Fractrade Telegram Bot:** Telegram bot for getting notifications from your Agents.
* **Fractrade Client API:** API for interacting with your Agents and developing your own data pipelines and strategies.
* **Fractrade Publisher API:** API for publishing trading signals and data to the marketplace and other subscribed agents.
* **Fractrade AI Agent Framework:** Open-Source framework for creating and training AI agents which can publish signals and data to the Publisher API.
* **Fractrade Agent**s: A set of agents with different features like market analytics, risk management, trade execution, copy trading, etc.&#x20;
* **Fractrade Worker:** Distributed task queue for executing all platform tasks like sending signals, executing trades, doing custom calculations, scanning the Hyperliquid ecosystem, monitoring on-chain data and off chain data, etc.

## How it works for users <a href="#how-it-works-for-users" id="how-it-works-for-users"></a>

Users can sign up on the fractrade.xyz App, which is free and currently in alpha testing stage. They can research strategies and configure custom AI agents which execute their preferred strategies. Some strategies are generic, which means they send the same signals/data for all users. Other strategies are custom, which means they send different signals/data for each user based on the individual configuration which is stored in the agent.

### Generic strategies <a href="#generic-strategies" id="generic-strategies"></a>

Examples include:

* A new token launched on Hyperliquid
* A new PERP is available on Hyperliquid
* The Market sentiment on Twitter changed
* Market Volume Spikes
* Anomaly detection

### Custom strategies <a href="#custom-strategies" id="custom-strategies"></a>

Examples include:

* Copy trading another wallet
* Risk management
* Custom market monitoring
* Portfoliomanagement: Your portfolio made 300% profit in token X, you might want to rebalance part of the profits into token Y
* There is a big TWAP order executing for one of the tokens in your portfolio
* The smart wallet you are following just bought a new token XYZ
* Your current open long position on BTC-PERP is at risk. There is an upcoming FOMC meeting increasing the volatility of the market and you are near a resistance level

When the agent and strategy are set up, users can start the agent and see the signals in the UI, on the Web sockets and can subscribe to them with the Telegram Bot. If they trade manually on Hyperliquid, using the fractrade.xyz App UI makes sense. For users who want to trade manually, setting up the agent subscription in Telegram is useful. And for fully automated algorithmic trading, you want to use the web socket connection to your agent, which gives you all signals in real time and allows you to act on the data or execute trades.

### Agent Types: Execution vs Signal <a href="#agent-types-execution-vs-signal" id="agent-types-execution-vs-signal"></a>

Fractrade supports two types of agents:

1. **Execution Agents**: These agents have an execution wallet configured and will automatically execute trades on your behalf. The platform handles all aspects of trade execution, including position sizing, order placement, and risk management.
2. **Signal Agents**: These agents do not have an execution wallet configured. They generate the same actions as execution agents, but these actions are not executed by the platform. Instead, you can receive these actions via websocket and execute them yourself.

Both agent types use the same strategies and generate the same actions. The only difference is whether the platform executes the actions automatically or leaves that to you.

### Action Websocket <a href="#action-websocket" id="action-websocket"></a>

All actions generated by agents (both execution and signal agents) are published to a websocket, except for `SEND_TELEGRAM` actions which are only used internally. This allows you to:

1. Monitor all tradable actions in real-time
2. Execute actions manually for signal agents
3. Build custom integrations with other systems
4. Create your own execution logic

Each action contains all the information needed to execute it, including: - Action type (e.g., EXECUTE\_HYPERLIQUID\_PERP\_TRADE, SET\_HYPERLIQUID\_PERP\_STOP\_LOSS) - Configuration details (e.g., symbol, size, price) - Agent and strategy information

This approach gives you maximum flexibility in how you use the platform.

Agents each have an input and an output. We are basically just passing a JSON data structure from one agent to the next. The output of the previous agent is the input for the next agent and so on. That way we can easily combine multiple agents to create more complex strategies. Your execution client then would just connect to the websocket of the last ageent in the chain and receive the final data / signals.

## How it works for Publishers <a href="#how-it-works-for-publishers" id="how-it-works-for-publishers"></a>

Developers can use our publisher framework to create custom strategies and data endpoints. They can be published on the marketplace and also require a subscription payment in USDC. Especially, running complex AI models might require some resources and a subscription is the only way to make it sustainable.

To get our marketplace started, fractrade.xyz will offer a set of strategies, data endpoints and agents ready to use, but eventually, our goal is to have a marketplace with hundreds of strategies, data endpoints and agents. We want to learn and develop together with our community and make it work for everyone.
