This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mtgoxDump = './dump.sql'; // this is the database file outputted by the Trade Downloader ( https://bitcointalk.org/index.php?topic=221055.0 ) | |
var output = './candles-' + (+new Date()) + '.csv'; // csv file with your candles | |
var db = require('sqlite-wrapper')(mtgoxDump); | |
var moment = require('moment'); | |
var _ = require('underscore'); | |
var fs = require('fs'); | |
var i = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# you need to have node and npm installed | |
cd ~ # navigate to homedir | |
mkdir test # create a new test directory | |
cd test # go in the new directory | |
mkdir node_modules # make sure bitstamp will get installed locally | |
npm install bitstamp # download bitstamp module | |
cd node_modules/bitstamp # go to the files of the module | |
node example.js # run the example file through node.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// var moment = require('moment'); | |
var nedb = require('nedb'); | |
// var async = require('async'); | |
var db = new nedb({filename: 'test6.db', autoload: true}); | |
var _ = require('lodash'); | |
var candles = []; | |
_.each(_.range(1440), function(d) { | |
var candle = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = require('lodash'); | |
var candles = []; | |
var c = function() { | |
console.log('create candle'); | |
_.each(_.range(100000), function(d) { | |
var candle = { | |
s: d, | |
o: Math.random() * 1000, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Low level datastore to persist 1m candles | |
// generated by the CandleManager to disk. | |
// | |
var zlib = require('zlib'); | |
var fs = require('fs'); | |
var lodash = require('lodash'); | |
var async = require('async'); | |
var _ = require('lodash'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
// log to stdout (console) fn | |
var stdout = process.stdout.write; | |
// log to file fn | |
var fileLog = fs.createWriteStream('log.txt', {'flags': 'a'}); | |
// overwrite the original to log to both | |
process.stdout.write = function(d) { | |
fileLog.write(d); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
**openDay**(day String) | |
Should open a day from disk or create a new one if nonexistant. Can be async. Will overwrite the previous open day. | |
Note: if we are adding candles and they are not written yet, wait for this to finish first. | |
**addCandles**(candles Array) | |
Should add candles to the currently open day and write to disk. If we are opening a day store them temp in a queue and process once the openDay is loaded. | |
**loadDay**(day String, cb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var _ = require('lodash'); | |
var db = '[' + fs.readFileSync('file.db', 'utf8') + ']'; | |
db = _.map(db.split('\n'), function(line) { | |
return line + ','; | |
}).join('\n'); | |
console.log(db) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Trader = require('./trader'); | |
var t = new Trader; | |
t.on('trading', console.log); | |
setInterval(t.trade, 1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ws; | |
var handle = function(e) { | |
console.log(JSON.parse(e.data)); | |
} | |
var reconnect = function() { | |
setTimeout(connect, 5000); | |
} |
OlderNewer