cryptum 0.0.352 → 0.0.353

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: a23224cc73178c4663be48c1acc1f32b206b72b08773267a32d5a17c14c6f5b1
4
- data.tar.gz: 5f19b50281cbe3ef284b1a8dfa64d0cf606dfd02687ca9b1c16fcd49edaab275
3
+ metadata.gz: 47dcac5945211f744cc4279a0bfe3ebec3cec83ff9fe612f34628c1d4affc5a9
4
+ data.tar.gz: ab40b9455aa8c6513ac5682c7015487fd1ca1ecef4b1b60273595c8a2d568024
5
5
  SHA512:
6
- metadata.gz: 28424b87e5b2d603294746caedd30e2463643ea320044a2305f482e2f2a7d25f8661eac42d3b6c58fff2149b771c3eb54a9f433386f3bee9175c36dfd730ee13
7
- data.tar.gz: 49878b0040b787f9799e9d90785876da078a990d1a6b693d2b4180aed5d4387730b9529c567edfb19fde68231910e81279546341cd2c396af341e95b228e4b54
6
+ metadata.gz: d849666e7e611db30936bd6f284e684527c62cb6011537b3843dfc2ed0352a37c6b67113eda1a0c41d88f69c0053b79312e6ce47675c303b2a1e8bc7e3ec244f
7
+ data.tar.gz: db2deff5a6c5ce62de9e01dc1d2b2952057b94670e4a878dd4604b57634e958b72022b60589f30052bec185d63221563962efb9bc6921e6d2c38da8d31fee02b
data/Gemfile CHANGED
@@ -12,7 +12,7 @@ gemspec
12
12
  # to build appropriately. Defer to ./reinstall_coinbot_gemset.sh
13
13
  # to review these custom flags
14
14
  gem 'addressable', '2.8.1'
15
- gem 'bundler', '>=2.3.26'
15
+ gem 'bundler', '>=2.4.1'
16
16
  gem 'bundler-audit', '0.9.1'
17
17
  gem 'curses', '1.4.4'
18
18
  gem 'eventmachine', '1.2.7'
@@ -26,10 +26,10 @@ gem 'rdoc', '6.5.0'
26
26
  gem 'require_all', '3.0.0'
27
27
  gem 'rest-client', '2.1.0'
28
28
  gem 'rspec', '3.12.0'
29
- gem 'rubocop', '1.41.0'
29
+ gem 'rubocop', '1.41.1'
30
30
  gem 'rubocop-rake', '0.6.0'
31
31
  gem 'rubocop-rspec', '2.16.0'
32
- gem 'ruby-prof', '1.4.4'
32
+ gem 'ruby-prof', '1.4.5'
33
33
  gem 'rvm', '1.11.3.9'
34
34
  gem 'sinatra', '3.0.5'
35
35
  gem 'thin', '1.8.1'
@@ -5,4 +5,4 @@ prod:
5
5
  sandbox:
6
6
  api_key: ''
7
7
  api_secret: ''
8
- api_passphrase: ''
8
+ api_passphrase: ''
@@ -0,0 +1 @@
1
+ bearer_token: ''
@@ -65,6 +65,9 @@ module Cryptum
65
65
 
66
66
  when :tpm
67
67
  limit_price = target_symbol_price
68
+ # TODO: Ensure previous order price
69
+ # on last _open order_ if applicable
70
+ # is greater than this one.
68
71
  order_type = :tpm
69
72
  when :gtfo
70
73
  # Attempt to get in front of falling price.
