npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

enigma-securities

v1.0.1

Published

A NodeJs library for the Enigma Securities API

Downloads

4

Readme

npm version

Enigma Securities API

A NodeJs library for trading with the Enigma Securities platform

For more information on the firm, please see: https://enigma-securities.io

Install

The library is available from npmjs.com and can be installed in the usual manner:

$ npm install enigma-securities

Use

The module exports a factory so that multiple connections can be managed and thus connection objects must be created:

// fetch factory
const Enigma = require('enigma-securities')

// grab credentials from the environment

var {ENIGMA_USERNAME, ENIGMA_PASSWORD} = process.env;

// create a connection object using credentials

const prod = new Enigma(ENIGMA_USERNAME, ENIGMA_PASSWORD)

// to create a connection to the development sandbox

const dev = new Enigma(ENIGMA_USERNAME, ENIGMA_PASSWORD, 'test')

// the constructor will pick up the credentials from the environment
// so you need not specify them

const prod = new Enigma()
const dev = new Enigma('test')

API

The following methods are supported:

products

Lists the products available in the platform. The return value is an object with crosses for keys and product ids for values. It will generally look like this:

{
   "BTC/EUR": "1",
   "BTC/USD": "2",
   "BTC/CAD": "3"
}

price(id)

  • id: the product id returned from the products() method

The method returns the spot, bid and ask prices for the product. The returned object looks more or less like this:

{
   "base": "BTC",
   "currency": "EUR",
   "spot": "4551.29",
   "bid": "4528.5336",
   "ask": "4574.0465" 
}

buy(id, qty, type)

sell(id, qty, type)

  • id: the product id received from products
  • type: specifies the metric of the quantity. can be one of: fiat or crypto. if left unspecified, defaults to fiat
  • qty: the amount for the trade

Use these methods to buy or sell a given asset

trade(id, op, qty, type)

  • op: one of: buy or sell

An interface useful for when the type of operation must be deduced from data. Allows writing simpler code:

// you can write
prod.trade(1, bal < 0 ? 'sell' : 'buy', 100)

// instead of
if (bal < 0)
   prod.sell(1, 100)
else
   prod.buy(1, 100)

trades [intraday]

Returns an array of trades performed for the account. If a true value is passed to the method, only intraday trades are returned. The output looks like this:

[

]

Notes

If credentials are neither provided via the environment, nor explicitly, the factory constructor will throw an exception on load:

Testing

A test suite is available and comprises primarily integration tests, so you can use it to make sure you can reach the platform. To run, first set the environment variables shown below with your credentials and then run the tests:

$ export ENIGMA_USER=xxxx
$ export ENIGMA_PASS=xxxx
$ npm test

Licence

MIT

Support

For support post an issue on Github or reach out to me on Telegram. My username is @ekkis