GithubHelp home page GithubHelp logo

tastyworks's Introduction

Tastyworks Node API

FOSSA Status

npm David npm

NodeJS Framework for basic account information, balances, positions and orders with TastyWorks's private API. This API has been reversed engineered. The stability and accuracy of this API cannot be garunteed.

Features

  • Account Balances
  • Account History
  • Current Orders
  • Current Positions

Installation

$ npm install tasty-works-api --save

Getting Started

/sample/index.js has an example of each call configured. To run and see each response, replace YOUR_USERNAME' and 'YOUR_PASSWORD' and 'ACCOUNT_ID' with your Tastyworks credentials. Then run$ cd sample && node index.js` in your Terminal.

API

User

Set account variables after authentication is complete so the variables can be used later. The object has four keys, username, password, authorization_token and accounts. By deafult, you are only required to set the username and password. In order to make sure the proper credentials are set as well as, to view the associated account(s) with the user, the getUser() function is provided.

NOTE: you must set the user object's username and password before other endpoints will work

const TastyWorks = require('tasty-works-api');
const credentials = {
	username: 'username',
	password: 'password'
};

TastyWorks.setAccount(credentials);
console.log(TastyWorks.getUser());

Authorization()

The authorization endpoint will return a session token that needs to be set into headers that are used in subsequent calls. Also, this call assumes that you have previously set the username and password in the users object.

TastyWorks.authorization().then(token => {
	// REQUIRED: Apply the new session token to the headers object passed into each call
	TastyWorks.setAuthorizationToken(token);

	// OPTIONAL: Set the session token in the user object
	TastyWorks.setUser({
		authorization_token: token
	});
	return true;
});

Accounts()

Get all accounts associated with the logged in user. The response is an array of account objects. While it is easy to add these to the user object to be referenced when needed. You can hardcode the account that you wish to reference and pass that into the other calls, too.

TastyWorks.accounts().then(accounts =>
	TastyWorks.setUser({
		accounts
	})
);

Balances(ACCOUNT_ID)

Fetch the balances for a single account

TastyWorks.balances('ACCOUNT_ID').then(balances => console.log(balances));

Positions(ACCOUNT_ID)

Fetch the current positions for a single account

TastyWorks.positions('ACCOUNT_ID').then(positions => console.log(positions));

LiveOrders(ACCOUNT_ID)

Fetch the current (non-complete) orders for a single account. This can include orders that have been partially fulfilled

TastyWorks.liveOrders('ACCOUNT_ID').then(liveOrders => console.log(liveOrders));

History(ACCOUNT_ID, START_DATE, END_DATE)

Fetch the accounts order history for a given time period. Date format is yyyy-mm-dd.

TastyWorks.history('ACCOUNT_ID', '2018-01-01', '2018-01-05').then(history => console.log(history));

TODOs

  • Position groupings
  • Fetch news for an equity
  • Current option prices

Direct Dependencies

Library Licenses
superagent (4.1.0) MIT

License

FOSSA Status

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.