Giter Club home page Giter Club logo

openapi-samples-js's Introduction

OpenAPI JavaScript Sample Repository

This repository contains sample files demonstrating OpenAPI interactions in JavaScript that can be run in the browser. Each of the included samples is designed as standalone HTML with vanilla JS and no dependencies.

To try these samples yourself, download/clone this repo and load the HTML files locally on your browser. You can alternatively navigate to this interactive page to select the samples hosted directly online.

Requirements

Samples run against Saxo's simulation environment and require an access token in order to function. Saxo provides 24-hour tokens on the Developer Portal, which is the easiest way to get started with the samples provided here. An account is required to generate a token, which can be created for free.

Table of Contents

  1. Authentication
  2. Basics
  3. Instruments
  4. Order Placement
  5. Portfolio
  6. Account History
  7. Using websockets

Sample Apps

Basic Price Streamer: Shows how to display prices for instruments and update them when an update is broadcasted. The connection health is monitored.

Basic Order Manager: A Vue.js app that runs in the browser, pulls out open orders of the logged-in client and displays them in a Vuetify table with sorting and filtering functionality. Includes a simple order blotter and an implementation of OAuth implicit flow to authenticate with the OpenAPI.

Suggestions? Comments? Reach us via Github or [email protected].

openapi-samples-js's People

Contributors

acalsxo avatar afmhenry avatar ayxue avatar basaxo avatar basgroot avatar dependabot[bot] avatar f3ng3r avatar gidven avatar michax avatar mortentobiasnielsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openapi-samples-js's Issues

Failed Open stream:Invalid argument

The first authorization step is correct but when you try to execute the second step (redirect) to obtain the token, it gives an error "failed to open stream: Invalid arguement" "X-Correlation header (for troubleshooting with Saxo): Null.
In the server-config file I have changed the Key and the secret

authentication sample does not seems to work

I'm trying to run JS Code Flow Sample with SIM environment. On the Step 2 when I click on 'Get token with NodeJS' I get:

Error with status 401 Unauthorized
Unauthorized: Unauthorized

X-Correlation header (for troubleshooting with Saxo): null

Any idea how to fix this?

Replacement for "Trade On Quote" feature (for Currency Option)

Describe the bug
I understand that "Trade On Quote" feature has been disabled recently.
rQ = tr.positions.PositionByQuote(data=dataOrdQuote)
Can you please suggest what is alternate for this functionality.
I tried to see feasibility of "Multi Leg Order", but it seems like it does not support "Currency Option Trades" (it needs uic)

Please suggest alternate.

Additional context
Add any other context about the problem here.

SOLVED: Instruments Lookup Failing with 404 in Live Environment (works in Simulation environment)

Describe the bug

OpenAPI 'Instruments Lookup' Failing with 404 in Live Environment (works perfectly in Simulation environment)

To Reproduce

  1. When hitting the SIM endpoint for instrument lookup (using Postman to verify):

https://gateway.saxobank.com/sim/openapi/ref/v1/instruments?$top=5&exchangeId=ASX&keywords=PLL&assetTypes=stock&accountKey={mySimulatorAccountKey}

I get a result:

{
    "Data": [
        {
            "AssetType": "Stock",
            "CurrencyCode": "AUD",
            "Description": "Piedmont Lithium Ltd",
            "ExchangeId": "ASX",
            "GroupId": 12489,
            "Identifier": 7671883,
            "IssuerCountry": "US",
            "SummaryType": "Instrument",
            "Symbol": "PLL:xasx",
            "TradableAs": [
                "Stock"
            ]
        }
    ]
}

X-Correlation: 44df3b1e3519427895b4a4c02aaa5d50#2958#82ee4235-f409-49f3-af65-3d10abee9fc1#82

  1. When I hit the same endpoint in the LIVE environment:

https://gateway.saxobank.com/openapi/ref/v1/instruments?$top=5&exchangeId=ASX&keywords=PLL&assetTypes=stock&accountKey={{myLIVEAccountKey}}

I get an HTTP 404/Not Found Response

X-Correlation: 7b6ffad83f8a4962a7e74477f5dea850#824#addb4598-31af-4455-83c6-6808d2e1b532#352

Please note: I have the correct and valid access tokens used in both. I know they are correct and valid because if I use the wrong ones, or they're expired, I get an expected 401/Unauthorized.

Expected behavior

I expected the LIVE account instrument lookup URL to work as described in your documentation. It doesn't.

Screenshots

Simulator: working:

image

Live: Has the LIVE api endpoint and the LIVE account key and access token, but otherwise identical to the sim one:

image

As you can see, the only difference between those urls is the /sim/ slug and the client account keys

Desktop (please complete the following information):

  • OS - Windows 10 (also fails on mac and linux, it's not my OS causing the problem)
  • Browser: Postman (to verify) but initially found using C# client.

Additional context
I've tried various combinations of adding/removing / at the end, casing of query-string parameters, ordering of query-string parameters. Whatever I do works perfectly in the simulation environment, but the live one fails with a 404 Every. Single. Time.

Please can you update the documentation to reflect the actual URL/endpoint we should be using for the LIVE instrument lookup? Or if it's not available any more, can you indicate it's obsolete/deprecated (and perhaps suggest how else we might go about doing an instrument lookup). Is there a versioning difference? Or, alternatively, fix the LIVE endpoint so it doesn't 404?

Thanks :)

Get Token_access failing

Hello,

Thx vm for thoses samples. very useful.
In OAuth2 Code Flow example
After redirect, get_code works fine but get_token fails with the following error:
localhost/:1 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0

Any idea why?
PS: I've used the live gateway in this test with correct Appkeys and links

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.