Custom Code Examples
The examples in this document intend to demonstrate how you can send signals to TradersPost from custom programming languages like PHP, Python, etc.

PHP

1
composer require symfony/http-client
Copied!
1
<?php
2
3
require 'vendor/autoload.php';
4
5
use Symfony\Component\HttpClient\HttpClient;
6
7
$webhookUrl = 'paste your webhook url';
8
9
$client = HttpClient::create();
10
11
$response = $client->request('POST', $webhookUrl, [
12
'json' => [
13
'ticker' => 'AMD',
14
'action' => 'buy',
15
'price' => 85.50,
16
]
17
]);
18
19
echo $response->getContent();
Copied!

Python

1
import requests
2
3
r = requests.post(
4
'paste your webhook url',
5
json={"ticker": "AMD", "action": "buy", "price": 85.50}
6
)
7
8
print(r.json())
9
Copied!

Ruby

1
require 'net/http'
2
require 'uri'
3
require 'json'
4
5
uri = URI.parse('paste your webhook url')
6
7
header = {'Content-Type': 'text/json'}
8
9
signal = {
10
ticker: 'AMD',
11
action: 'buy',
12
price: 85.50
13
}
14
15
http = Net::HTTP.new(uri.host, uri.port)
16
request = Net::HTTP::Post.new(uri.request_uri, header)
17
request.body = signal.to_json
18
19
response = http.request(request)
20
21
puts response.body
Copied!
Take these examples and combine them with a service like Polygon or Alpaca to get live market data to build your own custom strategies and use TradersPost to manage the integration with your broker.
If you are interested building your own custom automated trading strategies, give TradersPost a try and Register your free account today! If you have any questions, join our Community or email us at [email protected].
Copy link
Edit on GitHub