-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
forex.ts
49 lines (44 loc) · 993 Bytes
/
forex.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
import SecType from "../data/enum/sec-type";
import { Contract } from "./contract";
/**
* A Forex Contract.
*/
export class Forex implements Contract {
/**
* Between two currencies,
* whatever currency comes first should be in "symbol" and the other one must be in "currency".
*/
private static readonly CURRENCY_SYMBOL_PRIO = [
"KRW",
"EUR",
"GBP",
"AUD",
"USD",
"TRY",
"ZAR",
"CAD",
"CHF",
"MXN",
"HKD",
"JPY",
"INR",
"NOK",
"SEK",
"RUB",
];
constructor(public symbol: string, public currency: string) {
// Swap between symbol and currency if the ordering is incorrect.
let temp: string;
if (
Forex.CURRENCY_SYMBOL_PRIO.indexOf(symbol) >
Forex.CURRENCY_SYMBOL_PRIO.indexOf(currency)
) {
temp = this.symbol;
this.symbol = this.currency;
this.currency = temp;
}
}
public exchange = "IDEALPRO";
public secType = SecType.CASH;
}
export default Forex;