-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtiger_trade.js
60 lines (52 loc) · 1.79 KB
/
tiger_trade.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
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: light-brown; icon-glyph: magic;
let url_endpoint = 'https://trade.itiger.com/portfolio/assets';
let url_icon =
'https://static.itiger.com/portal5/static/images/logo.152.abf5ec9c.png';
let textProps = {
minimumScaleFactor: 0.5,
lineLimit: 1,
'-centerAlignText': [],
};
let $ = importModule('core');
async function main() {
let auth = args.widgetParameter;
let r = new Request(url_endpoint);
r.method = 'GET';
r.headers = {
Authorization: auth,
};
let data = await r.loadJSON();
let { unrealizedPnl, totalTodayPnl, netLiquidation } = data.data.sec;
let icon = await $.loadImage(url_icon);
let node = $.parse`
<ListWidget >
<Image init=${icon} imageSize=${[24, 24]} cornerRadius=${4} -centerAlignImage/>
<Spacer/>
<Text init=${'$' + netLiquidation.toFixed(2)} font=title1 ...${textProps} />
<Text init="Total Assets" font=caption1 ...${textProps}/>
<Spacer/>
<Stack -centerAlignContent>
<Stack -layoutVertically>
<Text init=${'$' + unrealizedPnl.toFixed(2)} font=title2 ...${textProps}/>
<Text init="Unrealized" font=caption2 ...${textProps}/>
</>
<Spacer/>
<Stack -layoutVertically>
<Text init=${'$' + totalTodayPnl.toFixed(2)}font=title2 ...${textProps}/>
<Text init="Today's P&L" font=caption2 ...${textProps}/>
</>
</>
<Stack>
<Spacer/>
<Text init="Last updated at " font=${['systemFont',8]} />
<Date init=${new Date()} font=${['systemFont',8]} -applyTimeStyle />
<Spacer/>
</>
</>
`;
let widget = $.createWidget(node);
$.presentWidget(widget);
}
$.run(main)