cryptum 0.0.358 → 0.0.360

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +16 -0
  3. data/.gitignore +30 -0
  4. data/.rspec +3 -0
  5. data/.rspec_status +0 -0
  6. data/.rubocop.yml +31 -0
  7. data/.rubocop_todo.yml +36 -0
  8. data/.ruby-gemset +1 -0
  9. data/.ruby-version +1 -0
  10. data/CODE_OF_CONDUCT.md +84 -0
  11. data/Gemfile +38 -0
  12. data/LICENSE +674 -0
  13. data/README.md +87 -0
  14. data/Rakefile +19 -0
  15. data/bin/cryptum +73 -0
  16. data/bin/cryptum-forecast +200 -0
  17. data/bin/cryptum-repl +73 -0
  18. data/bin/cryptum_autoinc_version +38 -0
  19. data/build_cryptum_gem.sh +58 -0
  20. data/cryptum.gemspec +52 -0
  21. data/cryptum_container.sh +1 -0
  22. data/docker/cryptum.json +60 -0
  23. data/docker/cryptum_container.sh +59 -0
  24. data/docker/packer_secrets.json.EXAMPLE +7 -0
  25. data/docker/provisioners/cryptum.sh +11 -0
  26. data/docker/provisioners/docker_bashrc.sh +2 -0
  27. data/docker/provisioners/docker_rvm.sh +22 -0
  28. data/docker/provisioners/init_image.sh +28 -0
  29. data/docker/provisioners/post_install.sh +6 -0
  30. data/docker/provisioners/ruby.sh +16 -0
  31. data/docker/provisioners/upload_globals.sh +49 -0
  32. data/etc/bot_confs/.gitkeep +0 -0
  33. data/etc/bot_confs/BOT_CONF.TEMPLATE +10 -0
  34. data/etc/coinbase_pro.yaml.EXAMPLE +8 -0
  35. data/etc/open_ai.yaml.EXAMPLE +1 -0
  36. data/git_commit.sh +22 -0
  37. data/lib/cryptum/api.rb +688 -0
  38. data/lib/cryptum/bot_conf.rb +197 -0
  39. data/lib/cryptum/event/bot_conf.rb +34 -0
  40. data/lib/cryptum/event/buy.rb +145 -0
  41. data/lib/cryptum/event/cancel.rb +35 -0
  42. data/lib/cryptum/event/exit.rb +35 -0
  43. data/lib/cryptum/event/gtfo.rb +36 -0
  44. data/lib/cryptum/event/history.rb +108 -0
  45. data/lib/cryptum/event/key_press.rb +64 -0
  46. data/lib/cryptum/event/order_book.rb +34 -0
  47. data/lib/cryptum/event/pane.rb +65 -0
  48. data/lib/cryptum/event/parse.rb +181 -0
  49. data/lib/cryptum/event/scroll.rb +200 -0
  50. data/lib/cryptum/event/sell.rb +124 -0
  51. data/lib/cryptum/event.rb +27 -0
  52. data/lib/cryptum/log.rb +34 -0
  53. data/lib/cryptum/matrix.rb +181 -0
  54. data/lib/cryptum/open_ai.rb +156 -0
  55. data/lib/cryptum/option/choice.rb +28 -0
  56. data/lib/cryptum/option.rb +206 -0
  57. data/lib/cryptum/order_book/generate.rb +114 -0
  58. data/lib/cryptum/order_book/indicator.rb +15 -0
  59. data/lib/cryptum/order_book/market_trend.rb +137 -0
  60. data/lib/cryptum/order_book/profit_margin.rb +55 -0
  61. data/lib/cryptum/order_book.rb +19 -0
  62. data/lib/cryptum/portfolio/balance.rb +123 -0
  63. data/lib/cryptum/portfolio.rb +15 -0
  64. data/lib/cryptum/ui/command.rb +314 -0
  65. data/lib/cryptum/ui/key_press_event.rb +33 -0
  66. data/lib/cryptum/ui/market_trend.rb +77 -0
  67. data/lib/cryptum/ui/order_execute_details.rb +297 -0
  68. data/lib/cryptum/ui/order_execution.rb +573 -0
  69. data/lib/cryptum/ui/order_plan.rb +512 -0
  70. data/lib/cryptum/ui/order_plan_details.rb +240 -0
  71. data/lib/cryptum/ui/order_timer.rb +136 -0
  72. data/lib/cryptum/ui/portfolio.rb +221 -0
  73. data/lib/cryptum/ui/signal_engine.rb +109 -0
  74. data/lib/cryptum/ui/terminal_window.rb +111 -0
  75. data/lib/cryptum/ui/ticker.rb +319 -0
  76. data/lib/cryptum/ui.rb +343 -0
  77. data/lib/cryptum/version.rb +5 -0
  78. data/lib/cryptum/web_sock/coinbase.rb +104 -0
  79. data/lib/cryptum/web_sock/event_machine.rb +276 -0
  80. data/lib/cryptum/web_sock.rb +16 -0
  81. data/lib/cryptum.rb +120 -0
  82. data/order_books/.gitkeep +0 -0
  83. data/reinstall_cryptum_gemset.sh +29 -0
  84. data/spec/lib/cryptum/api_spec.rb +10 -0
  85. data/spec/lib/cryptum/event_spec.rb +10 -0
  86. data/spec/lib/cryptum/log_spec.rb +10 -0
  87. data/spec/lib/cryptum/option_spec.rb +10 -0
  88. data/spec/lib/cryptum/order_book/generate_spec.rb +10 -0
  89. data/spec/lib/cryptum/order_book/market_trend_spec.rb +10 -0
  90. data/spec/lib/cryptum/order_book_spec.rb +10 -0
  91. data/spec/lib/cryptum/ui/command_spec.rb +10 -0
  92. data/spec/lib/cryptum/ui/ticker_spec.rb +10 -0
  93. data/spec/lib/cryptum/ui_spec.rb +10 -0
  94. data/spec/lib/cryptum/web_sock_spec.rb +10 -0
  95. data/spec/lib/cryptum_spec.rb +10 -0
  96. data/spec/spec_helper.rb +3 -0
  97. data/upgrade_Gemfile_gems.sh +20 -0
  98. data/upgrade_cryptum.sh +13 -0
  99. data/upgrade_gem.sh +4 -0
  100. data/upgrade_ruby.sh +45 -0
  101. metadata +112 -9
