0.0.10 • Published 2 years ago

@tradologics/tradologics v0.0.10

Weekly downloads
33
License
Apache-2.0
Repository
-
Last release
2 years ago

Tradologics JavaScript SDK

This is the initial version of Tradologics' JavaScript SDK.

At the moment, it only supports a wrapper for the awesome axios library that will automatically:

  • prepend the full endpoint url to your calls
  • attach your token to the request headers
  • add datetime to your order when in backtesting mode

Install using NPM

npm install @tradologics/tradologics

Using the library

JavaScript

const axios = require('@tradologics/tradologics');

axios.setToken('MY AWESOME TOKEN');

axios.get('/orders')
  .then((res) => {
    // do anything with response
    console.log(res.data);
  })
  .catch((err) => {
    // handle any error
    console.error(err.message);
  });

axios.post('/orders', {
  key1: 'val1',
  key2: 'val2'
  // ...
}, {
  headers: {
    'Custom-Header-Key': 'Custom-Header-Value'
    // ...
  }
})
  .then((res) => {
    // do anything with response
    console.log(res.data);
  })
  .catch((err) => {
    // handle any error
    console.error(err.message);
  });

TypeScript

import axios, { AxiosError, AxiosResponse } from '@tradologics/tradologics';

axios.setToken('MY AWESOME TOKEN');

axios.get('/orders')
  .then((res: AxiosResponse) => {
    // do anything with response
    console.log(res.data);
  })
  .catch((err: AxiosError) => {
    // handle any error
    console.error(err.message);
  });

axios.post('/orders', {
  key1: 'val1',
  key2: 'val2'
  // ...
}, {
  headers: {
    'Custom-Header-Key': 'Custom-Header-Value'
    // ...
  }
})
  .then((res: AxiosResponse) => {
    // do anything with response
    console.log(res.data);
  })
  .catch((err: AxiosError) => {
    // handle any error
    console.error(err.message);
  });

Sandbox

const { Sandbox } = require('@tradologics/tradologics/sandbox');
const { strategy } = require('./strategy');

Sandbox.setToken('MY AWESOME TOKEN');
Sandbox.price_monitor(strategy);

Running your own server

const Server = require('@tradologics/tradologics/server');
const { strategy } = require('./strategy');

Server.start(strategy, '/my-strategy', '0.0.0.0', '5000');

Using helpers

const helpers = require('@tradologics/tradologics/helpers');

helpers.sum([1, 2, 3, 4]);
helpers.mean([1, 2, 3, 4]);
helpers.median([1, 2, 3, 4]);
const bars = {
  '2021-08-02T00:00:00': {
    'AAPL:US': {
      o: '145.78222065',
      h: '146.32989976',
      l: '130.50695245',
      c: '144.78644045',
      w: '145.30287592',
      v: 57857569,
      t: 440960,
    },
  },
  '2021-08-03T00:00:00': {
    'AAPL:US': {
      o: '145.19471033',
      h: '147.42027907',
      l: '144.38812837',
      c: '146.73816964',
      w: '146.29709366',
      v: 62153954,
      t: 449350,
    },
  },
};
console.log(helpers.bars_to_array(bars));
0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago