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

@enea-scaccabarozzi/tradekits

v1.7.0

Published

A small library to interact with some cryptocurrency exchanges in a way that is convenient for my projects.

Downloads

43

Readme

Tradekits

npm package Build Status Downloads Issues Code Coverage Commitizen Friendly Semantic Release

A small library to interact with some cryptocurrency exchanges in a way that is convenient for my projects. Please note that this projects is suited for my very specific needs and it's not meant to be a general purpose library. If you find it useful, feel free to use it, but be aware that it may not cover all the features you need.

Table of Contents

Installation

To install Tradekit, run:

npm install @enea-scaccabarozzi/tradekits

Usage

import { Binance, Bybit } from '@enea-scaccabarozzi/tradekits';

const exchange = new Binance({
    proxies: [{
        host: "string",
        port: "number",
        auth: { username: undefined, password: undefined },
        protocol: undefined;
    }];
  sandbox: true;
  auth: { key: "string", secret: "string" };
})

The Tradekit API allows you to manage proxies, authenticate, access market data, and handle account and position management within a trading environment. This README provides an overview of the available methods and options for interacting with the Tradekit API.

Proxy Management

Manage the proxies used by Tradekit for network requests.

  • addProxy(proxy: ProxyOptions): ProxyOptions Adds a proxy configuration and returns the added proxy options.

  • setProxies(proxies: ProxyOptions[]): number Sets multiple proxies and returns the number of proxies set.

  • getProxies(): TradekitResult<ProxyOptions[]> Retrieves the list of configured proxies.

  • getCurrentProxy(): TradekitResult Retrieves the currently active proxy.

  • rotateProxy(): TradekitResult Rotates to the next proxy in the list and returns the new active proxy.

Authentication

Manage authentication for accessing trading services.

  • setAuth(auth: TradekitAuth): boolean Sets the authentication credentials and returns a boolean indicating success.

  • getAuth(): TradekitResult Retrieves the current authentication credentials.

Sandbox

Enable or disable the sandbox mode for testing without affecting real accounts.

  • setSandbox(sandbox: boolean): boolean Sets the sandbox mode and returns a boolean indicating if it was successfully set.

Market Data

Access market data such as ticker information.

  • getTicker(opts: GetTikerOptions): Promise<TradekitResult> Retrieves the ticker data for a specified symbol.

  • getTickers(opts: GetTikersOptions): Promise<TradekitResult<Ticker[]>> Retrieves ticker data for multiple symbols.

  • subscribeToTicker(opts: SubscribeToTikerOptions): TradekitResult Subscribes to updates for a specified ticker.

  • subscribeToTickers(opts: SubscribeToTikersOptions): TradekitResult Subscribes to updates for multiple tickers.

Account Data

Manage and retrieve account-related data.

  • getBalance(opts?: GetBalanceOptions): Promise<TradekitResult> Retrieves the balance for specified currencies.

  • setLeverage(opts: SetLeverageOptions): Promise<TradekitResult> Sets the leverage for trading and returns the new leverage.

Position Management

Open and close trading positions.

  • openShort(opts: OpenPositionOptions): Promise<TradekitResult> Opens a short position with specified options.

  • closeShort(opts: ClosePositionOptions): Promise<TradekitResult> Closes a short position with specified options.

  • openLong(opts: OpenPositionOptions): Promise<TradekitResult> Opens a long position with specified options.

  • closeLong(opts: ClosePositionOptions): Promise<TradekitResult> Closes a long position with specified options.

Interfaces

ProxyOptions

Defines the configuration for a proxy.

TradekitAuth

Defines the authentication credentials.

GetTikerOptions

Options for retrieving a single ticker.

export interface GetTikerOptions {
  symbol: string;
}

SubscribeToTikerOptions

Options for subscribing to a single ticker, extending GetTikerOptions.

export type SubscribeToTikerOptions = GetTikerOptions & BaseSubscriptionOptions<Ticker>;

GetTikersOptions

Options for retrieving multiple tickers.

export interface GetTikersOptions {
  symbols: string[];
}

SubscribeToTikersOptions

Options for subscribing to multiple tickers, extending GetTikersOptions.

export type SubscribeToTikersOptions = GetTikersOptions & BaseSubscriptionOptions<Ticker[]>;

GetBalanceOptions

Options for retrieving account balances.

export interface GetBalanceOptions {
  currencies?: string[];
}

SetLeverageOptions

Options for setting trading leverage.

export interface SetLeverageOptions {
  leverage: number;
  symbol?: string;
}

OpenPositionOptions

Options for opening a trading position.

export interface OpenPositionOptions {
  symbol: string;
  amount: number;
  timeInForce?: number;
}

ClosePositionOptions

Options for closing a trading position.

export interface ClosePositionOptions {
  symbol: string;
  amount: number;
  timeInForce?: number;
}

BaseSubscriptionOptions

Base options for subscribing to updates, with generic type T.

export interface BaseSubscriptionOptions<T> {
  onUpdate: (data: T) => void | Promise<void>;
  onConnect?: () => void | Promise<void>;
  onClose?: () => void | Promise<void>;
  onSubscribed?: () => void | Promise<void>;
  onError?: (error: TradekitError) => void | Promise<void>;
}

TradekitResult

Generic result type used by many Tradekit methods. It wraps the result data and any errors that may have occurred. See neverthrow for more information about this approach.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or new features.

License

This project is licensed under the MIT License. See the LICENSE file for details.