cryptum 0.0.456 → 0.0.457

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e3f976fdd41eb06a0f31c77a0f98052dd3b75b816cfd4a7ada3109c046f33f4
4
- data.tar.gz: 986148e3bae656c4d32420c2b4d9dcc9e36d6680eb32242012bdfad73bb6d1eb
3
+ metadata.gz: a7dda352965440c606383099a1ad8affc595e83b3126b1d9a17a5a9e80ea93f8
4
+ data.tar.gz: 9680be3d642bdbf69833c3e61d1d25aa908a2259f421138106c42a554de7069e
5
5
  SHA512:
6
- metadata.gz: 27280b8e5c51c90a3d46452dd5c449f3558c31306c3afd7411a7ac38db0accc2a3e70721b37892fe2e3ab839c2816215cda28220db3f611d5b1249b52dd7ba47
7
- data.tar.gz: 919f242f11f071e1e5a5f211e509b85759ef3f3696c1073c67896a6c90efa01f8f671c353dc10b3a92771435e90159da81dc8e6d58026248bef388a57d230014
6
+ metadata.gz: fb4e777ff41816b922ce7a98323c4ea33142abb623cd3e9bab90433e7436fdcf06d538c8794c7c3360234494ae6a062ddaa67a701ae718f8628767232c129b5f
7
+ data.tar.gz: 4cbf5bb9dd5c144b92b8165e65fd830d6c84e9cd479e3e65ebae6c1dc4d10c4b675609fb8d292dd706e79398d9f59aa15e906ad78de416eb6d2d8a1bddc4dcf9
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,28 @@ 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
248
258
  order_hist_sold_ytd = oh_sold_ytd_arr.length
259
+ order_hist_sold_usd_tot = oh_sold_ytd_arr.map do |oh|
260
+ oh[:executed_value].to_f
261
+ end.sum
262
+ order_hist_profit_usd_ytd = order_hist_sold_usd_tot - order_hist_buy_usd_tot
263
+ order_hist_profit_usd_ytd_out = format('%0.2f', order_hist_profit_usd_ytd)
249
264
 
250
265
  # Snag all session orders sold YTD
251
266
  oh_meta_sold_arr = order_history_meta.select do |ohm|
@@ -314,6 +329,15 @@ module Cryptum
314
329
  # OK, now let's tally up everything...
315
330
  twenty_four_hrs_ago = Time.now - 86_400
316
331
 
332
+ # Snag all orders bought within past 24 hrs
333
+ oh_buy_twenty_four_arr = []
334
+ unless oh_buy_ytd_arr.empty?
335
+ oh_buy_twenty_four_arr = oh_buy_ytd_arr.select do |o|
336
+ Time.parse(o[:done_at]) >= twenty_four_hrs_ago
337
+ end
338
+ end
339
+ # order_hist_buy_twenty_four = oh_buy_twenty_four_arr.length
340
+
317
341
  # Snag all orders sold within past 24 hrs
318
342
  oh_sold_twenty_four_arr = []
319
343
  unless oh_sold_ytd_arr.empty?
@@ -323,6 +347,17 @@ module Cryptum
323
347
  end
324
348
  order_hist_sold_twenty_four = oh_sold_twenty_four_arr.length
325
349
 
350
+ # Calculate 24h gain
351
+ order_hist_buy_usd_24h = oh_buy_twenty_four_arr.map do |oh|
352
+ oh[:excuted_value].to_f
353
+ end.sum
354
+
355
+ order_hist_sold_usd_24h = oh_sold_twenty_four_arr.map do |oh|
356
+ oh[:executed_value].to_f
357
+ end.sum
358
+ order_hist_profit_usd_24h = order_hist_sold_usd_24h - order_hist_buy_usd_24h
359
+ order_hist_profit_usd_24h_out = format('%0.2f', order_hist_profit_usd_24h)
360
+
326
361
  # Snag all session orders sold within past 24 hrs
327
362
  ohm_sold_twenty_four_arr = []
328
363
  unless oh_meta_sold_arr.empty?
@@ -608,7 +643,7 @@ module Cryptum
608
643
 
609
644
  tot_header_str = "TOTAL OPEN: #{total_to_sell} TPMD: $TBD | "
610
645
  tot_header_str += "SOLD 24h: #{order_hist_sold_twenty_four} YTD: #{order_hist_sold_ytd} | "
611
- tot_header_str += 'PROF 24h: $TBD Y: $TBD | '
646
+ tot_header_str += "PROF 24h: $#{order_hist_profit_usd_24h_out} YTD: $#{order_hist_profit_usd_ytd_out} | "
612
647
  tot_header_str += 'AvgRndT DAYS: TBD'
613
648
  order_execute_win.setpos(
614
649
  out_line_no,
@@ -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.457'
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.457
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.