Skip to content

Commit 1cd5716

Browse files
committed
Update to new Luno investment
1 parent a4ce577 commit 1cd5716

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

src/app/services/WalletService.ts

+29-28
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { IDataStore } from '../storage';
2-
import { Wallet, BalanceSummary, CurrentState } from '../domain';
3-
import * as moment from 'moment';
1+
import { IDataStore } from "../storage";
2+
import { Wallet, BalanceSummary, CurrentState } from "../domain";
3+
import * as moment from "moment";
44

55
export class WalletSummary {
66
totalBTC;
@@ -14,9 +14,9 @@ export class WalletSummary {
1414
}
1515

1616
const investments = {
17-
xbt: 500,
17+
xbt: 1000,
1818
eth: 0,
19-
btc: 500
19+
btc: 0
2020
};
2121

2222
const fees = {
@@ -59,9 +59,9 @@ export class WalletService {
5959

6060
async getCurrentWalletBalances(): Promise<Wallet[]> {
6161
let exchangeWallets = [
62-
await this.getWalletPerformance('Luno', 'xbt', ['XBTZAR']),
63-
await this.getWalletPerformance('Bitfinex', 'eth', ['ethbtc', 'XBTZAR']),
64-
await this.getWalletPerformance('Bitfinex', 'btc', ['XBTZAR'])
62+
await this.getWalletPerformance("Luno", "xbt", ["XBTZAR"]),
63+
await this.getWalletPerformance("Bitfinex", "eth", ["ethbtc", "XBTZAR"]),
64+
await this.getWalletPerformance("Bitfinex", "btc", ["XBTZAR"])
6565
].filter(wallet => wallet.baseValue > 0);
6666
exchangeWallets.push(await this.getOfflineWalletPerformance());
6767
return exchangeWallets;
@@ -83,8 +83,8 @@ export class WalletService {
8383
await this.store.getDailyRate(
8484
pair,
8585
moment()
86-
.add(-1, 'days')
87-
.startOf('day')
86+
.add(-1, "days")
87+
.startOf("day")
8888
.toDate()
8989
)
9090
)
@@ -95,7 +95,7 @@ export class WalletService {
9595
1
9696
);
9797
let openingPrice = openingPrices.reduce(
98-
(price, rate) => price * (rate?rate.close:0),
98+
(price, rate) => price * (rate ? rate.close : 0),
9999
1
100100
);
101101

@@ -116,19 +116,19 @@ export class WalletService {
116116
}
117117

118118
async getOfflineWalletPerformance(): Promise<Wallet> {
119-
let wallet = new Wallet('Mycellium', offlineWallet, 'btc', new Date());
119+
let wallet = new Wallet("Mycellium", offlineWallet, "btc", new Date());
120120
let currentPrices = await Promise.all(
121-
['XBTZAR'].map(async pair => await this.store.getLatestPrice(pair))
121+
["XBTZAR"].map(async pair => await this.store.getLatestPrice(pair))
122122
);
123123

124124
let openingPrices = await Promise.all(
125-
['XBTZAR'].map(
125+
["XBTZAR"].map(
126126
async pair =>
127127
await this.store.getDailyRate(
128128
pair,
129129
moment()
130-
.add(-1, 'days')
131-
.startOf('day')
130+
.add(-1, "days")
131+
.startOf("day")
132132
.toDate()
133133
)
134134
)
@@ -139,7 +139,7 @@ export class WalletService {
139139
1
140140
);
141141
let openingPrice = openingPrices.reduce(
142-
(price, rate) => price * (rate?rate.close:0),
142+
(price, rate) => price * (rate ? rate.close : 0),
143143
1
144144
);
145145

@@ -155,29 +155,30 @@ export class WalletService {
155155
currentPrice * wallet.baseValue - walletInvestment;
156156
wallet.changeSinceStartPercent =
157157
wallet.changeSinceStartRand / walletInvestment;
158-
wallet.url = 'https://www.blocktrail.com/BTC/address/19fedXKZdPGdUavsCydbvdYZ37NhjLW7A4';
158+
wallet.url =
159+
"https://www.blocktrail.com/BTC/address/19fedXKZdPGdUavsCydbvdYZ37NhjLW7A4";
159160
return wallet;
160161
}
161162

162163
async getSummary(): Promise<BalanceSummary> {
163-
let btcBalanceLuno = await this.getWalletPerformance('Luno', 'xbt', [
164-
'XBTZAR'
164+
let btcBalanceLuno = await this.getWalletPerformance("Luno", "xbt", [
165+
"XBTZAR"
165166
]);
166167
let btcBalanceBitfinex = await this.getWalletPerformance(
167-
'Bitfinex',
168-
'btc',
169-
['XBTZAR']
168+
"Bitfinex",
169+
"btc",
170+
["XBTZAR"]
170171
);
171172

172-
let ethBalance = await this.getWalletPerformance('Bitfinex', 'eth', [
173-
'ethbtc',
174-
'XBTZAR'
173+
let ethBalance = await this.getWalletPerformance("Bitfinex", "eth", [
174+
"ethbtc",
175+
"XBTZAR"
175176
]);
176177

177178
let mycelliumBalance = await this.getOfflineWalletPerformance();
178179

179-
let ethbtcRate = (await this.store.getLatestPrice('ethbtc')).price;
180-
let btczarRate = (await this.store.getLatestPrice('XBTZAR')).price;
180+
let ethbtcRate = (await this.store.getLatestPrice("ethbtc")).price;
181+
let btczarRate = (await this.store.getLatestPrice("XBTZAR")).price;
181182
let ethzarRate = ethbtcRate * btczarRate;
182183

183184
let summary = new WalletSummary();

0 commit comments

Comments
 (0)