@@ -0,0 +1,156 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'rest-client'
5
+
6
+ module Cryptum
7
+ # This plugin is used for interacting w/ OpenAI's REST API
8
+ # This is based on the following OpenAI API Specification:
9
+ # https://api.openai.com/v1
10
+ module OpenAI
11
+ # Supported Method Parameters::
12
+ # open_ai_rest_call(
13
+ # env: 'required - env object containing OpenAI Bearer token',
14
+ # option_choice = 'required - option_choice object in case proxy is configured',
15
+ # http_method: 'optional HTTP method (defaults to GET)
16
+ # rest_call: 'required rest call to make per the schema',
17
+ # params: 'optional params passed in the URI or HTTP Headers',
18
+ # http_body: 'optional HTTP body sent in HTTP methods that support it e.g. POST'
19
+ # )
20
+
21
+ private_class_method def self.open_ai_rest_call(opts = {})
22
+ env = opts[:env]
23
+ option_choice = opts[:option_choice]
24
+ http_method = if opts[:http_method].nil?
25
+ :GET
26
+ else
27
+ opts[:http_method].to_s.upcase.scrub.strip.chomp.to_sym
28
+ end
29
+ rest_call = opts[:rest_call].to_s.scrub
30
+ params = opts[:params]
31
+ http_body = opts[:http_body].to_s.scrub
32
+ base_open_ai_api_uri = 'https://api.openai.com/v1'
33
+ bearer_token = env[:open_ai_bearer_token]
34
+
35
+ if option_choice.proxy
36
+ rest_client = RestClient
37
+ rest_client.proxy = option_choice.proxy
38
+ rest_client_request = rest_client::Request
39
+ else
40
+ rest_client_request = RestClient::Request
41
+ end
42
+
43
+ case http_method
44
+ when :GET
45
+ response = rest_client_request.execute(
46
+ method: :GET,
47
+ url: "#{base_open_ai_api_uri}/#{rest_call}",
48
+ headers: {
49
+ content_type: 'application/json; charset=UTF-8',
50
+ authorization: "Bearer #{bearer_token}",
51
+ params: params
52
+ },
53
+ verify_ssl: false
54
+ )
55
+
56
+ when :POST
57
+ response = rest_client_request.execute(
58
+ method: :POST,
59
+ url: "#{base_open_ai_api_uri}/#{rest_call}",
60
+ headers: {
61
+ content_type: 'application/json; charset=UTF-8',
62
+ authorization: "Bearer #{bearer_token}"
63
+ },
64
+ payload: http_body,
65
+ verify_ssl: false
66
+ )
67
+
68
+ else
69
+ raise @@logger.error("Unsupported HTTP Method #{http_method} for #{self} Plugin")
70
+ end
71
+ response
72
+ rescue RestClient::ExceptionWithResponse => e
73
+ File.open('/tmp/cryptum-errors.txt', 'a') do |f|
74
+ f.puts Time.now.strftime('%Y-%m-%d %H:%M:%S.%N %z')
75
+ f.puts "Module: #{self}"
76
+ f.puts "URL: #{api_endpoint}#{api_call}"
77
+ f.puts "PARAMS: #{params.inspect}"
78
+ f.puts "HTTP POST BODY: #{http_body.inspect}" if http_body != ''
79
+ f.puts "#{e}\n#{e.response}\n\n\n"
80
+ end
81
+ rescue StandardError => e
82
+ raise e
83
+ end
84
+
85
+ # Supported Method Parameters::
86
+ # models = PWN::Plugins::OpenAI.get_models(
87
+ # env: 'required - env object containing OpenAI Bearer token',
88
+ # option_choice = 'required - option_choice object in case proxy is configured',
89
+ # )
90
+
91
+ public_class_method def self.get_models(opts = {})
92
+ env = opts[:env]
93
+ option_choice = opts[:option_choice]
94
+
95
+ response = open_ai_rest_call(
96
+ env: env,
97
+ option_choice: option_choice,
98
+ http_method: :post,
99
+ rest_call: 'models'
100
+ )
101
+
102
+ JSON.parse(response, symbolize_names: true)
103
+ rescue StandardError => e
104
+ raise e
105
+ end
106
+
107
+ # Supported Method Parameters::
108
+ # response = PWN::Plugins::OpenAI.chat_gpt(
109
+ # env: 'required - env object containing OpenAI Bearer token',
110
+ # option_choice = 'required - option_choice object in case proxy is configured',
111
+ # request: 'required - message to ChatGPT'
112
+ # )
113
+
114
+ public_class_method def self.chat_gpt(opts = {})
115
+ env = opts[:env]
116
+ option_choice = opts[:option_choice]
117
+ request = opts[:request]
118
+
119
+ http_body = {
120
+ model: 'text-davinci-003',
121
+ prompt: request,
122
+ temperature: 0,
123
+ max_tokens: 1024
124
+ }
125
+
126
+ response = open_ai_rest_call(
127
+ env: env,
128
+ option_choice: option_choice,
129
+ http_method: :post,
130
+ rest_call: 'completions',
131
+ http_body: http_body.to_json
132
+ )
133
+
134
+ JSON.parse(response, symbolize_names: true)
135
+ rescue StandardError => e
136
+ raise e
137
+ end
138
+
139
+ # Display Usage for this Module
140
+
141
+ public_class_method def self.help
142
+ puts "USAGE:
143
+ models = PWN::Plugins::OpenAI.get_models(
144
+ env: 'required - env object containing OpenAI Bearer token',
145
+ option_choice = 'required - option_choice object in case proxy is configured',
146
+ )
147
+
148
+ response = #{self}.chat_gpt(
149
+ env: 'required - env object containing OpenAI Bearer token',
150
+ option_choice = 'required - option_choice object in case proxy is configured',
151
+ request: 'required - message to ChatGPT'
152
+ )
153
+ "
154
+ end
155
+ end
156
+ end
@@ -184,6 +184,15 @@ module Cryptum
184
184
  env = yaml_conf[:sandbox] if option_choice.sandbox
