cryptum 0.0.456 → 0.0.458

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e3f976fdd41eb06a0f31c77a0f98052dd3b75b816cfd4a7ada3109c046f33f4
4
- data.tar.gz: 986148e3bae656c4d32420c2b4d9dcc9e36d6680eb32242012bdfad73bb6d1eb
3
+ metadata.gz: 3c04633f954adc6a1d46177ffad69796738a01be430071efc785226f8f1fd116
4
+ data.tar.gz: 804989be187108d606c9784aae5149dea03a302b0bd937e5115810a0714d74a7
5
5
  SHA512:
6
- metadata.gz: 27280b8e5c51c90a3d46452dd5c449f3558c31306c3afd7411a7ac38db0accc2a3e70721b37892fe2e3ab839c2816215cda28220db3f611d5b1249b52dd7ba47
7
- data.tar.gz: 919f242f11f071e1e5a5f211e509b85759ef3f3696c1073c67896a6c90efa01f8f671c353dc10b3a92771435e90159da81dc8e6d58026248bef388a57d230014
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: 486.2
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: 93
17
+ Max: 102
18
18
  Metrics/MethodLength:
19
- Max: 457
19
+ Max: 485
20
20
  Metrics/ModuleLength:
21
- Max: 467
21
+ Max: 495
22
22
  Metrics/PerceivedComplexity:
23
- Max: 91
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
- # Snad all orders sold YTD
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} TPMD: $TBD | "
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 += 'PROF 24h: $TBD Y: $TBD | '
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptum
4
- VERSION = '0.0.456'
4
+ VERSION = '0.0.458'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.456
4
+ version: 0.0.458
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.