@@ -0,0 +1,59 @@
1
+ #!/bin/bash --login
2
+ debug=false
3
+ export PACKER_LOG=1
4
+ set -e
5
+
6
+ function usage() {
7
+ echo -e "USAGE: ${0} <build || debug>"
8
+ exit 1
9
+ }
10
+
11
+ function pack() {
12
+ packer_provider_template=$1
13
+ debug=$2
14
+ packer_secrets='./packer_secrets.json'
15
+
16
+ if [[ $CRYPTUM_ROOT == '' ]]; then
17
+ if [[ ! -d '/opt/cryptum' ]]; then
18
+ cryptum_root=$(pwd)
19
+ else
20
+ cryptum_root='/opt/cryptum'
21
+ fi
22
+ else
23
+ cryptum_root="${CRYPTUM_ROOT}"
24
+ fi
25
+
26
+ cd $cryptum_root/docker
27
+
28
+ if $debug; then
29
+ packer build \
30
+ -debug \
31
+ -only docker \
32
+ -var "box_version=latest" \
33
+ -var "ssh_auth_sock=${SSH_AUTH_SOCK}" \
34
+ -var-file=$packer_secrets \
35
+ $packer_provider_template
36
+ else
37
+ packer build \
38
+ -only docker \
39
+ -var "box_version=latest" \
40
+ -var "ssh_auth_sock=${SSH_AUTH_SOCK}" \
41
+ -var-file=$packer_secrets \
42
+ $packer_provider_template
43
+ fi
44
+ }
45
+
46
+ if [[ $# < 1 ]]; then
47
+ usage
48
+ fi
49
+
50
+ action="${1}"
51
+
52
+ case $action in
53
+ 'build')
54
+ pack ./cryptum.json false;;
55
+ 'debug')
56
+ pack ./cryptum.json true;;
57
+ '*')
58
+ usage;;
59
+ esac
@@ -0,0 +1,7 @@
1
+ {
2
+ "repository": "AWS ECR Repository to Upload Container",
3
+ "aws_access_key": "AWS ACCESS KEY",
4
+ "aws_secret_key": "AWS SECRET ACCESS KEY"
5
+ "aws_token": "AWS STS TOKEN"
6
+ "aws_profile": "AWS Shared Credentials Profile Used for Communication"
7
+ }
@@ -0,0 +1,11 @@
1
+ #!/bin/bash --login
2
+ source /etc/profile.d/globals.sh
3
+
4
+ cryptum_root="${CRYPTUM_ROOT}"
5
+
6
+ echo "Installing cryptum Dependencies..."
7
+ $screen_cmd "${apt} install -y tmux ${assess_update_errors}"
8
+ grok_error
9
+
10
+ sudo /bin/bash --login -c "cd ${cryptum_root} && ./build_cryptum_gem.sh"
11
+ /bin/bash --login -c "cd ${cryptum_root} && ./init_cryptum_web.sh start"
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ echo 'source /etc/profile.d/rvm.sh' >> ~/.bashrc
@@ -0,0 +1,22 @@
1
+ #!/bin/bash --login
2
+ source /etc/profile.d/globals.sh
3
+
4
+ key1='409B6B1796C275462A1703113804BB82D39DC0E3'
5
+ key2='7D2BAF1CF37B13E2069D6956105BD0E739499BDB'
6
+
7
+ # sudo /bin/bash --login -c "gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys ${key1} ${key2}"
8
+ $screen_cmd "curl -sSL https://rvm.io/mpapis.asc | sudo gpg2 --import - ${assess_update_errors}"
9
+ grok_error
10
+
11
+ $screen_cmd "curl -sSL https://rvm.io/pkuczynski.asc | sudo gpg2 --import - ${assess_update_errors}"
12
+ grok_error
13
+
14
+ $screen_cmd "echo -e \"trust\n5\ny\n\" | gpg2 --no-tty --command-fd 0 --edit-key ${key1} ${assess_update_errors}"
15
+ grok_error
16
+
17
+ $screen_cmd "echo -e \"trust\n5\ny\n\" | gpg2 --no-tty --command-fd 0 --edit-key ${key2} ${assess_update_errors}"
18
+ grok_error
19
+
20
+ # Multi-user install required due to the need to run MSFRPCD as root w/in metasploit gemset
21
+ $screen_cmd "curl -sSL https://get.rvm.io | sudo bash -s latest ${assess_update_errors}"
22
+ grok_error
@@ -0,0 +1,28 @@
1
+ #!/bin/bash --login
2
+ source /etc/profile.d/globals.sh
3
+
4
+ cryptum_env_file='/etc/profile.d/cryptum_envs.sh'
5
+
6
+ $screen_cmd "chmod 755 ${cryptum_env_file} ${assess_update_errors}"
7
+ grok_error
8
+
9
+ $screen_cmd "${apt} install -y curl gnupg2 openssh-server net-tools"
10
+ grok_error
11
+
12
+ $screen_cmd "service ssh start"
13
+ grok_error
14
+
15
+ $screen_cmd "${apt} dist-upgrade -y ${assess_update_errors}"
16
+ grok_error
17
+
18
+ $screen_cmd "${apt} full-upgrade -y ${assess_update_errors}"
19
+ grok_error
20
+
21
+ $screen_cmd "useradd -m -s /bin/bash admin ${assess_update_errors}"
22
+ grok_error
23
+
24
+ $screen_cmd "usermod -aG sudo admin ${assess_update_errors}"
25
+ grok_error
26
+
27
+ # Restrict Home Directory
28
+ sudo chmod 700 /home/admin
@@ -0,0 +1,6 @@
1
+ #!/bin/bash --login
2
+ # TODO: Cleanup up history, cloning keys, etc.
3
+
4
+ ln -sf /dev/null /root/.bash_history
5
+ ln -sf /dev/null /home/admin/.bash_history
6
+ history -c
@@ -0,0 +1,16 @@
1
+ #!/bin/bash --login
2
+ source /etc/profile.d/globals.sh
3
+
4
+ cryptum_root="${CRYPTUM_ROOT}"
5
+
6
+ $screen_cmd "${apt} install -y build-essential bison openssl libreadline-dev curl git-core git zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev autoconf libc6-dev ncurses-dev automake libtool libpcap-dev libsqlite3-dev libgmp-dev ${assess_update_errors}"
7
+ grok_error
8
+
9
+ # Clone now to get the proper version of Ruby
10
+ sudo /bin/bash --login -c "mkdir /root/.ssh"
11
+ sudo /bin/bash --login -c "ssh-keyscan -H github.com > /root/.ssh/known_hosts"
12
+ sudo /bin/bash --login -c "git clone ssh://git@github.com/0dayinc/cryptum.git ${cryptum_root}"
13
+
14
+ ruby_version=`cat ${cryptum_root}/.ruby-version`
15
+ ruby_gemset=`cat ${cryptum_root}/.ruby-gemset`
16
+ sudo /bin/bash --login -c "source /etc/profile.d/rvm.sh && rvm install ruby-${ruby_version}"
@@ -0,0 +1,49 @@
1
+ #!/bin/bash --login
2
+ cryptum_env_file='/etc/profile.d/cryptum_envs.sh'
3
+
4
+ apt update && apt install -y sudo screen apt-utils
5
+
6
+ sudo tee -a $cryptum_env_file << EOF
7
+ export SSH_AUTH_SOCK=/ssh-agent
8
+ export CRYPTUM_ROOT='/opt/cryptum'
9
+ EOF
10
+
11
+ sudo tee -a /etc/profile.d/globals.sh << 'EOF'
12
+ #!/bin/bash --login
13
+ export DEBIAN_FRONTEND=noninteractive
14
+ export TERM=xterm
15
+
16
+ screen_session=`basename -- ${0} .sh`
17
+ screen_cmd="screen -T xterm -L -S ${screen_session} -d -m sudo /bin/bash --login -c"
18
+ assess_update_errors='|| echo IMAGE_ABORT && exit 1'
19
+ debconf_set='/usr/bin/debconf-set-selections'
20
+ apt="DEBIAN_FRONTEND=noninteractive apt -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confnew'"
21
+
22
+ grok_error() {
23
+ while true; do
24
+ # Wait until screen exits session
25
+ screen -ls | grep $screen_session
26
+ if [[ $? == 1 ]]; then
27
+ grep IMAGE_ABORT screenlog.*
28
+ if [[ $? == 0 ]]; then
29
+ echo "Failures encountered in $(ls screenlog.*) for ${screen_session} session!!!"
30
+ cat screenlog.*
31
+ rm screenlog.*
32
+ exit 1
33
+ else
34
+ echo "No errors in $(ls screenlog.*) detected...moving onto the next."
35
+ ls screenlog.* > /dev/null 2>&1
36
+ if [[ $? == 0 ]]; then
37
+ rm screenlog.*
38
+ fi
39
+ break
40
+ fi
41
+ else
42
+ printf '.'
43
+ sleep 9
44
+ fi
45
+ done
46
+ }
47
+ EOF
48
+
49
+ sudo chmod 755 /etc/profile.d/globals.sh
File without changes
@@ -0,0 +1,10 @@
1
+ #---------------------------------------#
2
+ # Enable Artifical Intelligence #
3
+ #---------------------------------------#
4
+ artifical_intelligence: true
5
+
6
+ #---------------------------------------#
7
+ # Goals & Risk Management %s #
8
+ #---------------------------------------#
9
+ autotrade_portfolio_percent: 10.00
10
+ target_profit_margin_percent: 20.00
@@ -0,0 +1,8 @@
1
+ prod:
2
+ api_key: ''
3
+ api_secret: ''
4
+ api_passphrase: ''
5
+ sandbox:
6
+ api_key: ''
7
+ api_secret: ''
8
+ api_passphrase: ''
@@ -0,0 +1 @@
1
+ bearer_token: ''
data/git_commit.sh ADDED
@@ -0,0 +1,22 @@
1
+ #!/bin/bash --login
2
+ if [[ $1 != "" && $2 != "" && $3 != "" ]]; then
3
+ # Default Strategy is to merge codebase
4
+ git config pull.rebase false
5
+ git config commit.gpgsign true
6
+ git pull origin master
7
+ git add . --all
8
+ echo 'Updating Gems to Latest Versions in Gemfile...'
9
+ ./upgrade_Gemfile_gems.sh
10
+ cryptum_autoinc_version
11
+ git commit -a -S --author="${1} <${2}>" -m "${3}"
12
+ ./upgrade_cryptum.sh
13
+ # Tag for every 100 commits (i.e. 0.1.100, 0.1.200, etc)
14
+ tag_this_version_bool=`ruby -r 'cryptum' -e 'if Cryptum::VERSION.split(".")[-1].to_i % 100 == 0; then print true; else print false; end'`
15
+ if [[ $tag_this_version_bool == 'true' ]]; then
16
+ this_version=`ruby -r 'cryptum' -e 'print Cryptum::VERSION'`
17
+ echo "Tagging: ${this_version}"
18
+ git tag $this_version
19
+ fi
20
+ else
21
+ echo "USAGE: ${0} '<full name>' <email address> '<git commit comments>'"
22
+ fi