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

zomma.js

v1.0.11

Published

Zomma Option API client library for trading.

Downloads

98

Readme

Zomma Option API

The Zomma Option API is a client library for trading options on the Zomma platform. It provides an easy-to-use interface for interacting with the Zomma API, allowing you to fetch market data, retrieve account information, and place buy and sell orders.

Installation

To install the Zomma Option API library, use the following command:

npm install zomma.js

Usage

Importing the Library

To use the Zomma Option API library in your project, you need to import it first:

import Zomma from 'zomma.js';

Initializing the Zomma Instance

Before you can start using the library, you need to initialize a Zomma instance with your private key and the desired network (mainnet or testnet):

const zomma = new Zomma({
  privateKey: 'YOUR_PRIVATE_KEY',
  network: 'mainnet', // or 'testnet' for the test network
});

await zomma.initialize();

Fetching Market Data

You can fetch the available markets using the getMarkets method:

const markets = await zomma.getMarkets();
console.log(markets);

Retrieving Account Information

To retrieve account information, such as balances and positions, use the getAccountInfo method:

const accountInfo = await zomma.getAccountInfo(markets[0], zomma.wallet.address);
console.log(ethers.formatEther(accountInfo[0].initialMargin));
{
  initialMargin: 1446.1108696148
  marginBalance: 26668.210827902161793263
  equity: 26481.483722905361793263
  equityWithFee: 26470.750172013833793263
  upnl: -73.420174597650921454
  available: 25222.099958287361793263,
  healthFactor: 21.027334532089830127,
}
// ...

Placing Buy and Sell Orders

You can buy and sell orders using the buy and sell methods, respectively:

// Buy 0.1 ETH-USDC 4100 call option expiring on 2023-06-07 with 0.5% slippage
const tradeResponse = await zomma.buy("ETH-USDC", 1717747200, "4100", 1, "0.1", 0.5);
console.log(tradeResponse);

// Sell 0.31 ETH-USDC 3500 put option expiring on 2023-06-14 with 0.5% slippage
const tradeResponse2 = await zomma.sell("ETH-USDC", 1718352000, "3500", 0, "0.31", 0.5);
console.log(tradeResponse2);

Retrieving Orders

You can retrieve the list of orders for a specific market using the getOrders method:

let orders = await zomma.getOrders("BTC-USDC");
console.log(orders);

Examples

The library includes example scripts demonstrating various usage scenarios. You can find them in the examples directory:

  • account.js: Demonstrates how to fetch market data and retrieve account information.
  • trade.js: Demonstrates how to place buy and sell orders.
  • orders.js: Demonstrates how to retrieve the list of orders for a specific market.

Documentation

For detailed information about the available methods and their parameters, please refer to the source code

License

This library is released under the MIT License.