-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquick.test.ts
106 lines (92 loc) · 3.1 KB
/
quick.test.ts
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// import axios from "axios";
// import { TradeSdk } from "./src/utils/TradeSdk";
// import { __latestQuotes__ } from "./src/utils/LatestQuotes";
// import { readFileSync, writeFileSync } from "fs";
// import yahooFinance from "yahoo-finance2";
// // {
// // id: 'c1efb631-f837-4076-8ce8-f2ecdc12a85a',
// // class: 'us_equity',
// // exchange: 'NASDAQ',
// // symbol: 'CHRD',
// // name: 'Chord Energy Corporation Common Stock',
// // status: 'active',
// // tradable: true,
// // marginable: true,
// // maintenance_margin_requirement: 30,
// // shortable: true,
// // easy_to_borrow: true,
// // fractionable: true,
// // attributes: []
// // }
// const getAsset = async () => {
// const result = await TradeSdk.getAssets({
// status: "active",
// });
// const tradable = result.filter((v: any) => v.tradable);
// const randomIdx = Math.floor(Math.random() * tradable?.length);
// const share = tradable[randomIdx];
// if (share) {
// const quote = await __latestQuotes__(share.symbol);
// share.quote = quote;
// return share;
// }
// // console.log(randomIdx);
// return tradable?.pop() ?? {};
// };
// const createRandomOrder = async () => {
// const res = await getAsset();
// // console.log(`🔥🔥 `, res);
// const order = await TradeSdk.createOrder({
// symbol: res.symbol, // any valid ticker symbol
// qty: 13,
// side: "buy",
// type: "market",
// time_in_force: "day",
// client_order_id: "this_jakir_order",
// });
// console.log(`################`, order);
// };
// const orderHistory = async () => {
// const result = await TradeSdk.getOrders({ status: "filled" });
// return result;
// };
// const sellShare = async (symbol: string) => {
// const result = await TradeSdk.createOrder({
// symbol: symbol, // any valid ticker symbol
// qty: 13,
// // notional: number, // qty or notional required, not both
// side: "sell",
// type: "market",
// time_in_force: "day",
// });
// console.log(result);
// };
// const main = async () => {
// console.clear();
// const query = "AAPL";
// const queryOptions = { period1: "2021-05-08" /* ... */ };
// const result = await yahooFinance.chart(query, queryOptions);
// const quotes = await yahooFinance.quote(query);
// console.log(quotes);
// };
// main();
// // const options = {
// // method: "GET",
// // url: "https://data.sandbox.alpaca.markets/v1beta1/logos/VXUS",
// // headers: {
// // accept: "image/png",
// // "APCA-API-KEY-ID": "PK0AV0KSFCSJW1GRNLB3",
// // "APCA-API-SECRET-KEY": "xAKFgdtB5tL2vSHz5luVa4YZ43kDIy5e0aFKyl6u",
// // },
// // };
// // axios
// // .request(options)
// // .then(function (response) {
// // console.log(response.data);
// // })
// // .catch(function (error) {
// // console.error(error.message);
// // });
// // tst();
// // resources
// // https://hbr.org/2014/11/the-best-performing-ceos-in-the-world