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

botnest

v0.0.13

Published

Fully customized trading bot for cryptocurrency exchange with custom strategies

Downloads

13

Readme

Nest.JS + CCXT Trading Bot

This is a trading bot for a cryptocurrency exchange with an ability to use custom strategies. There are two strategies on the board:

  1. FillCells - bot purchase bitcoin with predefined steps (every $50 of rates for example). If there is an already opened order with current rate step found, the purchase is not made.

  2. AwaitProfit - bot is waiting for the exchange to rise and try to sell buyed bitcoin. If anual profit percent more that 200% then bot try to sell bitcoin. After 24 hours needed anual profit decreases to 30%.

These simple strategies will guarantee you at least 30% anual profits, just be patient)

Requirements:

  1. API keys for Binance
  2. PostgreSQL Server
  3. Node v16.14.0

Instalation:

npm install botnest
cp ./node_modules/botnest/.env.example .env

Or you can

git clone [email protected]:gorcer/botnest.git
cd botnest

Fill settings in .env (TEST_MODE = false for production)

Usage as project (if you git clone it)

To run one iteration:

npm run example:inline

To run as daemon:

npm run example:daemon

Usage as component

All you need it's BotNest - it is all in one service.

import { BotNest } from "../bot/botnest.service";
import { FillCellsStrategy } from "../strategy/buyFillCellsStrategy/fillCellsStrategy.strategy";
import { AwaitProfitStrategy } from "../strategy/sellAwaitProfitStrategy/awaitProfitStrategy.strategy";
 
const pairName = process.env.PAIRS.replace(' ', '').split(',')[0];
const userId = 1;
const cellSize = 50; // step for FillCellsStrategy
const pair = await this.botnest.actualizePair(pairName)

// set bot strategies
this.botnest.addStrategy(FillCellsStrategy);
this.botnest.addStrategy(AwaitProfitStrategy);

// add test account
const account = await this.botnest.setUserAccount(userId, {
    exchangeName: process.env.EXCHANGE_NAME,
    apiKey: process.env.EXCHANGE_API_KEY,
    secret: process.env.EXCHANGE_API_SECRET,
    testMode: process.env.TEST_MODE == 'true',
});

// set buy strategy config for account
await this.botnest.setStrategyForAccount(
    {accountId: account.id, pairId:pair.id},
    FillCellsStrategy,
    {
        orderAmount: Number(process.env.STRATEGY_BUY_ORDER_AMOUNT),
        risk: process.env.STRATEGY_BUY_RISK,
        pairId: pair.id,
        cellSize: process.env.INLINE_CELLSIZE
    });

// set sell strategy for account
await this.botnest.setStrategyForAccount(
    {accountId: account.id},
    AwaitProfitStrategy,
    {
        minDailyProfit: Number(process.env.STRATEGY_SELL_MIN_DAILY_PROFIT), 
        minYearlyProfit: Number(process.env.STRATEGY_SELL_MIN_ANNUAL_PROFIT), 
    });


// checking orders before start
await this.botnest.checkCloseOrders();

//get current rates
const rates = await this.botnest.getActualRates(pairName);
if (!rates.ask || !rates.bid) {
    throw new Error('Cant resolve current rate, try to repeat later')
}

// set current rates
await this.botnest.setRates({
    pairName: rates
});

// run buy strategies
await this.botnest.runBuyStrategies();

// run sell strategies
await this.botnest.runSellStrategies();

Full example watch there:

src/example/inlineTrade.service.ts

Run tests

npm test