cryptum 0.0.456 → 0.0.458
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -5
- data/lib/cryptum/ui/order/execute.rb +40 -4
- data/lib/cryptum/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c04633f954adc6a1d46177ffad69796738a01be430071efc785226f8f1fd116
|
4
|
+
data.tar.gz: 804989be187108d606c9784aae5149dea03a302b0bd937e5115810a0714d74a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a86babcb3ee6fdfedf5f218ead23f74bc449c8bb8f8bb9eb7afb6b7b716458aab16cda47dc524d1af447116b04346722e9e2d7f7b453140bf1afb2b91379bb6
|
7
|
+
data.tar.gz: ce866cc620947b3a575a9b4124bf076002818ba6457cfc46f479baad6b7014ecf4a489ca73dec0f5fcbb986d3db813cdde5d33bcbc03ee1214cfe77157784b56
|
data/.rubocop.yml
CHANGED
@@ -6,7 +6,7 @@ Layout/LineLength:
|
|
6
6
|
Lint/UselessRescue:
|
7
7
|
Enabled: false
|
8
8
|
Metrics/AbcSize:
|
9
|
-
Max:
|
9
|
+
Max: 537.6
|
10
10
|
Metrics/BlockLength:
|
11
11
|
Max: 138
|
12
12
|
Metrics/BlockNesting:
|
@@ -14,13 +14,13 @@ Metrics/BlockNesting:
|
|
14
14
|
Metrics/ClassLength:
|
15
15
|
Max: 134
|
16
16
|
Metrics/CyclomaticComplexity:
|
17
|
-
Max:
|
17
|
+
Max: 102
|
18
18
|
Metrics/MethodLength:
|
19
|
-
Max:
|
19
|
+
Max: 485
|
20
20
|
Metrics/ModuleLength:
|
21
|
-
Max:
|
21
|
+
Max: 495
|
22
22
|
Metrics/PerceivedComplexity:
|
23
|
-
Max:
|
23
|
+
Max: 100
|
24
24
|
Style/HashSyntax:
|
25
25
|
EnforcedShorthandSyntax: never
|
26
26
|
|
@@ -239,13 +239,30 @@ module Cryptum
|
|
239
239
|
end
|
240
240
|
end
|
241
241
|
|
242
|
-
#
|
242
|
+
# Snag all orders bought YTD
|
243
|
+
oh_buy_ytd_arr = order_history.select do |oh|
|
244
|
+
oh[:side] == 'buy' &&
|
245
|
+
oh.key?(:done_at) &&
|
246
|
+
Time.now.strftime('%Y') == Time.parse(oh[:done_at]).strftime('%Y')
|
247
|
+
end
|
248
|
+
order_hist_buy_usd_tot = oh_buy_ytd_arr.map do |oh|
|
249
|
+
oh[:executed_value].to_f
|
250
|
+
end.sum
|
251
|
+
|
252
|
+
# Snag all orders sold YTD
|
243
253
|
oh_sold_ytd_arr = order_history.select do |oh|
|
244
254
|
oh[:side] == 'sell' &&
|
245
255
|
oh.key?(:done_at) &&
|
246
256
|
Time.now.strftime('%Y') == Time.parse(oh[:done_at]).strftime('%Y')
|
247
257
|
end
|
258
|
+
# TODO: ensure oh_buy_ytd_arr && oh_sold_ytd_arr are same length
|
259
|
+
# otherwise it throws off the profit calculations
|
248
260
|
order_hist_sold_ytd = oh_sold_ytd_arr.length
|
261
|
+
order_hist_sold_usd_tot = oh_sold_ytd_arr.map do |oh|
|
262
|
+
oh[:executed_value].to_f
|
263
|
+
end.sum
|
264
|
+
order_hist_profit_usd_ytd = order_hist_sold_usd_tot - order_hist_buy_usd_tot
|
265
|
+
order_hist_profit_usd_ytd_out = format('%0.2f', order_hist_profit_usd_ytd)
|
249
266
|
|
250
267
|
# Snag all session orders sold YTD
|
251
268
|
oh_meta_sold_arr = order_history_meta.select do |ohm|
|
@@ -314,6 +331,15 @@ module Cryptum
|
|
314
331
|
# OK, now let's tally up everything...
|
315
332
|
twenty_four_hrs_ago = Time.now - 86_400
|
316
333
|
|
334
|
+
# Snag all orders bought within past 24 hrs
|
335
|
+
oh_buy_twenty_four_arr = []
|
336
|
+
unless oh_buy_ytd_arr.empty?
|
337
|
+
oh_buy_twenty_four_arr = oh_buy_ytd_arr.select do |o|
|
338
|
+
Time.parse(o[:done_at]) >= twenty_four_hrs_ago
|
339
|
+
end
|
340
|
+
end
|
341
|
+
# order_hist_buy_twenty_four = oh_buy_twenty_four_arr.length
|
342
|
+
|
317
343
|
# Snag all orders sold within past 24 hrs
|
318
344
|
oh_sold_twenty_four_arr = []
|
319
345
|
unless oh_sold_ytd_arr.empty?
|
@@ -323,6 +349,17 @@ module Cryptum
|
|
323
349
|
end
|
324
350
|
order_hist_sold_twenty_four = oh_sold_twenty_four_arr.length
|
325
351
|
|
352
|
+
# Calculate 24h gain
|
353
|
+
order_hist_buy_usd_24h = oh_buy_twenty_four_arr.map do |oh|
|
354
|
+
oh[:excuted_value].to_f
|
355
|
+
end.sum
|
356
|
+
|
357
|
+
order_hist_sold_usd_24h = oh_sold_twenty_four_arr.map do |oh|
|
358
|
+
oh[:executed_value].to_f
|
359
|
+
end.sum
|
360
|
+
order_hist_profit_usd_24h = order_hist_sold_usd_24h - order_hist_buy_usd_24h
|
361
|
+
order_hist_profit_usd_24h_out = format('%0.2f', order_hist_profit_usd_24h)
|
362
|
+
|
326
363
|
# Snag all session orders sold within past 24 hrs
|
327
364
|
ohm_sold_twenty_four_arr = []
|
328
365
|
unless oh_meta_sold_arr.empty?
|
@@ -606,10 +643,9 @@ module Cryptum
|
|
606
643
|
string: ''.ljust(col_just1, ' ')
|
607
644
|
)
|
608
645
|
|
609
|
-
tot_header_str = "TOTAL OPEN: #{total_to_sell}
|
646
|
+
tot_header_str = "TOTAL OPEN: #{total_to_sell} | "
|
610
647
|
tot_header_str += "SOLD 24h: #{order_hist_sold_twenty_four} YTD: #{order_hist_sold_ytd} | "
|
611
|
-
tot_header_str +=
|
612
|
-
tot_header_str += 'AvgRndT DAYS: TBD'
|
648
|
+
tot_header_str += "PROF 24h: $#{order_hist_profit_usd_24h_out} YTD: $#{order_hist_profit_usd_ytd_out}"
|
613
649
|
order_execute_win.setpos(
|
614
650
|
out_line_no,
|
615
651
|
Cryptum::UI.col_center(str: tot_header_str)
|
data/lib/cryptum/version.rb
CHANGED