### Install QuickFIX Python package Source: https://tradermade.com/docs/fix-api Command to install the QuickFIX library for the Python example. ```bash pip install quickfix ``` -------------------------------- ### Install TraderMade Python SDK Source: https://tradermade.com/docs/restful-api Install the TraderMade Python SDK via pip. This is the first step before using the SDK in Python. ```bash pip install tradermade ``` -------------------------------- ### Get Live Exchange Rates with Ruby (Net::HTTP) Source: https://tradermade.com/docs/api Ruby (Net::HTTP) example for the GET /live endpoint. It requests live rates for EURUSD and GBPUSD using the api_key query parameter and prints the parsed JSON response. ```ruby require 'uri' require 'net/http' require 'json' url = URI("https://marketdata.tradermade.com/api/v1/live?currency=EURUSD,GBPUSD&api_key=YOUR_SECRET_TOKEN") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) response = http.request(request) data = JSON.parse(response.body) puts data ``` -------------------------------- ### Live Exchange Rates Response (JSON) Source: https://tradermade.com/docs/api Example response for the GET /live endpoint. Shows live rates for EURUSD, GBPUSD, and UK100 with ask, bid, mid, and timestamp fields. ```json { "endpoint": "live", "quotes": [ { "ask": 1.18183, "base_currency": "EUR", "bid": 1.18181, "mid": 1.18182, "quote_currency": "USD" }, { "ask": 1.31705, "base_currency": "GBP", "bid": 1.31704, "mid": 1.31705, "quote_currency": "USD" }, { "ask": 6310.5, "bid": 6309.8, "instrument": "UK100", "mid": 6310.1499 } ], "requested_time": "Fri, 13 Nov 2020 11:42:51 GMT", "timestamp": 1605267771 } ``` -------------------------------- ### TraderMade WebSocket v2 client examples (C#, Java, PHP) Source: https://tradermade.com/docs/streaming-data-api Connect to the TraderMade WebSocket v2 endpoint wss://stream.tradermade.com/feedAdv, send a login message with the API key, then subscribe to symbols and receive quote messages. The C# example uses Websocket.Client and re-sends login on reconnection; the Java example uses java.net.http.WebSocket and subscribes after receiving login_ok; the PHP example uses WebSocket\Client and prints quote fields. ```csharp using System; using System.Threading; using System.Text.Json; using Websocket.Client; namespace TraderMadeWebSocketTest { class Program { private string streaming_API_Key = "{{api_key}}"; static void Main(string[] args) { Program prg = new Program(); prg.Initialize(); } private void Initialize() { Console.CursorVisible = false; try { var exitEvent = new ManualResetEvent(false); var url = new Uri("wss://stream.tradermade.com/feedAdv"); using (var client = new WebsocketClient(url)) { client.ReconnectTimeout = TimeSpan.FromSeconds(30); client.ReconnectionHappened.Subscribe(info => { Console.WriteLine("Reconnection happened, type: " + info.Type); string loginData = "{\"action\":\"login\",\"key\":\"" + streaming_API_Key + "\",\"fmt\":\"JSON\"}"; client.Send(loginData); }); client.MessageReceived.Subscribe(msg => { Console.WriteLine("Message received: " + msg); try { var json = JsonDocument.Parse(msg.ToString()); var root = json.RootElement; if (root.TryGetProperty("type", out var type) && type.GetString() == "login_ok") { string data = "{\"action\":\"subscribe\",\"symbols\":[\"EURUSD:QUOTE\",\"GBPUSD:QUOTE\",\"USDJPY:QUOTE\"]}"; client.Send(data); } } catch { } }); client.Start(); exitEvent.WaitOne(); } } catch (Exception ex) { Console.WriteLine("ERROR: " + ex.ToString()); } Console.ReadKey(); } } } ``` ```java package client; import java.net.URI; import java.net.http.HttpClient; import java.net.http.WebSocket; import java.util.concurrent.CompletionStage; import java.util.concurrent.CountDownLatch; public class ClientCaller { public static void main(String[] args) throws Exception { CountDownLatch latch = new CountDownLatch(100); WebSocket ws = HttpClient .newHttpClient() .newWebSocketBuilder() .buildAsync(URI.create("wss://stream.tradermade.com/feedAdv"), new WebSocketClient(latch)) .join(); latch.await(); } private static class WebSocketClient implements WebSocket.Listener { private final CountDownLatch latch; public WebSocketClient(CountDownLatch latch) { this.latch = latch; } @Override public void onOpen(WebSocket webSocket) { System.out.println("onOpen using subprotocol " + webSocket.getSubprotocol()); WebSocket.Listener.super.onOpen(webSocket); webSocket.sendText("{\"action\":\"login\",\"key\":\"{{api_key}}\",\"fmt\":\"JSON\"}", true); } @Override public CompletionStage onText(WebSocket webSocket, CharSequence data, boolean last) { System.out.println("onText received " + data); String s = data.toString(); if (s.contains("\"type\":\"login_ok\"")) { webSocket.sendText("{\"action\":\"subscribe\",\"symbols\":[\"GBPUSD:QUOTE\"]}", true); } latch.countDown(); return WebSocket.Listener.super.onText(webSocket, data, last); } @Override public void onError(WebSocket webSocket, Throwable error) { System.out.println("Bad day! " + webSocket.toString()); WebSocket.Listener.super.onError(webSocket, error); } } } ``` ```php require_once("vendor/autoload.php"); $client = new WebSocket\Client("wss://stream.tradermade.com/feedAdv"); $client->text("{\"action\":\"login\",\"key\":\"{{api_key}}\",\"fmt\":\"JSON\"}"); $message = $client->receive(); echo $message . "\n"; $client->text("{\"action\":\"subscribe\",\"symbols\":[\"GBPUSD:QUOTE\"]}"); while(true){ $message = $client->receive(); $decoded_json = json_decode($message); if(isset($decoded_json->t) && $decoded_json->t === "QUOTE"){ echo $decoded_json->t, " ", $decoded_json->s, " ", $decoded_json->ts, " ", $decoded_json->b, " ", $decoded_json->a, " ", $decoded_json->bv, " ", $decoded_json->av, "\n"; } else { echo $message . "\n"; } } ``` -------------------------------- ### WebSocket v2 connection and subscription (Python, JavaScript, Go) Source: https://tradermade.com/docs/streaming-data-api Connect to the WebSocket v2 endpoint wss://stream.tradermade.com/feedAdv, log in with your API key, and subscribe to a symbol. The Python example writes messages to webSocketTester.log and sends a login with send_ladder:true. The JavaScript example reconnects every 10 seconds on close and subscribes after login_ok. The Go example uses gorilla/websocket, sends a login message, subscribes on login_ok, and handles interrupts with a keep-alive ticker. ```python import websocket import time import os try: import thread except ImportError: import _thread as thread f = open("webSocketTester.log", "a") def on_message(ws, message): print(message) f.write(message + "\n" ) f.flush() def on_error(ws, error): print(error) def on_close(ws): print("### closed ###") def on_open(ws): def run(*args): # Inserted your active key directly into the string ws.send('{"action":"login","key":"api_key","fmt":"JSON","send_ladder":true}') ws.send('{"action":"subscribe","symbols":["GBPUSD:QUOTE"],"send_last":true}') thread.start_new_thread(run, ()) if __name__ == "__main__": ws = websocket.WebSocketApp("wss://stream.tradermade.com/feedAdv", on_message = on_message, on_error = on_error, on_close = on_close) ws.on_open = on_open ws.run_forever() ``` ```javascript const WebSocket = require('ws'); var reconnectInterval = 1000 * 10 var ws; var connect = function(){ const ws = new WebSocket('wss://stream.tradermade.com/feedAdv'); ws.on('open', function open() { ws.send("{\"action\":\"login\",\"key\":\"{{api_key}}\",\"fmt\":\"JSON\"}"); }); ws.on('close', function() { console.log('socket close : will reconnect in ' + reconnectInterval ); setTimeout(connect, reconnectInterval) }); ws.on('message', function incoming(data) { console.log(data.toString()); var json = JSON.parse(data); if (json.type === "login_ok") { ws.send("{\"action\":\"subscribe\",\"symbols\":[\"GBPUSD:QUOTE\"]}"); } }); }; connect(); ``` ```go // +build ignore package main import ( "encoding/json" "flag" "log" "net/url" "os" "os/signal" "time" "github.com/gorilla/websocket" ) func main() { flag.Parse() log.SetFlags(0) messageOut := make(chan string) interrupt := make(chan os.Signal, 1) signal.Notify(interrupt, os.Interrupt) u := url.URL{Scheme: "wss", Host: "stream.tradermade.com", Path: "/feedAdv"} log.Printf("connecting to %s", u.String()) c, resp, err := websocket.DefaultDialer.Dial(u.String(), nil) if err != nil { log.Printf("handshake failed with status %d", resp.StatusCode) log.Fatal("dial:", err) } defer c.Close() done := make(chan struct{}) err = c.WriteMessage(websocket.TextMessage, []byte(`{"action":"login","key":"{{api_key}}","fmt":"JSON"}`)) if err != nil { log.Fatal("write login:", err) } go func() { defer close(done) for { _, message, err := c.ReadMessage() if err != nil { log.Println("read:", err) return } log.Printf("recv: %s", message) var msg map[string]interface{} if json.Unmarshal(message, &msg) == nil { if msg["type"] == "login_ok" { log.Printf("Send Sub Details") messageOut <- `{"action":"subscribe","symbols":["EURUSD:QUOTE"]}` } } } }() ticker := time.NewTicker(time.Second) defer ticker.Stop() for { select { case <-done: return case m := <-messageOut: log.Printf("Send Message %s", m) err := c.WriteMessage(websocket.TextMessage, []byte(m)) if err != nil { log.Println("write:", err) return } case <-ticker.C: // keep-alive tick case <-interrupt: log.Println("interrupt") err := c.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "")) if err != nil { log.Println("write close:", err) return } select { case <-done: case <-time.After(time.Second): } return } } } ``` -------------------------------- ### Go Example for Live Rates Source: https://tradermade.com/docs/restful-api Fetches live rates for EURUSD and GBPUSD, unmarshals the JSON response, and prints the quotes. ```go package main import ( "encoding/json" "fmt" "io/ioutil" "log" "net/http" ) type data struct { Endpoint string `json:'endpoint'` Quotes []map[string]interface{} `json:'quotes'` Requested_time string `json:'requested_time'` Timestamp int32 `json:'timestamp'` } func main(){ currencies := "EURUSD,GBPUSD" api_key := "api_key" url := "https://marketdata.tradermade.com/api/v1/live?currency=" + currencies + "&api_key=" + api_key resp, getErr := http.Get(url) if getErr != nil { log.Fatal(getErr) } body, readErr := ioutil.ReadAll(resp.Body) if readErr != nil { log.Fatal(readErr) } fmt.Println(string(body)) data_obj := data{} jsonErr := json.Unmarshal(body, &data_obj) if jsonErr != nil { log.Fatal(jsonErr) } fmt.Println("endpoint", data_obj.Endpoint, "requested time", data_obj.Requested_time, "timestamp", data_obj.Timestamp) for key, value := range data_obj.Quotes { fmt.Println(key) fmt.Println("symbol", value["base_currency"]+value["quote_currency"], "bid", value["bid"], "ask", value["ask"], "mid", value["mid"]) } } ``` -------------------------------- ### JavaScript (fetch) historical endpoint Source: https://tradermade.com/docs/restful-api JavaScript example using fetch to call the historical endpoint. It sends a GET request with URL-encoded currency parameters and a date, then logs the response text. Requires an API key. ```JavaScript var requestOptions = { method : 'GET', redirect : 'follow' }; fetch( 'https://marketdata.tradermade.com/api/v1/historical?currency=EURUSD%2CGBPUSD&date=2019-10-09&api_key=api_key', requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log( 'error', error)); ``` -------------------------------- ### JavaScript (jQuery) historical endpoint Source: https://tradermade.com/docs/restful-api JavaScript example using jQuery's $.ajax to call the historical endpoint. It configures a GET request with a timeout of 0 and logs the response. Requires an API key. ```JavaScript var settings = { "url": "https://marketdata.tradermade.com/api/v1/historical?currency=EURUSD%2CGBPUSD&date=2019-10-09&api_key=api_key", "method": "GET", "timeout": 0, }; $.ajax(settings).done(function (response) { console.log(response); }); ``` -------------------------------- ### Python Example for Live Rates Source: https://tradermade.com/docs/restful-api Uses the requests library to fetch live exchange rates from the TraderMade API. Requires an API key. ```python import requests url = "https://marketdata.tradermade.com/api/v1/live" querystring = {"currency": "USDJPY", "api_key": "api_key"} response = requests.get(url, params=querystring) print(response.json()) ``` -------------------------------- ### Python QuickFIX client main() Source: https://tradermade.com/docs/fix-api Python client using QuickFIX to connect to TraderMade FIX server. It loads configuration, starts a SocketInitiator, waits for initial data, and handles logout. Requires a client.cfg file with session settings. ```python def wait_for_first_data(self, timeout_ms): """ Blocking call that waits for the first market data message to be received. Returns True if data was received, False otherwise. """ timeout_seconds = timeout_ms / 1000.0 print(f"Waiting up to {timeout_seconds} seconds for initial market data...") return self.first_data_event.wait(timeout_seconds) def main(): if len(sys.argv) < 2: print("usage: python market_data_client.py client.cfg") sys.exit(2) try: # 1. Load configuration and setup application components settings = fix.SessionSettings(sys.argv[1]) application = MarketDataApp(settings) store_factory = fix.FileStoreFactory(settings) log_factory = fix.FileLogFactory(settings) # 2. Initialize the SocketInitiator # Note: Threading is managed internally by the QuickFIX library initiator = fix.SocketInitiator(application, store_factory, settings, log_factory) # 3. Start the initiator (connects and attempts logon) initiator.start() # 4. Optional Health Check: Wait for initial data if not application.wait_for_first_data(60000): print("Warning: Timed out waiting for initial market data.") print("Running... press Enter to unsubscribe and logout.") sys.stdin.readline() # 5. Cleanup: Unsubscribe and Logout application.sendUnsubscribeAll() time.sleep(0.3) # Give time for unsubscribe message to be processed # Logout the session sids = settings.getSessions() if sids: session = fix.Session.lookupSession(sids[0]) if session: session.logout("Client exit") print("Sent Logout message.") initiator.stop() except fix.ConfigError as e: print(f"Configuration Error: {e}") sys.exit(1) except Exception as e: print(f"Fatal error: {e}") sys.exit(1) if __name__ == '__main__': main() ``` -------------------------------- ### R Example for Live Rates Source: https://tradermade.com/docs/restful-api Uses httr and jsonlite to fetch live rates for EURUSD and GBPUSD and convert the response to a data frame. ```r library (httr) library (jsonlite) req <- "https://marketdata.tradermade.com/api/v1/live?currency=EURUSD,GBPUSD&api_key=api_key" data_raw <- GET(url = req) data_text = content(data_raw, "text", encoding = "UTF-8") data_json = fromJSON(data_text, flatten=TRUE) dataframe = as.data.frame(data_json) dataframe ``` -------------------------------- ### C# live endpoint with HttpClient Source: https://tradermade.com/docs/restful-api C# example using HttpClient to call the live endpoint. It deserializes the JSON response with Newtonsoft.Json and prints each quote's base/quote currency and mid price. Requires an API key in the URL. ```C# using System; using System.Net.Http; using Newtonsoft.Json; namespace crest { class Program { static async System.Threading.Tasks.Task Main(string[] args) { HttpClient client = new HttpClient(); HttpResponseMessage response = await client.GetAsync("https://marketdata.tradermade.com/api/v1/live?currency=EURUSD,GBPUSD&api_key=api_key"); response.EnsureSuccessStatusCode(); var responseBody = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject(responseBody); foreach (var item in result.quotes) { Console.WriteLine(" Result: " + item.base_currency + "/" + item.quote_currency + " " + item.mid); } } public class CurrencyDetails { public string endpoint { get; set; } public quotes[] quotes { get; set; } public string requested_time { get; set; } public long timestamp { get; set; } } public class quotes { public double ask { get; set; } public double bid { get; set; } public string base_currency { get; set; } public double mid { get; set; } public string quote_currency { get; set; } } } } ``` -------------------------------- ### GET /live Source: https://tradermade.com/docs/api Retrieve real-time exchange rates for one or more currency pairs and/or CFDs. ```APIDOC ## GET /live ### Description Retrieve real-time exchange rates for one or more currency pairs and/or CFDs. ### Method GET ### Endpoint /live ### Parameters #### Query Parameters - **currency** (string) - Required - A single instrument (e.g., `EURUSD` or `UK100`) or a comma-separated list (e.g., `EURUSD,GBPUSD,UK100`). ### Request Example ``` https://marketdata.tradermade.com/api/v1/live?currency=EURUSD,GBPUSD&api_key=YOUR_SECRET_TOKEN ``` ### Response #### Success Response (200) - **endpoint** (string) - The endpoint name. - **quotes** (array) - List of quote objects. - **ask** (number) - Ask price. - **base_currency** (string) - Base currency (for forex pairs). - **bid** (number) - Bid price. - **mid** (number) - Mid price. - **quote_currency** (string) - Quote currency (for forex pairs). - **instrument** (string) - Instrument name (for CFDs). - **requested_time** (string) - Time of request in GMT. - **timestamp** (integer) - Unix timestamp. #### Response Example ``` { "endpoint": "live", "quotes": [ { "ask": 1.18183, "base_currency": "EUR", "bid": 1.18181, "mid": 1.18182, "quote_currency": "USD" }, { "ask": 1.31705, "base_currency": "GBP", "bid": 1.31704, "mid": 1.31705, "quote_currency": "USD" }, { "ask": 6310.5, "bid": 6309.8, "instrument": "UK100", "mid": 6310.1499 } ], "requested_time": "Fri, 13 Nov 2020 11:42:51 GMT", "timestamp": 1605267771 } ``` #### Error Responses - **401** - Invalid or missing API key (HTTP 200 with error payload). - **429** - Rate limit exceeded (HTTP 429). ``` -------------------------------- ### JavaScript (axios) live endpoint Source: https://tradermade.com/docs/restful-api JavaScript example using axios to call the live endpoint. It logs the full response and then the second quote object. Requires an API key in the URL. ```JavaScript const axios = require('axios'); axios.get('https://marketdata.tradermade.com/api/v1/live?currency=EURUSD,GBPUSD,UK100&api_key=api_key') .then(response => { console.log(response.data); console.log(response.data.quotes[1]); }) .catch(error => { console.log(error); }); ``` -------------------------------- ### Example Error Response (400) Source: https://tradermade.com/docs/restful-api Shows the JSON error response returned for a 400 error, including the details of the validation failure. ```json // 400 will return error which includes the details of the error { "errors": { "date": "YYYY-MM-DD time data '2019-10-' does not match format '%Y-%m-%d'" }, "message": "Input payload validation failed" } ``` -------------------------------- ### FIX client.cfg configuration Source: https://tradermade.com/docs/fix-api Example client.cfg configuration file for the FIX client. Replace the placeholders for Username, Password, SenderCompID, and optionally set RefreshOnLogin. The file is obtained from the dashboard when registering for a trial. ```ini [DEFAULT] ApplicationID=FixClientApp ConnectionType=initiator ReconnectInterval=5 FileStorePath=store/TMS_Target_xxxx/ FileLogPath=log/ StartTime=00:00:00 EndTime=23:59:59 HeartBtInt=30 UseDataDictionary=Y DataDictionary=./spec/FIX44.xml Username= Password= Symbols=GBPUSD [SESSION] ResetOnLogon=Y BeginString=FIX.4.4 SocketConnectPort=5000 SocketConnectHost=marketdata.tradermade.com SenderCompID= TargetCompID=TRADERMADE_M1 [LOGGING] LogFilePath=/var/log/fix-client.log LogLevel=INFO ``` -------------------------------- ### GET /api/v1/live Source: https://tradermade.com/docs/restful-api Provides live sub-second data for over 4200+ currency pairs and 200+ CFDs. The response includes bid, ask, and mid prices for each requested instrument. ```APIDOC ## GET /api/v1/live ### Description Provides live sub-second data for over 4200+ currency pairs and 200+ CFDs. The response includes bid, ask, and mid prices for each requested instrument. ### Method GET ### Endpoint https://marketdata.tradermade.com/api/v1/live ### Parameters #### Query Parameters - **currency** (string) - Required - Comma-separated list of currency pairs or CFDs, e.g., "EURUSD,GBPUSD". - **api_key** (string) - Required - API key for authentication. ### Response #### Success Response (200) - **endpoint** (string) - The endpoint name, e.g., "live". - **quotes** (array) - List of quote objects. - **ask** (number) - Ask price. - **bid** (number) - Bid price. - **mid** (number) - Mid price. - **base_currency** (string) - Base currency (for currency pairs). - **quote_currency** (string) - Quote currency (for currency pairs). - **instrument** (string) - Instrument name (for CFDs). - **requested_time** (string) - Timestamp of the request. - **timestamp** (integer) - Unix timestamp. #### Response Example { "endpoint": "live",". "quotes": [". {". "ask": 1.18183,". "base_currency": "EUR",". "bid": 1.18181,". "mid": 1.18182,". "quote_currency": "USD"". },". {". "ask": 1.31705,". "base_currency": "GBP",". "bid": 1.31704,". "mid": 1.31705,". "quote_currency": "USD"". },". {". "ask": 6310.5,". "bid": 6309.8,". "instrument": "UK100",". "mid": 6310.1499". }". ],". "requested_time": "Fri, 13 Nov 2020 11:42:51 GMT",". "timestamp": 1605267771".} ``` -------------------------------- ### PHP cURL Example for Convert Source: https://tradermade.com/docs/restful-api Uses cURL in PHP to call the convert endpoint, converting 1000 EUR to USD. Requires an API key. ```php $curl = curl_init(); curl_setopt_array( $curl, array( CURLOPT_PORT => "443", CURLOPT_URL => "https://marketdata.tradermade.com/api/v1/convert?from=EUR&to=USD&amount=1000&api_key=api_key", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ``` -------------------------------- ### C++ historical endpoint with libcurl Source: https://tradermade.com/docs/restful-api C++ example using libcurl to call the historical endpoint. It sets a write callback, a 10-second timeout, and prints the response or an error with the HTTP status code. Requires an API key. ```C++ #include #include #include static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp) { size_t totalSize = size * nmemb; std::string* buffer = static_cast(userp); buffer->append(static_cast(contents), totalSize); return totalSize; } int main() { CURL* curl; CURLcode res; std::string readBuffer; long http_code = 0; curl_global_init(CURL_GLOBAL_DEFAULT); curl = curl_easy_init(); if(curl) { std::string base_url = "https://www.tradermade.com/api/v1/historical"; std::string params = "?currency=EURUSD,GBPUSD&date=2025-10-10&api_key=TRADERMADE_API_KEY"; std::string full_url = base_url + params; curl_easy_setopt(curl, CURLOPT_URL, full_url.c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10L); res = curl_easy_perform(curl); if(res != CURLE_OK) { std::cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << std::endl; } else { curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code); if(http_code == 200) { std::cout << "Response :" << readBuffer << std::endl; } else { std::cerr << "Error :" << http_code << " - " << readBuffer << std::endl; } } curl_easy_cleanup(curl); } curl_global_cleanup(); return 0; } ``` -------------------------------- ### GET /api/v1/convert Source: https://tradermade.com/docs/restful-api Converts an amount from one currency to another in real time. Returns the converted total and the exchange rate. ```APIDOC ## [GET] /api/v1/convert ### Description Converts an amount from one currency to another in real time. Returns the converted total and the exchange rate. ### Method GET ### Endpoint https://marketdata.tradermade.com/api/v1/convert ### Parameters #### Query Parameters - **from** (string) - Required - The currency to convert from, e.g., EUR. - **to** (string) - Required - The currency to convert to, e.g., GBP. - **amount** (number) - Required - The amount to convert. - **api_key** (string) - Required - Your API key. ### Request Example https://marketdata.tradermade.com/api/v1/convert?api_key=api_key&from=EUR&to=GBP&amount=1000 ### Response #### Success Response (200) - **base_currency** (string) - The base currency. - **quote** (number) - The exchange rate. - **quote_currency** (string) - The quote currency. - **requested_time** (string) - Timestamp of the request. - **timestamp** (number) - Unix timestamp. - **total** (number) - The converted amount. #### Response Example { "base_currency": "EUR",".quote": 0.861, "quote_currency": "GBP",".requested_time": "Thu, 31 Oct 2019 14:46:35 GMT",".timestamp": 1572533196, "total": 861 } ``` -------------------------------- ### GET /api/v1/live_crypto_list Source: https://tradermade.com/docs/restful-api Retrieves a list of available cryptocurrencies for the live endpoint. Append your api_key to the endpoint to access the JSON object containing all available crypto codes. ```APIDOC ## GET /api/v1/live_crypto_list ### Description Retrieves a list of available cryptocurrencies for the live endpoint. Append your api_key to the endpoint to access the JSON object containing all available crypto codes. ### Method GET ### Endpoint https://marketdata.tradermade.com/api/v1/live_crypto_list?api_key=api_key ### Parameters #### Query Parameters - **api_key** (string) - Required - Your API key. ### Request Example https://marketdata.tradermade.com/api/v1/live_crypto_list?api_key=api_key ### Response #### Success Response (200) - **available_currencies** (object) - A dictionary mapping cryptocurrency codes (e.g., ADA, BTC) to their full names. - **endpoint** (string) - The endpoint name, e.g., "live_crypto". #### Response Example { "available_currencies": { "ADA": "Cardano", "ATOM": "Atom", "AVAX": "Avalanche", "AXS": "Axis infinity", "BCH": "Bitcoin Cash", "BNB": "Binance Coin", "BTC": "Bitcoin", "BTG": "Bitcoin Gold", "BUSD": "Binance USD", "DAI": "DAI", "DASH": "Dashcoin", "DOGE": "DogeCoin", "DOT": "Polkadot", "EGLD": "Elrond Egold", "ENJ": "ENJ", "EOS": "EOS Platform", "ETC": "Ethereum Classic", "ETH": "Ethereum", "FIL": "Filecoin", "FLOW": "Flow", "FTM": "Fantom USD", "FTT": "FTX Token", "GALA": "Gala", "HBAR": "Hbar", "HNT": "Helium", "ICP": "Internet Computer Price", "LINK": "Chainlink", "LRC": "Loopring", "LTC": "Litecoin", "LUNA": "Luna", "MANA": "Decentraland", "MATIC": "Matic", "NEAR": "Near", "NEO": "NEO", "ROSE": "Rose", "SAND": "Sandbox", "SHIB": "Shiba inu", "SOL": "Solana", "THETA": "Theta", "TRX": "Tron", "UNI": "Uniswap", "USDT": "Tether", "UST": "Terra USD", "VET": "Vechain",". "XLM": "Stellar", "XMR": "Monero", "XRP": "Ripple", "XTZ": "Tezos"". }, "endpoint": "live_crypto"". } ``` -------------------------------- ### GET /api/v1/live_currencies_list Source: https://tradermade.com/docs/restful-api Retrieves a list of available currencies for the live and convert endpoints. Append your api_key to the endpoint to access the JSON object containing all available currency codes. ```APIDOC ## GET /api/v1/live_currencies_list ### Description Retrieves a list of available currencies for the live and convert endpoints. Append your api_key to the endpoint to access the JSON object containing all available currency codes. ### Method GET ### Endpoint https://marketdata.tradermade.com/api/v1/live_currencies_list?api_key=api_key ### Parameters #### Query Parameters - **api_key** (string) - Required - Your API key. ### Request Example https://marketdata.tradermade.com/api/v1/live_currencies_list?api_key=api_key ### Response #### Success Response (200) - **available_currencies** (object) - A dictionary mapping currency codes (e.g., AED, USD) to their full names. - **endpoint** (string) - The endpoint name, e.g., "live_currencies". #### Response Example { "available_currencies": { "AED": "UAE Dirham", "ARS": "Argentine Peso", "AUD": "Australian Dollar", "BHD": "Bahraini Dinar", "BRL": "Brazilian Real", "CAD": "Canadian Dollar", "CHF": "Swiss Franc", "CLP": "Chilean Peso", "CNY": "Chinese Yuan", "COP": "Colombian Peso", "CZK": "Czech Koruna", "DKK": "Danish Krone", "EUR": "Euro", "GBP": "British Pound Sterling", "HKD": "Hong Kong Dollar", "HRK": "Croatian Kuna", "HUF": "Hungarian Forint", "IDR": "Indonesian Rupiah", "ILS": "Israeli New Sheqel", "INR": "Indian Rupee", "ISK": "Icelandic Krona", "JPY": "Japanese Yen", "KRW": "South Korean Won", "KWD": "Kuwaiti Dinar", "MAD": "Moroccan Dirham", "MXN": "Mexican Peso", "MYR": "Malaysian Ringgit", "NGN": "Nigerean Naira", "NOK": "Norwegian Krone", "NZD": "New Zealand Dollar", "OMR": "Omani Rial", "PEN": "Peruvian Nuevo Sol", "PHP": "Philippine Peso", "PLN": "Polish Zloty", "RON": "Romanian Leu", "RUB": "Russian Ruble", "SEK": "Swedish Krona", "SGD": "Singapore Dollar", "THB": "Thai Baht", "TRY": "Turkish Lira", "TWD": "Taiwanese Dollar", "USD": "US Dollar", "VND": "Vietnamese Dong", "ZAR": "South African Rand" }, "endpoint": "live_currencies" } ``` -------------------------------- ### C++ QuickFIX client main() Source: https://tradermade.com/docs/fix-api Main entry point for a QuickFIX C++ client. It parses the configuration file, starts the initiator, waits for the first market data message (with a 60-second timeout), then on Enter it unsubscribes, logs out, and stops. Requires a valid client.cfg path as the first argument. ```cpp int main(int argc, char** argv) { if (argc < 2) { std::cerr << "usage: " << argv[0] << " client.cfg"; return 2; } try { FIX::SessionSettings settings(argv[1]); App app(settings); FIX::FileStoreFactory store(settings); FIX::FileLogFactory log(settings); FIX::SocketInitiator initiator(app, store, settings, log); initiator.start(); app.waitFirstDataMs(60000); // optional health check std::cout << "Running… press Enter to unsubscribe and logout." << std::endl; std::cin.get(); app.sendUnsubscribeAll(); auto sids = settings.getSessions(); if (!sids.empty()) if (auto* s = FIX::Session::lookupSession(*sids.begin())) s->logout("Client exit"); std::this_thread::sleep_for(std::chrono::milliseconds(300)); initiator.stop(); return 0; } catch (const std::exception& e) { std::cerr << "fatal: " << e.what() << "\n"; return 1; } } ``` -------------------------------- ### GET /api/v1/timeseries Source: https://tradermade.com/docs/restful-api Returns time series data for a specified currency pair between start and end dates. ```APIDOC ## GET /api/v1/timeseries ### Description Returns time series data for a specified currency pair between start and end dates. ### Method GET ### Endpoint https://marketdata.tradermade.com/api/v1/timeseries ### Parameters #### Query Parameters - **start_date** (string) - Required - Start date in YYYY-MM-DD format. - **end_date** (string) - Required - End date in YYYY-MM-DD format. - **currency** (string) - Required - Currency pair, e.g., "EURUSD". - **api_key** (string) - Required - API key for authentication. ### Response #### Success Response (200) - **endpoint** (string) - The endpoint name. - **quotes** (array) - List of time series data objects. - **date** (string) - Date. - **open** (number) - Open price. - **high** (number) - High price. - **low** (number) - Low price. - **close** (number) - Close price. #### Response Example { "endpoint": "timeseries", "quotes": [ { "date": "2025-04-10", "open": 1.1, "high": 1.2, "low": 1.0, "close": 1.15 } ] } ``` -------------------------------- ### Java QuickFIX/J market data client main Source: https://tradermade.com/docs/fix-api Java client main method that starts a QuickFIX/J initiator, waits for the first market data tick, and handles unsubscribe and graceful logout on Enter. Requires a configuration file path as the first argument; exits with code 2 on missing argument and code 1 on fatal errors. ```java // Wait up to ms for first tick public boolean waitFirstDataMs(long ms) { try { return firstData.await(ms, java.util.concurrent.TimeUnit.MILLISECONDS); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); return false; } } // ---- Main ---- public static void main(String[] args) { if (args.length < 1) { System.err.println("usage: java MdClient client.cfg"); System.exit(2); } String cfg = args[0]; try { SessionSettings settings = new SessionSettings(cfg); Application app = new MdClient(settings); MessageStoreFactory store = new FileStoreFactory(settings); LogFactory log = new FileLogFactory(settings); Initiator initiator = new SocketInitiator(app, store, settings, log); initiator.start(); // Optional health check if (app instanceof MdClient) ((MdClient) app).waitFirstDataMs(60000); System.out.println("Running… press Enter to unsubscribe and logout."); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br.readLine(); // Unsubscribe and logout try { ((MdClient) app).sendUnsubscribeAll(); } catch (Exception e) { System.out.println("unsubscribe error: " + e.getMessage()); } // Graceful logout of first session @SuppressWarnings("unchecked") Iterator it = settings.getSessions().iterator(); if (it.hasNext()) { SessionID sid = it.next(); Session s = Session.lookupSession(sid); if (s != null) s.logout("Client exit"); } Thread.sleep(300); initiator.stop(); System.exit(0); } catch (Exception e) { System.err.println("fatal: " + e.getMessage()); System.exit(1); } } } ``` -------------------------------- ### QuickFIX/J client configuration (FIX.4.4) Source: https://tradermade.com/docs/fix-api Client configuration file for the QuickFIX/J market data client. Replace SocketConnectionHost, SocketConnectionPort, SenderCompID, TargetCompID, Username, and Password with your credentials; optionally set RefreshOnLogin. The Symbols line defaults to EURUSD and can be commented out to use the alternative symbol list. ```ini [default] ApplicationID=client2 FileStorePath=messagestore/messages/ ConnectionType=initiator StartTime=00:01:00 EndTime=23:59:00 HeartBtInt=30 UseDataDictionary=Y DataDictionary=FIX44.xml ValidateUserDefinedFields=N ValidateIncomingMessage=N RefreshOnLogon=Y ResetOnLogon=Y [session] BeginString=FIX.4.4 SocketConnectHost=SOCKET_CONNECTION_HOST SocketConnectPort=SOCKET_CONNECTION_PORT SenderCompID=SENDER_COMP_ID TargetCompID=CLIENT_COMP_ID ​ [SSL] #SocketUseSSL=Y #SocketKeyStore=KEYSTORE_NAME #SocketKeyStorePassword=KEYSTORE_PASSWORD [Logging] FileLogPath=log ScreenLog=N ScreenLogShowIncoming=N ScreenLogShowOutgoing=N ScreenLogShowHeartBeats=N [Account] Username=USERNAME Password=PASSWORD Symbols=EURUSD #Symbols=USDCAD USDCZK USDDKK USDHUF USDILS USDNOK USDPLN USDSGD USDTHB ```