bot18
Version:
A high-frequency cryptocurrency trading bot by Zenbot creator @carlos8f
50 lines (44 loc) • 1.61 kB
JavaScript
/*
* Copyright (c) 2012 Mathieu Turcotte
* Licensed under the MIT license.
*/
var Backoff = require('./lib/backoff');
var ExponentialBackoffStrategy = require('./lib/strategy/exponential');
var FibonacciBackoffStrategy = require('./lib/strategy/fibonacci');
var FunctionCall = require('./lib/function_call.js');
module.exports.Backoff = Backoff;
module.exports.FunctionCall = FunctionCall;
module.exports.FibonacciStrategy = FibonacciBackoffStrategy;
module.exports.ExponentialStrategy = ExponentialBackoffStrategy;
/**
* Constructs a Fibonacci backoff.
* @param options Fibonacci backoff strategy arguments.
* @return The fibonacci backoff.
* @see FibonacciBackoffStrategy
*/
module.exports.fibonacci = function(options) {
return new Backoff(new FibonacciBackoffStrategy(options));
};
/**
* Constructs an exponential backoff.
* @param options Exponential strategy arguments.
* @return The exponential backoff.
* @see ExponentialBackoffStrategy
*/
module.exports.exponential = function(options) {
return new Backoff(new ExponentialBackoffStrategy(options));
};
/**
* Constructs a FunctionCall for the given function and arguments.
* @param fn The function to wrap in a backoff handler.
* @param vargs The function's arguments (var args).
* @param callback The function's callback.
* @return The FunctionCall instance.
*/
module.exports.call = function(fn, vargs, callback) {
var args = Array.prototype.slice.call(arguments);
fn = args[0];
vargs = args.slice(1, args.length - 1);
callback = args[args.length - 1];
return new FunctionCall(fn, vargs, callback);
};