Transpiled version (11476L) is out of date.
1 | interface IFuturesMarket {
|
2 | // all open/close orders are market right now (not limit) |
3 | |
4 | sclass OpenOrCloseOrder {
|
5 | // input parameters |
6 | |
7 | settable S clientOrderID; // optional |
8 | |
9 | settable HoldSide holdSide; |
10 | settable double cryptoAmount; |
11 | |
12 | settable double leverage = 1; |
13 | |
14 | // Limit order if set. Otherwise market order. |
15 | // Limit orders are good-until-cancel. |
16 | // (unimplemented) |
17 | settable double limitPrice = Double.NaN; |
18 | |
19 | // output parameters |
20 | |
21 | // order ID returned by platform |
22 | settable S orderID; |
23 | } |
24 | |
25 | macro ExtendingOpenOrCloseOrder {
|
26 | public selfType clientOrderID(S clientOrderID) { super.clientOrderID(clientOrderID); this; }
|
27 | public selfType holdSide(HoldSide holdSide) { super.holdSide(holdSide); this; }
|
28 | public selfType cryptoAmount(double cryptoAmount) { super.cryptoAmount(cryptoAmount); this; }
|
29 | public selfType leverage(double leverage) { super.leverage(leverage); this; }
|
30 | public selfType limitPrice(double limitPrice) { super.limitPrice(limitPrice); this; }
|
31 | } |
32 | |
33 | sclass OpenOrder extends OpenOrCloseOrder {
|
34 | ExtendingOpenOrCloseOrder |
35 | settable bool isCross; |
36 | |
37 | settable double takeProfitPrice = Double.NaN; |
38 | settable double stopLossPrice = Double.NaN; |
39 | } |
40 | |
41 | sclass CloseOrder extends OpenOrCloseOrder {
|
42 | ExtendingOpenOrCloseOrder |
43 | } |
44 | |
45 | // throws exception if order failed |
46 | void openPosition(OpenOrder order); |
47 | |
48 | // throws exception if order failed |
49 | void closePosition(CloseOrder order); |
50 | |
51 | sclass SwappableImplementation is IFuturesMarket {
|
52 | public swappable void openPosition(OpenOrder order) {}
|
53 | public swappable void closePosition(CloseOrder order) {}
|
54 | public swappable double drift() { unimplemented(); }
|
55 | public swappable FutureCoinParameters getCoinParameters() { unimplemented(); }
|
56 | public swappable bool anyOpenPositions() { unimplemented(); }
|
57 | } |
58 | |
59 | // Get current drift (sum of longs+shorts in crypto units) |
60 | double drift(); |
61 | |
62 | FutureCoinParameters getCoinParameters(); |
63 | |
64 | bool anyOpenPositions(); |
65 | } |
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1036219 |
| Snippet name: | IFuturesMarket - interface to a single market (e.g. ETHUSDT) |
| Eternal ID of this version: | #1036219/22 |
| Text MD5: | b3cb6d0b096ce7c03302718a163a2904 |
| Author: | stefan |
| Category: | javax / trading |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2024-07-07 06:23:36 |
| Source code size: | 2127 bytes / 65 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 2004 / 2261 |
| Version history: | 21 change(s) |
| Referenced in: | [show references] |