Jump to content

Search the Community

Showing results for tags 'bid prices'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Gain Capital API FAQ
    • General Questions and Discussion

Found 1 result

  1. Hello World. I have been lurking and going over old forum posts for the past few weeks and have been able to begin to delve into the Gain API. I have a primarily php project that stores username and session keys on login and so far have gotten GET and POST url requests done, but I am still having trouble with getting a lightstreamer to subscribe to a stream for showing bid and ask prices. So far for the body I want the Bid and Ask/Offer Prices to appear at the head of a table with the code for that below here: <table> <tr> <td>Currency Selected: <?php print_r($_SESSION["currency_pair"]);?> </td> <td> <div id="marketID" data-source="lightstreamer" data-grid="stocks" name="Offer" data-field="Offer" data-item="item1"></div> </td> <td> <div id="marketID" data-source="lightstreamer" data-grid="stocks" data-item="item1" name="Bid" data-field="Bid"></div> </td> </tr> </table> As for my lightstreamer client code I have that at the bottom of the page like this: <script src="assets/js/require.js"></script> <script src="assets/js/lightstreamer.js"></script> <script> define("js/lsClient", ["LightstreamerClient", "StatusWidget"], function(LightstreamerClient, StatusWidget) { var protocolToUse = document.location.protocol != "file:" ? document.location.protocol : "http:"; var portToUse = document.location.protocol == "https:" ? "443" : "80"; // // var lsClient = new LightstreamerClient(protocolToUse + "//push.lightstreamer.com:" + portToUse, "DEMO"); lsClient.connectionSharing.enableSharing("OnlineDemoCommonConnection", "ATTACH", "CREATE"); lsClient.addListener(new StatusWidget("left", "0px", true)); lsClient.connect(); return lsClient; }); </script> <script> require(["LightstreamerClient","Subscription","StaticGrid"],function(LightstreamerClient,Subscription,StaticGrid) { //var ls = require(['lightstreamer-client']); var lsClient = new LightstreamerClient("https://push.cityindex.com", "STREAMINGALL"); lsClient.connectionDetails.setUser("<?php echo $_SESSION["username"]?>"); lsClient.connectionDetails.setPassword("<?php echo $_SESSION["login_session"]?>"); lsClient.connect(); var stocksGrid = new StaticGrid("stocks",true); stocksGrid.setAutoCleanBehavior(true,false); stocksGrid.addListener({ onVisualUpdate: function(key,info) { if (info == null) { //cleaning return; } var cold = (key.substring(4) % 2 == 1) ? "#eeeeee" : "#ddddee"; info.setAttribute("yellow", cold, "backgroundColor"); } }); var marketId = "401484317"; var stockSubscription = new Subscription("MERGE", ["PRICE."+ marketID], ["Bid", "Offer"], true); stockSubscription.addListener(stocksGrid); //stockSubscription.setItems(["PRICE.99588"]) stockSubscription.setDataAdapter("PRICES"); stockSubscription.setRequestedSnapshot("yes"); lsClient.subscribe(stockSubscription); }); </script> But whenever I run it on a local instance for testing, I receive an error in my Chrome Console stating that "IllegalArgumentException", message: "An item name cannot contain spaces". I feel like I am missing something extremely obvious but I have been trying small tweaks for hours. I would like an outside perspective to help see what I have missed.