-
Notifications
You must be signed in to change notification settings - Fork 21
/
order.js
90 lines (72 loc) · 1.58 KB
/
order.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import assert from 'assert';
export default class Contract {
static limit(data) {
assert(data.action);
assert(data.totalQuantity > 0);
assert(data.lmtPrice > 0);
return Contract._toOrder(data, 'LMT', {
transmit: true,
openClose: 'O',
tif: 'DAY',
/*
origin: 0,
parentId: 0,
blockOrder: 0,
sweepToFill: 0,
displaySize: 0,
triggerMethod: 0,
outsideRth: 0,
hidden: 0,
discretionaryAmt: 0,
shortSaleSlot: 0,
exemptCode: -1,
ocaType: 0,
allOrNone: 0,
eTradeOnly: 1,
firmQuoteOnly: 1,
auctionStrategy: 0,
overridePercentageConstraints: 0,
continuousUpdate: 0,
optOutSmartRouting: 0,
notHeld: 0,
whatIf: 0,
solicited: 0,
randomizeSize: 0,
randomizePrice: 0,
extOperator: 0,
mifid2ExecutionAlgo: 0,*/
});
}
static market(data) {
assert(data.action);
assert(data.totalQuantity > 0);
return Contract._toOrder(data, 'MKT', {
transmit: true,
goodAfterTime: '',
goodTillDate: ''
});
}
static stop(data) {
assert(data.action);
assert(data.totalQuantity > 0);
assert(data.auxPrice > 0);
return Contract._toOrder(data, 'STP', {
transmit: true,
parentId: 0,
tif: 'DAY'
});
}
static _toOrder(data, orderType, defaults) {
assert(!data.orderType);
let o = {
orderType: orderType
};
for (let k in defaults) {
o[k] = defaults[k];
}
for (let k in data) {
o[k] = data[k];
}
return o;
}
}