# gdax-sim

> Simulator used to help unit test and back test various Coinbase-Pro (gdax) interactions.

Latest version **1.5.2** (published 2021-02-15) · AGPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install gdax-sim
pnpm add gdax-sim
yarn add gdax-sim
bun add gdax-sim
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.2 |
| Published | 2021-02-15 |
| First published | 2019-01-04 |
| Weekly downloads | 0 |
| License | AGPL-3.0-or-later |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | aaaelite21 |
| Maintainers | aaaelite21 |
| Keywords | gdax |

## Links

- npm: https://www.npmjs.com/package/gdax-sim
- Repository: https://github.com/aaaelite21/gdax-sim
- Homepage: https://github.com/aaaelite21/gdax-sim#readme
- Issues: https://github.com/aaaelite21/gdax-sim/issues
- npm.io page: https://npm.io/package/gdax-sim

## Recent versions

- 1.5.2 (latest) — 2021-02-15
- 1.5.1 — 2020-11-29
- 1.5.0 — 2020-11-22
- 1.2.0 — 2020-10-21
- 1.1.1 — 2020-07-28
- 1.1.0 — 2020-07-27
- 1.0.16 — 2019-11-13
- 1.0.15 — 2019-09-29
- 1.0.13 — 2019-09-29
- 1.0.14 — 2019-08-11
- 1.0.12 — 2019-07-09
- 1.0.11 — 2019-05-24
- 1.0.10 — 2019-05-18
- 1.0.9 — 2019-05-05
- 1.0.8 — 2019-04-20
- … 8 more at https://npm.io/package/gdax-sim/versions

## README

# gdax-sim

Simulator used to help unit test and back test various Coinbase-Pro (gdax) interactions.

## Install

```
npm i gdax-sim
```

## Backtest

Reads data from saved candle objects and spits out matches 4 matches, one for open, one for the high, one for the low, and one for the close.

- If open >= close, the high will be 'sent' second and the low third
- If close > open, the low will be 'sent' second and the high third
  - Settings to change this will come later
- Dispatches matches and dones based off of user orders to better replicate actual behavior
- If there is a gap in teh data the time is filled with 1 heartbeat message per minute

## Example Code

```
const ApiSim = require('gdax-sim)
let gdax = new ApiSim({
        quote_balance: 10,
        base_balance: 10,
        taker_fee: 0.5,
        hour_start_on: 30,
      }); //set base account (quote_balance-base_balance) taker_fee (in %), an when to start hourly candles
gdax.pair = 'LTC-USD';//set the name of the pair
gdax.websocketClient.on('message', (data) => {
  //your code to handle behavior upon recieving a message on the websocket
});

//function to run after all mesages generated by the specific data set have been disbatched
gdax.afterSession = () =>{
  console.log(gdax.user.fiatBalance, gdax.user.cryptoBalance);
}

//start the backtest
gdax.backtest(require('./TestData/LTC/27Nov2018.json').{
            start_time: "0000", //starts candles and events when >=
            end_time: "2460"    //stops when 24 hour time is less than
          });
```

## Currnet API Endpoints

- Buy
  - limit and market
- Sell
  - limit and market
- cancelOrder
  - limit only
- getOrder
- getHistoricRates
  - takes 'granularity'
  - takes 'end'

### Coming Soon

- Get Accounts
- Get Balance
- Multi-asset web socket

## Unit Test

Done using a global install of Mocha

```
gdax-sim> mocha
```

## Dev Blog

[DownToCrypto.com](https://downtocrypto.com)

---
_Source: https://npm.io/package/gdax-sim · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
