-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtrade2.js
57 lines (48 loc) · 1.44 KB
/
trade2.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
45
46
47
48
49
50
51
52
53
54
55
56
57
// Test trading with our new Weathervane, Malaise.
const {
candleManager,
poloniex,
company,
orderBook,
orderManager,
Trade,
currencyOut,
currencyIn
} = require('./preamble')
const PositionChange = require('./positionChange')
const Malaise = require('./malaise')
const m = new Malaise()
// TRADER POLICY
// All the behavior and parameters specified below are trader
// behavior, and should be moved into its own module eventually.
bet_amount = 1; // Amount to gamble in each bet, in ETH
increment = 0.00000001;
limit = 1.0001; // stop chasing the price if we can't catch it in 0.01%
candleManager.onNewCandle(function(newCandle, candleManager) {
console.log("Malaise New Candle");
m.newCandlestick(newCandle);
})
m.onSell(function(confidence) {
console.log("Topping out with confidence " + confidence);
console.log(bet_amount);
finalAmount = bet_amount*confidence;
console.log("Amount " + finalAmount);
/*
positionChange = new PositionChange(poloniex, orderBook, "sell",
finalAmount, increment, limit);
positionChange.doTheThing();
*/
});
m.onBuy(function(confidence) {
console.log("Bottoming out with confidence " + confidence);
console.log(bet_amount);
finalAmount = bet_amount*confidence;
console.log("Amount " + finalAmount);
/*
positionChange = new PositionChange(poloniex, orderBook, "buy",
finalAmount, increment, limit);
positionChange.doTheThing();
*/
});
// Kick it off!
orderBook.start();