Coder Social home page Coder Social logo

wsm_node_api's Introduction

Wall Street Magnate Crypto API

This is a NodeJS wrapper for virtual/simulated cryptocurrency trading through Wall Street Magnate's platform.

Installation

npm install wsm-api

Quick Start

Prerequisites

You will need:
* A Wall Street Magnate account
* API keys for your account, which can be found here under the gear tab in top right of the WSM UI.





Create Client object

You need to first create a client object that has access to WSM via an access token. The async createClient() function will set this up for you given your API keys. You must await this function.

let client = await WSM.createClient(MY_API_KEY, MY_API_SECRET)

Making API Calls

All API calls return a promise so you can process the response with any standard promise handling.

let client = await WSM.createClient(MY_API_KEY, MY_API_SECRET)

//Search a symbol using await
let searchResponse = await client.searchSymbol("XRP");
console.log(`WSM's data on XRP: " ${searchResponse});

//Purchase 1 BTC on the account you are logged into with then/catch
client.positionBuy("BTC", 1)
  .then((data) => {
    console.log(data);
  })
  .catch((err) => {
    console.log(err);
  })

Demo script

You can try the include demo script, demo demo.js which will run through every function for you. This will attempt to buy 10 Ripple (~$3) for you and sell it immediately after.

node demo.js YOUR_API_KEY YOUR_API_SECRET

Functions of the WSM class

createClient(key, secret)

** Arguments **

  • key - the API key
  • secret - API secret ** Return ** A fully set up WSM client object that has your access tokens set.

This is a static method of the WSM class and how you will create your client. ** You need to await this function ** as it sets the access token for your client internally. createClient() returns the created client object back to you and all subsequent calls are class functions to this object, so be sure to save the response somewhere.

getPositionsOpen()

** Return ** Array of holdings, each as a JSON.

Returns all the open positions (the crypto you are currently holding).

getPositionsClosed()

** Return ** Array of closed positions, each as a JSON.

Returns all closed positions (sell orders).

positionBuy(symbol, quantity)

** Arguments **

  • Symbol - (string) shortened symbol of the cryptocurrency you intend to buy
  • Quantity - (int) The quantity of this coin you intend to buy ** Return ** JSON containing the information from your order. ** Note **: If you do not have sufficient cash funds in your account to execute this order, you will receive a 400 Error specifying that you do not have the funds to execute this order.

positionSell(symbol, quantity, positionId)

** Arguments **

  • Symbol - (string) shortened symbol of the coin you intend to sell
  • quantity - (int) the quantity of the coin you intend to sell (check note below)
  • positionId - (string) id of the open position you are selling from ** Return ** JSON containing the information from your order. ** Note **: This function sells from a position, so the quantity you sell must be <= the quantity in this position. For example, given 2 positions {id:1, "symbol": "ETH", "quantity": 4} and {id:2, "symbol": ETH, "quantity": 400} you must sell from one one of these positions otherwise you will receive a 400 error.
    Valid: client.positionSell("ETH", 4, 1), client.positionSell("ETH", 200, 2) Error: client.positionSell("ETH", 200, 1), client.positionSell("ETH", 404, 2) # Neither position holds enough Etherium

searchSymbol(symbol)

** Arguments **

  • Symbol - (string) shortened symbol of the coin you want to search ** Return ** JSON of search info for the coin matching the symbol.

getUsersTotals()

** Return ** JSON of account asset totals.

Reference

Some support currencies and their ticker:

  • Bitcoin - "BTC"
  • Etherium - "ETH"
  • Litecoin - "LTC"
  • Ripple - "XRP"
  • Bitcoin Cash - "BCH"
  • US Dollar - "USD"
  • Bitcoin SV - "BSV"
  • EOS -"EOS"
  • Tezos - "XTZ"
  • Stellar - "XLM"
  • TRON - "TRX"
  • Cosmos - "ATOM"
  • UNUS SED LEO - "LEO"
  • NEO - "NEO"
  • VeChain - "VET"

wsm_node_api's People

Watchers

 avatar  avatar

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.