forked from destenson/etheropt--etheropt.github.io
-
Notifications
You must be signed in to change notification settings - Fork 1
/
market_maker.js
44 lines (40 loc) · 1.49 KB
/
market_maker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var config = require('./config.js');
var server = require('./server.js');
var utility = require('./utility.js');
var Web3 = require('web3');
var request = require('request');
var async = require('async');
var gaussian = require('gaussian');
var commandLineArgs = require('command-line-args');
var sha256 = require('js-sha256').sha256;
require('datejs');
var cli = commandLineArgs([
{ name: 'help', alias: 'h', type: Boolean },
{ name: 'armed', type: Boolean, defaultValue: false },
{ name: 'domain', type: String, defaultValue: config.domain },
{ name: 'port', type: String, defaultValue: config.port },
{ name: 'eth_addr', type: String, defaultValue: config.eth_addr }
]);
var cli_options = cli.parse()
if (cli_options.help) {
console.log(cli.getUsage());
} else {
var server = new server.Server(cli_options.domain, cli_options.port, cli_options.eth_addr, cli_options.armed,
function (existing_pricer_data, callback) {
callback();
},
function(option, pricer_data) {
var today = Date.now();
var expiration = Date.parse(option.expiration+" 00:00:00 UTC");
var t_days = (expiration - today)/86400000.0;
var t = t_days / 365.0;
if (t<=0) return undefined;
var buy_price = 0.0001;
var sell_price = option.margin;
var buy_size = utility.ethToWei(1);
var sell_size = utility.ethToWei(1);
var expires = 10; //in blocks
return {buy_price: buy_price, sell_price: sell_price, buy_size: buy_size, sell_size: sell_size, expires: expires};
}
);
}