### Install Dependencies Source: https://github.com/traderspost/docs/blob/main/learn/signal-sources/discord-trading-bot.md Install the required HTTP client and Discord PHP library using Composer. ```bash $ composer require symfony/http-client $ composer require team-reflex/discord-php ``` -------------------------------- ### Go Webhook Example Source: https://context7.com/traderspost/docs/llms.txt Send trading signals from Go applications to the TradersPost webhook. This example demonstrates setting up the request with JSON data. ```go package main import ( "bytes" "encoding/json" "fmt" "net/http" ) func main() { url := "https://webhooks.traderspost.io/trading/webhook/{uuid}/{password}" data := map[string]interface{}{ "ticker": "AMD", "action": "buy", "price": 85.50, } jsonData, _ := json.Marshal(data) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() var result map[string]interface{} json.NewDecoder(resp.Body).Decode(&result) fmt.Println(result) } ``` -------------------------------- ### Initialize PHP Project Environment Source: https://github.com/traderspost/docs/blob/main/developer-resources/custom-code-examples.md Commands to create a project directory and install the required Symfony HTTP client dependency. ```bash mkdir traderspost cd traderspost ``` ```bash composer require symfony/http-client ``` -------------------------------- ### Trading Window Strategy Example Source: https://github.com/traderspost/docs/blob/main/learn/signal-sources/tradingview.md A Pine Script strategy example demonstrating how to implement a trading time window. It uses session inputs to define trading hours and EMA crossovers for entry signals. ```pinescript @version=5 strategy('TradersPost Trading Window Example Strategy', overlay=true) tradingWindow = input.session("0900-1455", title="Trading Window") group1 = "Exit Rules" useExitHour = input.bool(defval=true, title="Exit at Defined Hour and Minute", group = group1) exitHour = input.int(defval=6, title="Hour", minval=0, maxval=23, step=1, group = group1, inline = "Exit Time") exitMinute = input.int(defval=0, title="Minute", minval=0, maxval=59, step=1, group = group1, inline = "Exit Time") inTradingWindow = not na(time(timeframe.period, tradingWindow)) bgcolor(color=inTradingWindow ? color.new(color.green, 90) : color.new(color.white, 99)) ema8 = ta.ema(close, 8) ema21 = ta.ema(close, 21) isUptrend = ema8 >= ema21 isDowntrend = ema8 <= ema21 trendChanging = ta.cross(ema8, ema21) tradersPostBuy = trendChanging and isUptrend tradersPostSell = trendChanging and isDowntrend if (inTradingWindow and tradersPostBuy) strategy.entry("TradersPost Long", strategy.long) if (inTradingWindow and tradersPostSell) strategy.entry("TradersPost Short", strategy.short) if (useExitHour == true and hour == exitHour and minute == exitMinute) strategy.close_all() ``` -------------------------------- ### Full Webhook Signal Example with Quantity Source: https://github.com/traderspost/docs/blob/main/assets/options-trading.md A comprehensive webhook signal example that includes the ticker, action, and an optional quantity parameter, which can be used for calculated orders. ```json { "ticker": "SQ", "action": "buy", "quantity": 5 } ``` -------------------------------- ### Simple Webhook Example Source: https://github.com/traderspost/docs/blob/main/learn/webhooks.md This is an example of a simple webhook payload containing trade signal information. It specifies the ticker and the desired action. ```json { "ticker": "AMD", "action": "buy" } ``` -------------------------------- ### Configure Limit and Stop Limit Orders Source: https://github.com/traderspost/docs/blob/main/core-concepts/webhooks.md Examples for setting specific order types like limit and stop limit. ```json { "ticker": "SPY", "action": "buy", "orderType": "limit", "limitPrice": 50.50 } ``` ```json { "ticker": "SPY", "action": "buy", "orderType": "stop_limit", "stopPrice": 60, "limitPrice": 50.50 } ``` -------------------------------- ### Entry Order with Limit Price Example Source: https://github.com/traderspost/docs/blob/main/assets/stock-trading.md This JSON example shows how to place a buy order for AAPL with a specified limit price. It's used when the signal does not provide a price, and TradersPost needs to fetch a quote from the broker. ```json { "ticker": "AAPL", "action": "buy", "orderType": "limit", "limitPrice": 100 } ``` -------------------------------- ### JavaScript Webhook Example Source: https://context7.com/traderspost/docs/llms.txt Send trading signals from Node.js or browser JavaScript using the fetch API. This example includes ticker, action, price, quantity, take profit, and stop loss. ```javascript fetch('https://webhooks.traderspost.io/trading/webhook/{uuid}/{password}', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ ticker: 'AMD', action: 'buy', price: 85.50, quantity: 10, takeProfit: { percent: 10 }, stopLoss: { type: 'stop', percent: 5 } }) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error(error)); ``` -------------------------------- ### Configure Percent of Equity via Webhook Source: https://github.com/traderspost/docs/blob/main/learn/platform-concepts/position-sizing.md Example JSON payload to set a percentage of equity for position sizing. ```json { "ticker": "TSLA", "action": "buy", "orderType": "limit", "limitPrice": 100, "quantityType": "percent_of_equity", "quantity": 1 } ``` -------------------------------- ### TradeStation MinMove Data Example Source: https://github.com/traderspost/docs/blob/main/all-supported-connections/tradestation.md This JSON object shows an example of minMove data reported by TradeStation. It is used to diagnose price rounding issues. ```json { "source": "ts", "symbol": "RNAZ", "expirationDate": null, "ask": "1.2", "bid": "1.19", "last": "1.1912", "mark": "1.195", "minMove": { "threshold": 0, "below": "0.0001", "above": "0.0001" }, "baseMinMove": null, "pointValue": "1", "updatedAt": "2025-03-21T14:05:01.000000+00:00", "status": "realtime" } ``` -------------------------------- ### Example for Add Action Source: https://github.com/traderspost/docs/blob/main/core-concepts/webhooks.md Demonstrates the 'add' action, which is used to increase an existing open position. This action can be used regardless of the 'Allow add to position' setting in strategy subscriptions. ```json { "ticker": "SPY", "action": "add" } ``` -------------------------------- ### Successful Webhook Response Example Source: https://github.com/traderspost/docs/blob/main/learn/webhooks.md This is an example of a successful webhook response from TradersPost, indicating that a trading signal was processed correctly. ```javascript { "success":true, "id":"47462f2d-378c-4bf5-a016-1c1221aa0e62", "logId":"a036eff1-b7db-4f15-b5b6-f5e51995ad29", "payload": { "ticker":"NQ", "action":"buy", "sentiment": "bullish", "price":12663.5, "quantity": 1 } } ``` -------------------------------- ### Configure Amount per Position via Webhook Source: https://github.com/traderspost/docs/blob/main/learn/platform-concepts/position-sizing.md Example JSON payload to set a fixed dollar amount for position sizing. ```json { "ticker": "TSLA", "action": "buy", "orderType": "limit", "limitPrice": 100, "quantityType": "amount_per_position", "quantity": 1000 } ``` -------------------------------- ### Configure Fixed Quantity via Webhook Source: https://github.com/traderspost/docs/blob/main/learn/platform-concepts/position-sizing.md Example JSON payload to specify a fixed number of shares to trade. ```json { "ticker": "TSLA", "action": "buy", "orderType": "market", "quantity": 5 } ``` -------------------------------- ### Basic JSON Message Example Source: https://github.com/traderspost/docs/blob/main/core-concepts/json-messages.md A simple JSON message structure for a buy order, including essential trading parameters. ```json { "ticker": "NQ1!", "action": "buy", "signalPrice": 18250.5, "quantity": 2, "time": "2025-06-17T10:30:00Z" } ``` -------------------------------- ### Example Signal JSON Message Source: https://github.com/traderspost/docs/blob/main/core-concepts/signals.md A sample JSON payload representing a buy order for 3 contracts of MNQ1!. ```json { "ticker": "MNQ1!", "action": "buy", "quantity": 3 } ``` -------------------------------- ### Configure Risk per Position via Webhook Source: https://github.com/traderspost/docs/blob/main/learn/platform-concepts/position-sizing.md Example JSON payload to set a fixed risk amount for position sizing. ```json { "ticker": "TSLA", "action": "buy", "orderType": "limit", "limitPrice": 100, "stopLoss": { "type": "stop", "stopPrice": 90 }, "quantityType": "risk_per_position", "quantity": 100 } ``` -------------------------------- ### Send Full Stock Trading Signal with Price and Quantity Source: https://github.com/traderspost/docs/blob/main/assets/stock-trading.md This example demonstrates a complete signal including ticker, action, price, and quantity. If configured, this can result in a 'Buy Limit' order with specified shares and price. ```json { "ticker": "SQ", "action": "buy", "price": 108.88, "quantity": 100 } ``` -------------------------------- ### Webhook Error Response Source: https://github.com/traderspost/docs/blob/main/learn/webhooks.md Example response returned when a webhook is not found. ```javascript { "success": false, "messageCode": "not-found", "message": "Webhook not found." } ``` -------------------------------- ### Risk Per Position Calculation Example Source: https://github.com/traderspost/docs/blob/main/assets/stock-trading.md Demonstrates how to calculate the number of shares based on a risk per position value and a stop-loss price. Ensure the stop-loss is correctly configured for accurate calculation. ```json { "ticker": "AAPL", "action": "buy", "price": "660", "stopLoss": { "stopPrice": 90 } "time": "2025-09-09T14:07:08Z", "interval": "5" } ``` -------------------------------- ### Define a Buy Order Webhook JSON Source: https://github.com/traderspost/docs/blob/main/README (1).md Example payload for a limit buy order of 5 shares of AMD at $85.50. ```json { "ticker": "AMD", "action": "buy", "orderType": "limit", "limitPrice": "85.50", "quantity": 5 } ``` -------------------------------- ### Cancel Open Orders Example Source: https://github.com/traderspost/docs/blob/main/assets/futures-trading.md Shows the effect of disabling order cancellation before submitting new orders, particularly when stop losses or take profits are active. ```json { "ticker": "MNQU2025", "action": "sell", "sentiment": "flat", "quantity": "2", "price": "23810.25", "time": "2025-09-09T14:07:08Z", "interval": "5" } ``` -------------------------------- ### Example for Ticker and Action Fields Source: https://github.com/traderspost/docs/blob/main/core-concepts/webhooks.md This snippet shows the required 'ticker' and 'action' fields in a JSON message. The 'ticker' specifies the financial instrument, and 'action' indicates the trade operation. ```json { "ticker": "MSFT", "action": "buy" } ``` -------------------------------- ### Python Webhook Example for Simple Buy Signal Source: https://context7.com/traderspost/docs/llms.txt Send a simple buy signal to the TradersPost webhook using Python's requests library. Requires a webhook URL with UUID and password. ```python import requests webhook_url = 'https://webhooks.traderspost.io/trading/webhook/{uuid}/{password}' # Simple buy signal response = requests.post(webhook_url, json={ "ticker": "AMD", "action": "buy", "price": 85.50 }) print(response.json()) ``` -------------------------------- ### Send Webhook with PHP Source: https://github.com/traderspost/docs/blob/main/developer-resources/custom-code-examples.md Example implementation using the Symfony HTTP Client to send a POST request to a TradersPost webhook URL. ```php request('POST', $webhookUrl, [ 'json' => [ 'ticker' => 'AMD', 'action' => 'buy', 'price' => 85.50, ] ]); echo $response->getContent(); ``` ```php request('POST', $webhookUrl, [ 'json' => [ 'ticker' => 'AMD', 'action' => 'buy', 'price' => 85.50, ] ]); echo $response->getContent(); ``` -------------------------------- ### TradingView Strategy Alert Message with Placeholders Source: https://context7.com/traderspost/docs/llms.txt Create dynamic alert messages for Pine Script strategies using TradingView placeholders. This example includes ticker, action, sentiment, quantity, price, time, and interval. ```json { "ticker": "{{ticker}}", "action": "{{strategy.order.action}}", "sentiment": "{{strategy.market_position}}", "quantity": "{{strategy.order.contracts}}", "price": "{{close}}", "time": "{{timenow}}", "interval": "{{interval}}" } ``` -------------------------------- ### Initialize Project Directory Source: https://github.com/traderspost/docs/blob/main/learn/signal-sources/discord-trading-bot.md Create and enter a new directory for the bot project. ```bash $ mkdir discord-bot $ cd discord-bot ``` -------------------------------- ### Invalid Webhook Request Example Source: https://github.com/traderspost/docs/blob/main/learn/webhooks.md An example of an invalid JSON payload sent to the TradersPost webhook, which would result in a 400 Bad Request response. ```json { "ticker": "NQ", "action": "bu" } ``` -------------------------------- ### Rejected Webhook Response Example Source: https://github.com/traderspost/docs/blob/main/learn/webhooks.md This is an example of a rejected webhook response from TradersPost due to an invalid action parameter. It includes a message code and a descriptive message. ```json { "success":false, "logId":"bf3b4869-bf85-48cc-a1b3-8e49c77215ae", "messageCode":"invalid-action", "message":"Invalid action provided. Action must be one of: buy, sell, exit, cancel, add." } ``` -------------------------------- ### Bracket Order Configuration Source: https://context7.com/traderspost/docs/llms.txt Combine take profit and stop loss with an entry signal. ```json { "ticker": "AMD", "action": "buy", "signalPrice": 143.12, "quantity": 1, "takeProfit": { "percent": 10 }, "stopLoss": { "type": "stop", "percent": 5 } } ``` -------------------------------- ### Custom Code POST Request Example Source: https://github.com/traderspost/docs/blob/main/core-concepts/webhooks.md Example of sending a custom JSON payload using curl. This demonstrates how to make a POST request with a JSON body to the TradersPost webhook URL. ```bash curl -X POST \ -H 'Content-Type: application/json' \ -d '{"ticker": "MNQ", "action": "buy"}' \ https://webhooks.traderspost.io/trading/webhook/98a90567-fac3-42b9-8c5d-97c4ec1710ba/6de6c4a446497f11debba25b90e90462 ``` -------------------------------- ### Run the Bot Source: https://github.com/traderspost/docs/blob/main/learn/signal-sources/discord-trading-bot.md Execute the bot script using the PHP CLI. ```bash $ php bot.php ``` -------------------------------- ### Create Entry Order with Take Profit and Stop Loss Source: https://github.com/traderspost/docs/blob/main/core-concepts/webhooks.md Combine take profit and stop loss functionalities within a single entry order. Both `takeProfit` and `stopLoss` objects should be included in the order signal. ```json { "ticker": "SPY", "action": "buy", "takeProfit": { "limitPrice": 19.99 }, "stopLoss": { "type": "stop", "stopPrice": 10.71 } } ``` -------------------------------- ### Trading Signal JSON Payload Source: https://github.com/traderspost/docs/blob/main/assets/futures-trading.md Example of a sell signal payload used to test trading window constraints. ```json { "ticker": "MNQU2025", "action": "sell", "quantity": "2", "price": "23810.25", "time": "2025-09-09T16:01:08Z", "interval": "5" } ``` -------------------------------- ### Define a Limit Exit Order Source: https://github.com/traderspost/docs/blob/main/assets/stock-trading.md Example of a JSON signal payload specifying a limit price for an exit order. ```json { "ticker": "AAPL", "action": "sell", "orderType": "limit", "limitPrice": 100 } ``` -------------------------------- ### Take Profit Options Source: https://github.com/traderspost/docs/blob/main/core-concepts/webhooks.md Configure take profit levels for your entry signals. You can choose between 'limitPrice', 'percent', or 'amount'. ```APIDOC ## Take Profit Configuration ### Description Allows setting a take profit target for an order. Only one type of take profit can be specified at a time. ### Parameters #### Request Body - **takeProfit** (object) - Optional - Configuration for the take profit. - **limitPrice** (number) - Optional - Absolute limit price. Mutually exclusive with `percent` and `amount`. - **percent** (number) - Optional - Relative percentage take profit. Mutually exclusive with `limitPrice` and `amount`. - **amount** (number) - Optional - Relative dollar amount take profit. Mutually exclusive with `limitPrice` and `percent`. ### Request Example (Percent) ```json { "ticker": "SPY", "action": "buy", "takeProfit": { "percent": 10 } } ``` ### Request Example (Amount) ```json { "ticker": "SPY", "action": "buy", "takeProfit": { "amount": 10 } } ``` ### Request Example (Limit Price) ```json { "ticker": "SPY", "action": "buy", "takeProfit": { "limitPrice": 19.99 } } ``` ``` -------------------------------- ### Take Profit Order Configuration Source: https://context7.com/traderspost/docs/llms.txt Attach a take profit order using percentage, dollar amount, or absolute limit price. ```json { "ticker": "SPY", "action": "buy", "takeProfit": { "percent": 10 } } ``` ```json { "ticker": "SPY", "action": "buy", "takeProfit": { "amount": 15 } } ``` ```json { "ticker": "SPY", "action": "buy", "takeProfit": { "limitPrice": 495.00 } } ``` -------------------------------- ### Create TradersPost Directory Source: https://github.com/traderspost/docs/blob/main/learn/signal-sources/custom-code.md Use these bash commands to create a new directory for your TradersPost project and navigate into it. ```bash mkdir traderspost cd traderspost ``` -------------------------------- ### Send Webhook with Go Source: https://github.com/traderspost/docs/blob/main/developer-resources/custom-code-examples.md Implementation using the standard net/http package to marshal data and send a POST request. ```go package main import ( "bytes" "encoding/json" "fmt" "net/http" ) func main() { url := "https://webhooks.traderspost.io/trading/webhook/8c9d9620-c50d-416e-926e-0ec01ee83522/a353c3e16f9e3ded7c58cfedd2c38d74" data := map[string]interface{}{ "ticker": "AMD", "action": "buy", "price": 85.50, } jsonData, err := json.Marshal(data) if err != nil { panic(err) } req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) if err != nil { panic(err) } req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() var result map[string]interface{} err = json.NewDecoder(resp.Body).Decode(&result) if err != nil { panic(err) } fmt.Println(result) } ``` -------------------------------- ### Trading Window Exit JSON Payload Source: https://github.com/traderspost/docs/blob/main/assets/stock-trading.md Example JSON payload for an exit signal sent outside of defined trading hours. ```json { "ticker": "SPY", "action": "sell", "quantity": "50", "price": "660", "time": "2025-09-09T16:01:08Z", "interval": "5" } ``` -------------------------------- ### Subtract Exit Quantity JSON Payload Source: https://github.com/traderspost/docs/blob/main/assets/stock-trading.md Example JSON payload for adjusting signal quantity by subtracting the current exit quantity. ```json { "ticker": "SPY", "action": "sell", "quantity": "100", "price": "660", "time": "2025-09-09T14:07:08Z", "interval": "5" } ``` -------------------------------- ### Partial Exit Signal Source: https://github.com/traderspost/docs/blob/main/learn/platform-concepts/order-behavior.md Use this to partially exit a position by specifying the quantity to sell. This example exits 3 out of 5 shares. ```json { "ticker": "TSLA", "action": "exit", "quantity": 3 } ``` -------------------------------- ### Side Swapping JSON Payload Source: https://github.com/traderspost/docs/blob/main/assets/stock-trading.md Example JSON payload used to trigger a side swap when an opposite action signal is received. ```json { "ticker": "SPY", "action": "sell", "quantity": "50", "price": "660", "time": "2025-09-09T14:07:08Z", "interval": "5" } ``` -------------------------------- ### Configure Percentage Stop Loss Source: https://github.com/traderspost/docs/blob/main/learn/webhooks.md Calculates a stop loss based on a percentage relative to the entry price. ```json { "ticker": "SQ", "action": "buy", "stopLoss": { "type": "stop", "percent": 5 } } ``` -------------------------------- ### Send Basic Buy Signal via Webhook Source: https://context7.com/traderspost/docs/llms.txt Use this cURL command to send a basic buy signal with ticker, action, and price. Authentication is handled via URL parameters. The response indicates success and provides IDs. ```bash curl -X POST \ -H 'Content-Type: application/json' \ -d '{"ticker": "AMD", "action": "buy", "price": 85.50}' \ 'https://webhooks.traderspost.io/trading/webhook/{uuid}/{password}' ``` ```json { "success": true, "id": "47462f2d-378c-4bf5-a016-1c1221aa0e62", "logId": "a036eff1-b7db-4f15-b5b6-f5e51995ad29", "payload": { "ticker": "AMD", "action": "buy", "price": 85.50 } } ``` -------------------------------- ### Full Entry Signal Source: https://github.com/traderspost/docs/blob/main/assets/futures-trading.md Include price and quantity fields to specify order parameters for the broker. ```json { "ticker": "NQH2022", "action": "buy", "price": 1420.50, "quantity": 2 } ``` -------------------------------- ### Configure Percentage Take Profit Source: https://github.com/traderspost/docs/blob/main/core-concepts/webhooks.md Use this for a relative percentage take profit. The entry price for market orders is estimated from the quote's midpoint. ```json { "ticker": "SPY", "action": "buy", "takeProfit": { "percent": 10 } } ``` -------------------------------- ### Sides Isolated JSON Payload Source: https://github.com/traderspost/docs/blob/main/assets/stock-trading.md Example JSON payload demonstrating a trade signal that would be rejected if the sides isolated setting is enabled. ```json { "ticker": "SPY", "action": "buy", "quantity": "50", "price": "660", "time": "2025-09-09T14:07:08Z", "interval": "5" } ``` -------------------------------- ### Set Limit Order with Time in Force Source: https://github.com/traderspost/docs/blob/main/core-concepts/webhooks.md Example of a limit order with a specified time in force. Ensure the time in force value is supported by your broker. ```json { "ticker": "SPY", "action": "buy", "orderType": "limit", "limitPrice": 50.50, "timeInForce": "gtc" } ``` -------------------------------- ### Enter Bullish Signal via Webhook Source: https://github.com/traderspost/docs/blob/main/assets/options-trading.md Send a 'buy' action webhook signal to initiate a bullish trade. This will close any existing bearish positions and open a bullish one. ```json { "ticker": "SQ", "action": "buy" } ``` -------------------------------- ### Define Custom Strategy Alert Message Source: https://github.com/traderspost/docs/blob/main/learn/signal-sources/tradingview.md Example of defining the alert message directly within a Pine Script strategy using the alert_message parameter. ```javascript // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © TradersPostInc //@version=5 strategy('TradersPost Example MOMO Strategy', overlay=true) ema8 = ta.ema(close, 8) ema21 = ta.ema(close, 21) isUptrend = ema8 >= ema21 isDowntrend = ema8 <= ema21 trendChanging = ta.cross(ema8, ema21) tradersPostBuy = trendChanging and isUptrend tradersPostSell = trendChanging and isDowntrend buyAlertMessage = '{"ticker": "' + syminfo.ticker + '", "action": "buy", "price": ' + str.tostring(close) + '}' sellAlertMessage = '{"ticker": "' + syminfo.ticker + '", "action": "sell", "price": ' + str.tostring(close) + '}' if tradersPostBuy strategy.entry("Long", strategy.long, alert_message = buyAlertMessage) if tradersPostSell strategy.close("Long", when = open[0], alert_message = sellAlertMessage) ``` -------------------------------- ### Example Futures Ticker and Action Source: https://github.com/traderspost/docs/blob/main/assets/futures-trading.md This JSON object represents a futures trading signal, specifying the ticker symbol and the desired action (buy or sell). ```json { "ticker": "MNQU2025", "action": "buy" } ``` -------------------------------- ### Python Webhook Example for Complex Signal Source: https://context7.com/traderspost/docs/llms.txt Send a complex buy signal with order type, limit price, quantity, take profit, stop loss, and extras using Python. Requires a webhook URL with UUID and password. ```python # Complex signal with take profit and stop loss response = requests.post(webhook_url, json={ "ticker": "TSLA", "action": "buy", "orderType": "limit", "limitPrice": 250.00, "quantity": 10, "takeProfit": { "percent": 15 }, "stopLoss": { "type": "stop", "percent": 5 }, "extras": { "strategy": "momentum_breakout" } }) print(response.json()) ```