API Keys
Market Data
If you want to view price charts and/or add MFE prices automatically, you need to get the data from a market data provided. Currently, TradeNote provides support for adding Polygon and Databento. You can add your API key(s) on the settings page.
- Polygon has an interesting free tier where you can make up to 5 api call per minute. It works with stocks and with options.
- Databento also provides data for futures. After trying numerous market data providers, Databento is one of my favorits. I offers a generous 150$ credit on signup and/or very intersting pricing.
TradeNote API
TradeNote provides an API so that you can setup an auto import of your trades. Please note that this a very experimental feature AND unfortunately, I will not be able to provide support on how to make a POST request.
POST /api/trades
Base url: < your tradenote url >
The trades endpoint allows you to import trade executions directly to the database.
Headers
- "api-key" (string): your TradeNote API key from your settings page.
Request Body
- "data" (array): contains all the executions, with same attributes and value format as the export file.
- "selectedBroker" (string): your broker name (example: "tradeZero").
- "uploadMfePrices" (bool): true or false if you want to upload MFE prices automatically. Requires you have added the Polygon API key.
Example The following code example written in Python was provided by a community member for your convienance.
python3
import requests
import csv
# Define the base URL and API key
base_url = "<your_url>/api/trades"
api_key = "<your_api_key>"
# Prepare the data in the required format
# Example CSV parsing, assuming you've already read the file into `csv_data`
csv_data = [
{
"Account": "TradingView",
"T/D": "10/13/2023",
"S/D": "10/13/2023",
"Currency": "USD",
"Type": "0",
"Side": "BC",
"Symbol": "C:USDJPY",
"Qty": 106904,
"Price": 149.679,
"Exec Time": "16:10:44",
"Comm": 0,
"SEC": 0,
"TAF": 0,
"NSCC": 0,
"Nasdaq": 0,
"ECN Remove": 0,
"ECN Add": 0,
"Gross Proceeds": -16001283.82,
"Net Proceeds": -16001283.82,
"Clr Broker": "",
"Liq": "",
"Note": ""
},
# Add more trade executions as needed
{
"Account": "TradingView",
"T/D": "10/13/2023",
"S/D": "10/13/2023",
"Currency": "USD",
"Type": "0",
"Side": "SS",
"Symbol": "C:USDJPY",
"Qty": 106904,
"Price": 149.641,
"Exec Time": "16:01:48",
"Comm": 0,
"SEC": 0,
"TAF": 0,
"NSCC": 0,
"Nasdaq": 0,
"ECN Remove": 0,
"ECN Add": 0,
"Gross Proceeds": 15997221.46,
"Net Proceeds": 15997221.46,
"Clr Broker": "",
"Liq": "",
"Note": ""
},
{
"Account": "TradingView",
"T/D": "10/15/2023",
"S/D": "10/15/2023",
"Currency": "USD",
"Type": "0",
"Side": "BC",
"Symbol": "C:USDJPY",
"Qty": 106904,
"Price": 149.679,
"Exec Time": "15:10:44",
"Comm": 0,
"SEC": 0,
"TAF": 0,
"NSCC": 0,
"Nasdaq": 0,
"ECN Remove": 0,
"ECN Add": 0,
"Gross Proceeds": -16001283.82,
"Net Proceeds": -16001283.82,
"Clr Broker": "",
"Liq": "",
"Note": ""
},
# Add more trade executions as needed
{
"Account": "TradingView",
"T/D": "10/15/2023",
"S/D": "10/15/2023",
"Currency": "USD",
"Type": "0",
"Side": "SS",
"Symbol": "C:USDJPY",
"Qty": 106904,
"Price": 149.641,
"Exec Time": "15:01:48",
"Comm": 0,
"SEC": 0,
"TAF": 0,
"NSCC": 0,
"Nasdaq": 0,
"ECN Remove": 0,
"ECN Add": 0,
"Gross Proceeds": 15997221.46,
"Net Proceeds": 15997221.46,
"Clr Broker": "",
"Liq": "",
"Note": ""
},
]
# Prepare the request body
payload = {
"data": csv_data,
"selectedBroker": "template"
}
# Set headers including the API key
headers = {
"api-key": api_key,
"Content-Type": "application/json"
}
# Send POST request
response = requests.post(base_url, json=payload, headers=headers)
# Check the response status
if response.status_code == 200:
print("Trades successfully imported!")
else:
print(f"Failed to import trades: {response.status_code}, {response.text}")