Code Monkey home page Code Monkey logo

crypto-bot-trader's Introduction

CryptoCurrency Bot Trader

swapping of ERC-20 Tokens (buy/sell) based on the market health with bot strategy (condition) - by utilizing MetaMask & Puppeteer

image

List of ERC-20 Tokens Included

  • ChainLink Token, Decentraland, Uniswap, Aave, Curve (CRV), Sushi Token, Avalanche, Wrapped Matic, Wrapped BTC
  • Full Details

Compatible Networks

  • Polygon

Important token/coin

  • usdc (for trading)
  • matic (for gas fees)

Notes

  • Always make sure to have a balance in usdc (used for trading) & matic (for gas fees)
  • One trade at a time (for now)
  • Compound trading

Installation

npm i crypto-bot-trader

Usage

Filename as .env in {root}

PREFERRED_NETWORK="matic-mainnet"
# Default: 0
HEADLESS_BROWSER=1
# Sell Options
# Default: -10 (percent as unit)
SELL_CUTLOSS=-5
# Default: 5 (percent as unit)
SELL_PROFIT=1

Security

As for initial setup will require you to input your PrivateKey & password (required upon encryption of your data) image

Filename as {jsFile} in {root}

const {metaMask, trader, token} = require('crypto-bot-trader');

(async function() {
    // // initiate 
    await metaMask.build();
    const initiatedTrader = new trader({metamask_with_build: metaMask, token: token});
    
    await initiatedTrader.analyzeMarket()
    setInterval(async () => {
        await initiatedTrader.analyzeMarket()
    }, 300000);
    // every 5 minutes

})();
node {jsFile}

Extras

You can also stop your trading bot on a certain date; This is quite ideal on cloud server

On Env File: Add the following key

CHECKPOINT_DATE="{YOUR_DATE_HERE-> Format: YYYY-MM-DD HH:mm} (24-hour)"

Headless

Typical headless in puppeteer with extension of metamask will not work. Alternatively, you can use X Virtual Frame Buffer (xvfb) See Details

const {metaMask, trader, token} = require('crypto-bot-trader');
const Xvfb = require('xvfb');

(async function() {
    let xvfb = new Xvfb();
    xvfb.startSync();
    // // initiate 
    await metaMask.build();
    const initiatedTrader = new trader({metamask_with_build: metaMask, token: token});
    
    await initiatedTrader.analyzeMarket()
    setInterval(async () => {
        await initiatedTrader.analyzeMarket()
    }, 300000);
    // every 5 minutes

})();

Deploy in cloud server

Setup in cloud server, A simple CLI tool for ensuring that a given script runs continuously/in-background called (forever) See Details

const {metaMask, trader, token} = require('crypto-bot-trader');
const { exec } = require("child_process");

(async function() {
    await metaMask.initializeSecurity({pwd: null, is_setup: true});
    exec(`forever start headless.js --pwd=1`, (error, stdout, stderr) => {});

})();

Focus Feature

Focus on a specific token, this is good especially if the volatility of token is really high.

  • focus on matic? wmatic
  • focus on bitcoin? wbtc
  • foucus on etherium? weth
node {jsFile} --focus=wmatic

Method: 'sendto'

After a successful trade, profit will be sent to a specific wallet address. This feature is good if you have bunch of bot traders & you want the profit to be centralized.

node {jsFile} --focus=wmatic --method=sendto

In .env in {root}

WALLET_ADDRESS=
# Exact amount that will be the baseline of trader to prevent draining of wallet; (USDC Currency)
# Ex: 200
BASE_AMOUNT=

crypto-bot-trader's People

Contributors

marcelooblan2016 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

crypto-bot-trader's Issues

Hi! Some error

After setup and installation the following happens:
Maetamask run ok, import private key is ok, matic token added ok, but dont add USDC token and i have error:

Running tests on MetaMask version v10.1.1

Setup metamask...
Adding new networks...
Adding network: matic-mainnet
Switch network: matic-mainnet
Import Tokens...
Adding matic token ...
TimeoutError: waiting for XPath //button[contains(text(), 'Next')][not(@disabled)] failed: timeout 30000ms exceeded
at new WaitTask (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:526:34)
at DOMWorld.waitForXPath (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:457:26)
at Frame.waitForXPath (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\FrameManager.js:948:51)
at Page.waitForXPath (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\Page.js:2410:33)
at Object. (C:\Polygon_trade_bot\node_modules\crypto-bot-trader\dist\Metamask\Libs\loadTokenContracts.js:68:28)
at Generator.next ()
at fulfilled (C:\Polygon_trade_bot\node_modules\crypto-bot-trader\dist\Metamask\Libs\loadTokenContracts.js:5:58)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Analyzing market...
TimeoutError: waiting for selector .list-item.asset-list-item.token-cell failed: timeout 15000ms exceeded
at new WaitTask (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:526:34)
at DOMWorld.waitForSelectorInPage (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:430:26)
at Object.internalHandler.waitFor (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\QueryHandler.js:31:77)
at DOMWorld.waitForSelector (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:321:29)
at Frame.waitForSelector (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\FrameManager.js:924:51)
at Page.waitForSelector (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\Page.js:2359:33)
at C:\Polygon_trade_bot\node_modules\crypto-bot-trader\dist\Metamask\Libs\getBalances.js:86:24
at Generator.next ()
at fulfilled (C:\Polygon_trade_bot\node_modules\crypto-bot-trader\dist\Metamask\Libs\getBalances.js:5:58)
Home modal found.
Analyzing market...
TimeoutError: waiting for selector .list-item.asset-list-item.token-cell failed: timeout 15000ms exceeded
at new WaitTask (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:526:34)
at DOMWorld.waitForSelectorInPage (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:430:26)
at Object.internalHandler.waitFor (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\QueryHandler.js:31:77)
at DOMWorld.waitForSelector (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:321:29)
at Frame.waitForSelector (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\FrameManager.js:924:51)
at Page.waitForSelector (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\Page.js:2359:33)
at C:\Polygon_trade_bot\node_modules\crypto-bot-trader\dist\Metamask\Libs\getBalances.js:86:24
at Generator.next ()
at fulfilled (C:\Polygon_trade_bot\node_modules\crypto-bot-trader\dist\Metamask\Libs\getBalances.js:5:58)
Home modal found.
Analyzing market...
TimeoutError: waiting for selector .list-item.asset-list-item.token-cell failed: timeout 15000ms exceeded
at new WaitTask (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:526:34)
at DOMWorld.waitForSelectorInPage (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:430:26)
at Object.internalHandler.waitFor (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\QueryHandler.js:31:77)
at DOMWorld.waitForSelector (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:321:29)
at Frame.waitForSelector (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\FrameManager.js:924:51)
at Page.waitForSelector (C:\Polygon_trade_bot\node_modules\puppeteer\lib\cjs\puppeteer\common\Page.js:2359:33)
at C:\Polygon_trade_bot\node_modules\crypto-bot-trader\dist\Metamask\Libs\getBalances.js:86:24
at Generator.next ()
at fulfilled (C:\Polygon_trade_bot\node_modules\crypto-bot-trader\dist\Metamask\Libs\getBalances.js:5:58)

At this step I add USDC token manually and script continues to work:

Analyzing market...
Market Analyzed.
Analyzing market...
Market Analyzed.
Analyzing market...
Market Analyzed.

Is this a critical error? Maybe I did something wrong?
OS Windows 10, node v16.13.1, all depencies (crypto-bot-trader, puppeteer etc.) installed correctly)

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.