185
185
  env[:env] = :sandbox if option_choice.sandbox
186
186
 
187
+ open_ai_yaml_conf_file = "#{option_choice.session_root}/etc/open_ai.yaml"
188
+ if File.exist?(open_ai_yaml_conf_file)
189
+ open_ai_yaml_conf = YAML.load_file(
190
+ open_ai_yaml_conf_file,
191
+ symbolize_names: true
192
+ )
193
+ env[:open_ai_bearer_token] = open_ai_yaml_conf[:bearer_token]
194
+ end
195
+
187
196
  env
188
197
  rescue StandardError => e
189
198
  raise e
@@ -41,10 +41,6 @@ module Cryptum
41
41
  # order_difference = 0
42
42
  if buy_total > sell_total
43
43
  order_difference = buy_total - sell_total
44
- # Too Expensive
45
- # order_difference = Cryptum.beautify_large_number(
46
- # value: order_difference
47
- # ).to_i
48
44
  motivation = 'BUYING THE DIP'
49
45
  indicator_hash[:color] = :red
50
46
  if event_history.bullish_trend
@@ -55,10 +51,6 @@ module Cryptum
55
51
  indicator_hash[:status] = "B#{Cryptum.up_arrow}"
56
52
  elsif buy_total < sell_total
57
53
  order_difference = sell_total - buy_total
58
- # Too Expensive
59
- # order_difference = Cryptum.beautify_large_number(
60
- # value: order_difference
61
- # ).to_i
62
54
  motivation = 'REKT'
63
55
  indicator_hash[:color] = :red
64
56
  if event_history.bullish_trend
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptum
4
- VERSION = '0.0.352'
4
+ VERSION = '0.0.353'
5
5
  end
data/lib/cryptum.rb CHANGED
@@ -15,6 +15,7 @@ module Cryptum
15
15
  require 'cryptum/event'
16
16
  require 'cryptum/log'
17
17
  require 'cryptum/matrix'
18
+ require 'cryptum/open_ai'
18
19
  require 'cryptum/option'
19
20
  require 'cryptum/order_book'
20
21
  require 'cryptum/portfolio'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.352
4
+ version: 0.0.353
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-21 00:00:00.000000000 Z
11
+ date: 2022-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.3.26
33
+ version: 2.4.1
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 2.3.26
40
+ version: 2.4.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler-audit
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -226,14 +226,14 @@ dependencies:
226
226
  requirements:
227
227
  - - '='
228
228
  - !ruby/object:Gem::Version
229
- version: 1.41.0
229
+ version: 1.41.1
230
230
  type: :runtime
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - '='
235
235
  - !ruby/object:Gem::Version
236
- version: 1.41.0
236
+ version: 1.41.1
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: rubocop-rake
239
239
  requirement: !ruby/object:Gem::Requirement
@@ -268,14 +268,14 @@ dependencies:
268
268
  requirements:
269
269
  - - '='
270
270
  - !ruby/object:Gem::Version
271
- version: 1.4.4
271
+ version: 1.4.5
272
272
  type: :runtime
273
273
  prerelease: false
274
274
  version_requirements: !ruby/object:Gem::Requirement
275
275
  requirements:
276
276
  - - '='
277
277
  - !ruby/object:Gem::Version
278
- version: 1.4.4
278
+ version: 1.4.5
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: rvm
281
281
  requirement: !ruby/object:Gem::Requirement
@@ -404,6 +404,7 @@ files:
404
404
  - etc/bot_confs/.gitkeep
405
405
  - etc/bot_confs/BOT_CONF.TEMPLATE
406
406
  - etc/coinbase_pro.yaml.EXAMPLE
407
+ - etc/open_ai.yaml.EXAMPLE
407
408
  - git_commit.sh
408
409
  - lib/cryptum.rb
409
410
  - lib/cryptum/api.rb
@@ -423,6 +424,7 @@ files:
423
424
  - lib/cryptum/event/sell.rb
424
425
  - lib/cryptum/log.rb
425
426
  - lib/cryptum/matrix.rb
427
+ - lib/cryptum/open_ai.rb
426
428
  - lib/cryptum/option.rb
427
429
  - lib/cryptum/option/choice.rb
428
430
  - lib/cryptum/order_book.rb
@@ -488,7 +490,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
488
490
  - !ruby/object:Gem::Version
489
491
  version: '0'
490
492
  requirements: []
491
- rubygems_version: 3.3.26
493
+ rubygems_version: 3.4.1
492
494
  signing_key:
493
495
  specification_version: 4
494
496
  summary: Coinbase Pro High-Frequency Trading Bot