node-activetick

0.1.2 • Public • Published

Activetick for NodeJS

Activetick provides real-time and historical stock values.

The CSV format is converted into an array of object, and the "YYYYMMDDHHMMSS" dates are converted into JS dates.

Setup

  • Download and install the http proxy
  • Launch the http proxy: ActiveTickFeedHttpServer 127.0.0.1 5000 activetick1.activetick.com [apikey] [username] [password]
  • install the nodejs package: npm install node-activetick

Output format

The output from fetch()'s callback is an array of object.

[
	{
		"d": "2015-01-05T15:05:00.000Z",
		"o": 115.68,
		"h": 115.87,
		"l": 115.67,
		"c": 115.761,
		"v": 277740
	},
	{
		"d": "2015-01-05T15:10:00.000Z",
		"o": 115.76,
		"h": 115.8299,
		"l": 115.66,
		"c": 115.671,
		"v": 181276
	},
	{
		"d": "2015-01-05T15:15:00.000Z",
		"o": 115.68,
		"h": 115.69,
		"l": 115.53,
		"c": 115.54,
		"v": 329890
	},
	{
		"d": "2015-01-05T15:20:00.000Z",
		"o": 115.54,
		"h": 115.75,
		"l": 115.52,
		"c": 115.715,
		"v": 267586
	},
	{
		"d": "2015-01-05T15:25:00.000Z",
		"o": 115.71,
		"h": 115.71,
		"l": 115.6,
		"c": 115.69,
		"v": 242454
	}
	...
]
  • d: Javascript Date Object
  • o: Open
  • h: High
  • l: Low
  • c: Close
  • v: Volume

Methods

Init

Without options:

var activetick	= require('node-activetick');
var market		= new activetick();

With options, if Activetick's HTTP proxy is not setup with the default settings:

var activetick	= require('node-activetick');
var market		= new activetick({
	host:	'127.0.0.1',
	port:	5000
});

Define the symbol

market.open('AAPL');

Define the date range

market.from(new Date(2014,01,01))
market.to(new Date())

Define the timeframe

market.timeframe('1h');

Here are the supported timeframes:

  • weekly
  • daily
  • 12h
  • 8h
  • 6h
  • 2h
  • 1h
  • 30m
  • 15m
  • 5m
  • 1m

Fetch the data

market.fetch(function(response) {
	// response is an array of objects. See "output" for format details.
});

Activetick's HTTP proxy will return faulty data if you ask for too much at once. If necessary, fetch(callback) will split your query into smaller queries to avoid that issue.

Logging

When downloading data, node-activetick will display a progress bar in the console. You can deactivate that by turning of the loging:

market.log = false

Note

This is a work in progress.

Real-time data is not yet implemented.

Pull requests are welcomed.

License: MIT

Copyright (c) 2014 Julien Loutre, Twenty-Six Medias, Inc

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Package Sidebar

Install

npm i node-activetick

Weekly Downloads

3

Version

0.1.2

License

none

Unpacked Size

18.4 kB

Total Files

6

Last publish

Collaborators

  • 26medias