-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand.sh
executable file
·1092 lines (1016 loc) · 30.9 KB
/
command.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
## EPITECH PROJECT, 2017
## Clément ROYER - clement.royer@epitech.eu
## File description:
## a bash trading bot with UI
##
# 0.0 SUMMURY
# 1.0 Variables
# 2.0 statubar (topbar)
# 3.0 loginscreen
# 1.0
#======================================================================================================================================================================================================================================
# Variables
cols=$(tput cols)
rows=$(tput lines)
#profil
connect="false"
msgname=""
eur_=10000
btc_=0
raw_=0
stock_=0
forex_=0
placement="crypto raw_ma stock_ forex_"
amountcrypto=0
amountraw=0
amountstock=0
amountforex=0
start=$SECONDS
sx=$(( ( ($cols / 2) - 60) ))
sy=$(( ( ($rows / 2) - 4 ) ))
# 2.0
#======================================================================================================================================================================================================================================
# STATUBAR
statubar()
{
nco="You are not connected. Type /login to connect."
co="You have been properly connected"
if [ ${#msgname} -eq 0 ]
then
msgname="Unknow"
fi
msgcols=$((( ($cols - ${#msgname}) - 2)))
ncocols=$((( (($cols/2) - (${#nco}/2)))))
cocols=$((( (($cols/2) - (${#co}/2)))))
tput reset
tput cup 0 2
echo -e "\e[1;38;5;220m$(date +"%d-%m-%Y")\e[0m"
if [ $connect == "false" ]
then
tput cup 0 $ncocols
echo -e "\e[1;91m${nco}\e[0m"
else
tput cup 0 $cocols
echo -e "\e[1;92m${co}\e[0m"
fi
tput cup 0 $msgcols
echo -e "\e[1;38;5;220m$msgname\e[0m"
}
# 3.0
#======================================================================================================================================================================================================================================
# LOGIN SCREEN
Thelogin()
{
tmp="LOGIN : "
txt="N U C L E A R CRYPTO BOT"
middle=$(( (($rows/2) - 10) ))
lenAscii=$(( ((($cols/2) - (${#txt}/2)) - 65) ))
tput cup $middle $lenAscii
echo -e "\e[1;38;5;45m\033#6N U C L E A R CRYPTO BOT\e[0m"
lenAscii=$((( (($cols/2) - (${#tmp}/2)))))
middle=$((($rows/2) - 10))
middle=$((($rows/2) - 8))
tput cup $middle $lenAscii
echo -e "\e[1;38;5;123mLOGIN :\e[1;33m\033#5"
lenAscii=$((( (($cols/2) + (${#tmp}/2)))))
tput cup $middle $lenAscii
read -u 2 login
middle=$((($rows/2) - 7))
lenAscii=$((( (($cols/2) - (${#tmp}/2)))))
tput cup $middle $lenAscii
echo -e "\e[1;38;5;123mPASS :\e[0m"
middle=$((($rows/2) - 7))
lenAscii=$((( (($cols/2) + (${#tmp}/2)))))
tput cup $middle $lenAscii
echo -en "( •_•)"
tput cup $middle $lenAscii
read -u 2 -s pass
tput cup $middle $lenAscii
echo -e "(⌐■_■)"
}
Thewait()
{
i=${#login}
while [ $i -ne 0 ]
do
middle=$(( ($rows/2) - 8 ))
lenAscii=$(( ((($cols/2) + (${#tmp}/2) + $i)) ))
tput cup $middle $lenAscii
printf "\e[38;5;173m%*s\e[0m" ${#login} "ヾ('〇')ノ"
sleep .50
middle=$(( ($rows/2) - 8 ))
lenAscii=$(( (($cols/2) + ((${#tmp}/2) + $i)) ))
tput cup $middle $lenAscii
printf "\e[38;5;173m%*s\e[0m" ${#login} "ヾ(-_- )ゞ"
sleep .50
i=$(( $i - 1 ))
done
}
veriflogin()
{
connect="true"
}
# 4.0
#======================================================================================================================================================================================================================================
# DISPLAY INFORMATION
# 4.1
# BANQ
banq()
{
#1/3 shell for banq (1/3) / 2
box_top=" ╭────────╮"
x=$(( ((($rows / 2) / 2) - ((${#box_top} / 2)/2) ) ))
y=5
tput cup $y $x
echo -e "\e[38;5;109m${box_top}\e[0m"
x=$(( ((($rows / 2) / 2) - ((${#box_top} / 2)/2) ) ))
y=6
tput cup $y $x
echo -e "\e[38;5;109m┌─────────┤\e[1;38;5;79m BANQUE \e[0m\e[38;5;109m├─────────┐\e[0m"
y=7
tput cup $y $x
echo -e "\e[38;5;109m│ └────────┘ │\e[0m"
y=8
tput cup $y $x
printf "\e[38;5;109m│\e[0m%-28s\e[38;5;109m│\e[0m"
y=9
tput cup $y $x
printf "\e[38;5;109m│\e[0m \e[38;5;113mEUR: \e[3;38;5;112m%-19s\e[0m\e[38;5;109m│\e[0m" "`echo "scale=3; ${eur_} / 1" | bc -l`€"
y=10
tput cup $y $x
printf "\e[38;5;109m│\e[0m%-28s\e[38;5;109m│\e[0m"
y=11
tput cup $y $x
printf "\e[38;5;109m│\e[0m \e[38;5;113mCRYPTO: \e[3;38;5;112m%-14s\e[0m\e[38;5;109m│\e[0m" `echo "scale=6; ${btc_} / 1" | bc -l`
y=12
tput cup $y $x
printf "\e[38;5;109m│\e[0m%-28s\e[38;5;109m│\e[0m"
y=13
tput cup $y $x
printf "\e[38;5;109m│\e[0m \e[38;5;113mRAW: \e[3;38;5;112m%-17s\e[0m\e[38;5;109m│\e[0m" `echo "scale=6; ${raw_} / 1" | bc -l`
y=14
tput cup $y $x
printf "\e[38;5;109m│\e[0m%-28s\e[38;5;109m│\e[0m"
y=15
tput cup $y $x
printf "\e[38;5;109m│\e[0m \e[38;5;113mSTOCK: \e[3;38;5;112m%-15s\e[0m\e[38;5;109m│\e[0m" `echo "scale=6; ${stock_} / 1" | bc -l`
y=16
tput cup $y $x
printf "\e[38;5;109m│\e[0m%-28s\e[38;5;109m│\e[0m"
y=17
tput cup $y $x
printf "\e[38;5;109m│\e[0m \e[38;5;113mFOREX: \e[3;38;5;112m%-15s\e[0m\e[38;5;109m│\e[0m" `echo "scale=6; ${forex_} / 1" | bc -l`
y=18
tput cup $y $x
printf "\e[38;5;109m│\e[0m%-28s\e[38;5;109m│\e[0m"
y=19
tput cup $y $x
echo -e "\e[38;5;109m└────────────────────────────┘\e[0m"
}
# 4.2
# RUNTIME
runtime()
{
box_top="╭──┤ RUNNING TIME ├──────────╮"
time=$(( SECONDS - start ))
x=$(( ((($rows / 2) / 2) - ((${#box_top} / 2)/2) ) ))
y=20
tput cup $y $x
echo -e " \e[38;5;109m╭──────────────╮\e[0m"
x=$(( ((($rows / 2) / 2) - ((${#box_top} / 2)/2) ) ))
y=21
tput cup $y $x
echo -e "\e[38;5;109m┌──┤ \e[1;38;5;220mRUNNING TIME\e[0m \e[38;5;109m├──────────┐\e[0m"
y=22
tput cup $y $x
printf "\e[38;5;109m│ └──────────────┘ \e[1;38;5;109m%5s\e[0m \e[38;5;109m│\e[0m" "$time"
y=23
tput cup $y $x
echo -e "\e[38;5;109m└────────────────────────────┘\e[0m"
}
# 4.3
# CURRPLACEMENT
currplacement()
{
box_top=" ╭───────────────────╮"
txt="CURRENT PLACEMENT"
x=$(( ((($rows / 2) / 2) - ((${#box_top} / 2)/2) ) ))
y=27
tput cup $y $x
echo -e "\e[38;5;109m${box_top}\e[0m"
x=$(( ((($rows / 2) / 2) - ((${#box_top}/2 / 2)) ) ))
y=28
tput cup $y $x
echo -e "\e[38;5;109m┌──┤ \e[1;38;5;220m$txt\e[0m\e[38;5;109m ├──┐\e[0m"
y=29
tput cup $y $x
echo -e "\e[38;5;109m│ └───────────────────┘ │\e[0m"
y=30
tput cup $y $x
printf "\e[38;5;109m│\e[0m%-25s\e[38;5;109m│\e[0m"
nb=`echo "$placement" | wc -w`
y=31
i=0
parray=( $placement )
# while [ $i -ne $nb ]
tput cup $y $x
printf "\e[38;5;109m│\e[0m\e[0m %-19s\e[38;5;109m│\e[0m" "${parray[0]}: ????"
y=$(( ($y + 1) ))
i=$(( ($i + 1) ))
tput cup $y $x
printf "\e[38;5;109m│\e[0m\e[0m %-19s\e[38;5;109m│\e[0m" "${parray[1]}: ????"
#$amountraw"
y=$(( ($y + 1) ))
i=$(( ($i + 1) ))
tput cup $y $x
printf "\e[38;5;109m│\e[0m\e[0m %-19s\e[38;5;109m│\e[0m" "${parray[2]}: ????"
#$amountstock
y=$(( ($y + 1) ))
i=$(( ($i + 1) ))
tput cup $y $x
printf "\e[38;5;109m│\e[0m\e[0m %-19s\e[38;5;109m│\e[0m" "${parray[3]}: ????"
#$amountcrypto"
y=$(( ($y + 1) ))
i=$(( ($i + 1) ))
tput cup $y $x
printf "\e[38;5;109m│\e[0m%-25s\e[38;5;109m│\e[0m"
y=$(( $y + 1 ))
tput cup $y $x
echo -e "\e[38;5;109m└─────────────────────────┘\e[0m"
}
# 4.4
# PLACENAME
placename()
{
box_top="┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐"
name_bx=" crypto raw_ma stock_ forex_"
explcation="PRICE_€ . MOYENNE . LOWER_B . HIGHT_B"
array=( $explcation )
x=$(( (($cols / 2) - (((${#box_top} / 3) + (${#box_top}/7))) )))
y=6
tput cup $y $x
echo -e "\e[38;5;109m\e[1;38;5;229m${name_bx}\e[0;38;5;109m\e[0m"
y=7
tput cup $y $x
printf "\e[38;5;109m%-$(( (${#box_top} - 2) ))s\e[0m"
y=8
tput cup $y $x
printf "\e[38;5;109m%-$(( (${#box_top} - 2) ))s\e[0m"
y=9
for i in {0..10}
do
y=$(( ($y + 1) ))
tput cup $y $x
printf "\e[38;5;109m%-$(( (${#box_top} - 2) ))s\e[0m" "${array[${i}]}"
i=$(( ($i + 1) ))
done
}
Themsgbox()
{
size=145
x=$(( ( ($cols / 2) - (${size} / 2) ) ))
y=$(( ( ($rows) - ($rows / 9)) ))
tput cup $y $x
printf "\e[38;5;155mYOUR ORDER ⫷⫶%-${size}s⫶⫸\e[0m"
}
botaction()
{
box_top="┌───────────────────────────────────────────────┤ N U C L E A R BOT ACTION ├───────────┐"
x=$(( ( ($cols / 2) - ((${#box_top} / 2) + 18) ) ))
y=$(( ( ($rows / 2) - 6 ) ))
tput cup $y $x
printf "\e[38;5;75m%-$(( ((${#box_top}/2) + 7) ))s╭──────────────────────────╮"
y=$(( ( ($rows / 2) - 5 ) ))
tput cup $y $x
echo -e "\e[38;5;75m┌──────────────────────────────────────────────────┤ \e[1;38;5;220mN U C L E A R\e[0;38;5;220m BOT ACTION \e[38;5;75m├────────┐\e[0m"
y=$(( $y + 1 ))
tput cup $y $x
printf "\e[38;5;75m│%-$(( ((${#box_top}/2) + 6) ))s└──────────────────────────┘ │\e[0m"
for i in {0..20}
do
y=$(( $y + 1 ))
tput cup $y $x
printf "\e[38;5;75m│%-$(( ${#box_top} - 2 ))s│\e[0m"
done
y=$(( $y + 1 ))
tput cup $y $x
echo -e "\e[38;5;75m└──────────────────────────────────────────────────────────────────────────────────────┘\e[0m"
}
resum()
{
box_top="┌───────────┤ FINAL POSITION ├───────────┐"
x=$(( ( ($cols / 2) + ((${#box_top} / 2) + 33) ) ))
y=$(( ( ($rows / 2) - 6 ) ))
tput cup $y $x
printf "%-12s\e[38;5;75m┌────────────────╮\e[0m"
y=$(( ($y + 1) ))
tput cup $y $x
echo -e "\e[38;5;75m┌───────────┤ \e[1;38;5;220mFINAL POSITION \e[0;38;5;75m├───────────┐\e[0m"
y=$(( ($y + 1) ))
tput cup $y $x
printf "\e[38;5;75m│%-11s\e[38;5;75m└────────────────┘ │\e[0m"
for i in {0..20}
do
y=$(( $y + 1 ))
tput cup $y $x
printf "\e[38;5;75m│%-$(( ${#box_top} - 2 ))s│\e[0m"
done
y=$(( $y + 1 ))
tput cup $y $x
echo -e "\e[38;5;75m└────────────────────────────────────────┘\e[0m"
}
# 5.0
#======================================================================================================================================================================================================================================
# SETVALUE
setbtcvalue()
{
box_top="╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮"
btcprice=$crypto
getbtcMA
getlowcrypto
getuppercrypto
change24h=$Cryptomoy
change1h=$lowCrypto
market_cap=$upCrypto
x=$(( (($cols / 2) - (((${#box_top} / 3) + ((${#box_top}/7)) - 22)) )))
y=10
tput cup $y $x
echo -e "\e[38;5;214m${btcprice}\e[0m"
y=12
tput cup $y $x
if [[ $change24h == *"-"* ]]
then
echo -e "\e[1;91m${change24h}\e[0m"
else
echo -e "\e[1;92m${change24h}\e[0m"
fi
y=14
tput cup $y $x
if [[ $change1h == *"-"* ]]
then
echo -e "\e[1;91m${change1h}\e[0m"
else
echo -e "\e[1;92m${change1h}\e[0m"
fi
y=16
tput cup $y $x
echo -e "\e[38;5;214m${market_cap}\e[0m"
}
setethvalue()
{
box_top="┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐"
ethprice=$raw
getrawMA
getlowraw
getupperraw
change24h=$Rawmoy
change1h=$lowRaw
market_cap=$upRaw
x=$(( (($cols / 2) - (((${#box_top} / 3) + ((${#box_top}/11)) - 39)) )))
y=10
tput cup $y $x
echo -e "\e[38;5;214m${ethprice}\e[0m"
y=12
tput cup $y $x
if [[ $change24h == *"-"* ]]
then
echo -e "\e[1;91m${change24h}\e[0m"
else
echo -e "\e[1;92m${change24h}\e[0m"
fi
y=14
tput cup $y $x
if [[ $change1h == *"-"* ]]
then
echo -e "\e[1;91m${change1h}\e[0m"
else
echo -e "\e[1;92m${change1h}\e[0m"
fi
y=16
tput cup $y $x
echo -e "\e[38;5;214m${market_cap}\e[0m"
}
setxrpvalue()
{
box_top="┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐"
xrpprice=$stock
getstockMA
getlowstock
getupperstock
change24h=$Stockmoy
change1h=$lowStock
market_cap=$upStock
x=$(( (($cols / 2) - (((${#box_top} / 3) + ((${#box_top}/11)) - 63)) )))
y=10
tput cup $y $x
echo -e "\e[38;5;214m${xrpprice}\e[0m"
y=12
tput cup $y $x
if [[ $change24h == *"-"* ]]
then
echo -e "\e[1;91m${change24h}\e[0m"
else
echo -e "\e[1;92m${change24h}\e[0m"
fi
y=14
tput cup $y $x
if [[ $change1h == *"-"* ]]
then
echo -e "\e[1;91m${change1h}\e[0m"
else
echo -e "\e[1;92m${change1h}\e[0m"
fi
y=16
tput cup $y $x
echo -e "\e[38;5;214m${market_cap}\e[0m"
}
setbchvalue()
{
box_top="┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐"
bchprice=$forex
getforexMA
getlowforex
getupperforex
change24h=$Forexmoy
change1h=$lowForex
market_cap=$upForex
x=$(( ( ($cols / 2) - ((${#box_top} / 3) - 74) ) ))
y=10
tput cup $y $x
echo -e "\e[38;5;214m${bchprice}\e[0m"
y=12
tput cup $y $x
if [[ $change24h == *"-"* ]]
then
echo -e "\e[1;91m${change24h}\e[0m"
else
echo -e "\e[1;92m${change24h}\e[0m"
fi
y=14
tput cup $y $x
if [[ $change1h == *"-"* ]]
then
echo -e "\e[1;91m${change1h}\e[0m"
else
echo -e "\e[1;92m${change1h}\e[0m"
fi
y=16
tput cup $y $x
echo -e "\e[38;5;214m${market_cap}\e[0m"
}
setltcvalue()
{
box_top="┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐"
ltcprice=$forex
change24h="????"
change1h="????"
market_cap="????"
x=$(( ( ($cols / 2) - ((${#box_top} / 3) - 98) ) ))
y=10
tput cup $y $x
echo -e "\e[38;5;214m${ltcprice}\e[0m"
y=12
tput cup $y $x
if [[ $change24h == *"-"* ]]
then
echo -e "\e[1;91m${change24h}\e[0m"
else
echo -e "\e[1;92m${change24h}\e[0m"
fi
y=14
tput cup $y $x
if [[ $change1h == *"-"* ]]
then
echo -e "\e[1;91m${change1h}\e[0m"
else
echo -e "\e[1;92m${change1h}\e[0m"
fi
y=16
tput cup $y $x
echo -e "\e[38;5;214m${market_cap}\e[0m"
}
msgcrypto()
{
tput cup $sy $sx
echo -e "\e[0;92mBought\e[0m $buyCR\e[0;38;5;220m crypto\e[0m at \e[0m$crypto\e[0m"
echo -e "Bought $buyCR crypto at $crypto." >> log.buy
echo -e "Bought $buyCR crypto at $crypto." >> log
sy=`echo "$sy + 1" | bc -l`
if [ $sy -eq 46 ]
then
sy=$(( ( ($rows / 2) - 4 ) ))
fi
tput cup $sy $sx
echo -e " "
}
msgraw()
{
tput cup $sy $sx
echo -e "\e[0;92mBought\e[0m $buyRA\e[0;38;5;220m raw\e[0m at \e[0m$raw\e[0m"
echo -e "Bought $buyRA raw at $raw" >> log.buy
echo -e "Bought $buyRA raw at $raw" >> log
sy=`echo "$sy + 1" | bc -l`
if [ $sy -eq 46 ]
then
sy=$(( ( ($rows / 2) - 4 ) ))
fi
tput cup $sy $sx
echo -e " "
}
msgstock()
{
tput cup $sy $sx
echo -e "\e[0;92mBought\e[0m $buyST\e[0;38;5;220m stock\e[0m at \e[0m$stock\e[0m"
echo -e "Bought $buyST stock at $stock" >> log.buy
echo -e "Bought $buyST stock at $stock" >> log
sy=`echo "$sy + 1" | bc -l`
if [ $sy -eq 46 ]
then
sy=$(( ( ($rows / 2) - 4 ) ))
fi
tput cup $sy $sx
echo -e " "
}
msgforex()
{
tput cup $sy $sx
echo -e "\e[0;92mBought\e[0m $buyFO\e[0;38;5;220m forex\e[0m at \e[0m$forex\e[0m"
echo -e "Bought $buyFO forex at $forex" >> log.buy
echo -e "Bought $buyFO forex at $forex" >> log
sy=`echo "$sy + 1" | bc -l`
if [ $sy -eq 46 ]
then
sy=$(( ( ($rows / 2) - 4 ) ))
fi
tput cup $sy $sx
echo -e " "
}
msgsellcrypto()
{
tput cup $sy $sx
echo -e "\e[0;91mSold\e[0m $sellCR\e[0;38;5;220m crypto\e[0m at \e[0m$crypto\e[0m"
echo -e "Sold $sellCR crypto at $crypto." >> log.sell
echo -e "Sold $sellCR crypto at $crypto." >> log
sy=`echo "$sy + 1" | bc -l`
if [ $sy -eq 46 ]
then
sy=$(( ( ($rows / 2) - 4 ) ))
fi
tput cup $sy $sx
echo -e " "
}
msgsellraw()
{
tput cup $sy $sx
echo -e "\e[0;91mSold\e[0m $buyRA\e[0;38;5;220m raw\e[0m at \e[0m$raw\e[0m"
echo -e "Sold $sellRA raw at $raw" >> log.sell
echo -e "Sold $sellRA raw at $raw" >> log
sy=`echo "$sy + 1" | bc -l`
if [ $sy -eq 46 ]
then
sy=$(( ( ($rows / 2) - 4 ) ))
fi
tput cup $sy $sx
echo -e " "
}
msgsellstock()
{
tput cup $sy $sx
echo -e "\e[0;91mSold\e[0m $sellST\e[0;38;5;220m stock\e[0m at \e[0m$stock\e[0m"
echo -e "Sold $sellST stock at $stock" >> log.sell
echo -e "Sold $sellST stock at $stock" >> log
sy=`echo "$sy + 1" | bc -l`
if [ $sy -eq 46 ]
then
sy=$(( ( ($rows / 2) - 4 ) ))
fi
tput cup $sy $sx
echo -e " "
}
msgsellforex()
{
tput cup $sy $sx
echo -e "\e[0;91mSold\e[0m $sellFO\e[0;38;5;220m forex\e[0m at \e[0m$forex\e[0m"
echo -e "Sold $sellFO forex at $forex" >> log.sell
echo -e "Sold $sellFO forex at $forex" >> log
sy=`echo "$sy + 1" | bc -l`
if [ $sy -eq 46 ]
then
sy=$(( ( ($rows / 2) - 4 ) ))
fi
tput cup $sy $sx
echo -e " "
}
# 6.0
#======================================================================================================================================================================================================================================
# BOT ACTION
value()
{
listen
setbtcvalue
setethvalue
setxrpvalue
setbchvalue
# setltcvalue
}
listen()
{
read crypto
crypto=${crypto#*:}
arrCrypto+=($crypto)
read raw
raw=${raw#*:}
arrRaw+=($raw)
read stock
stock=${stock#*:}
arrStock+=($stock)
read forex
forex=${forex#*:}
arrForex+=($forex)
}
InitBot()
{
hehe=0
}
botCrypto()
{
low=`echo "$lowCrypto * 1.13" | bc -l`
iif=`echo $crypto "<=" $low | bc -l`
aif=`echo "$crypto >= ($upCrypto * 0.95) && $btc_ > 0" | bc -l`
if [ $iif -eq 1 ] && [ $aif -eq 1 ]
then
return 1
fi
if [ $iif -eq 1 ]
then
amountcrypto=`echo "$amountcrypto + 1" | bc -l`
tmp=`echo "(($eur_ - ($eur_ * 0.2)) >= 0) && (($eur_ - ($eur_ * 0.2)) >= 0.10) && (($eur_ * 0.2) >= 0.10)" | bc -l`
if [ $tmp -eq 1 ]
then
buyCR=`echo "($eur_ * 0.2) / $crypto" | bc -l`
eur_=`echo "$eur_ - ($eur_ * 0.2)" | bc -l`
btc_=`echo "$btc_ + $buyCR" | bc -l`
msgcrypto
fi
fi
if [ $aif -eq 1 ]
then
amountcrypto=`echo "$amountcrypto - ($amountcrypto * 0.90)" | bc -l`
tmp=`echo "$btc_ - ($btc_ * 0.90) >= 0.0000010" | bc -l`
if [ $tmp -eq 1 ]
then
sellCR=`echo "($btc_ * 0.90) * $crypto" | bc -l`
eur_=`echo "$eur_ + $sellCR" | bc -l`
btc_=`echo "$btc_ - ($btc_ * 0.90)" | bc -l`
msgsellcrypto
fi
fi
}
botRaw()
{
#low=`echo "$lowRaw * 1.13" | bc -l`
#iif=`echo $raw "<=" $low | bc -l`
iif=0
aif=`echo "$raw >= ($upRaw * 0.95) && $raw_ > 0" | bc -l`
if [ $iif -eq 1 ] && [ $aif -eq 1 ]
then
return 1
fi
if [ $iif -eq 1 ]
then
amountraw=`echo "$amountraw + 1" | bc -l`
tmp=`echo "(($eur_ - ($eur_ * 0.2)) >= 0) && (($eur_ - ($eur_ * 0.2)) >= 0.10) && (($eur_ * 0.2) >= 0.10)" | bc -l`
if [ $tmp -eq 1 ]
then
buyRA=`echo "($eur_ * 0.2) / $raw" | bc -l`
eur_=`echo "$eur_ - ($eur_ * 0.2)" | bc -l`
raw_=`echo "$raw_ + $buyRA" | bc -l`
msgraw
fi
fi
if [ $aif -eq 1 ]
then
amountraw=`echo "$amountraw - ($amountraw * 0.90)" | bc -l`
tmp=`echo "$raw_ - ($raw_ * 0.90) >= 0.0000010" | bc -l`
if [ $tmp -eq 1 ]
then
sellRA=`echo "($raw_ * 0.90) * $raw" | bc -l`
eur_=`echo "$eur_ + $sellRA" | bc -l`
raw_=`echo "$raw_ - ($raw_ * 0.90)" | bc -l`
msgsellraw
fi
fi
}
botStock()
{
low=`echo "$lowStock * 1.13" | bc -l`
iif=`echo "$stock <= $low" | bc -l`
aif=`echo "$stock >= ($upStock * 0.95) && $stock_ > 0" | bc -l`
if [ $iif -eq 1 ] && [ $aif -eq 1 ]
then
return 1
fi
if [ $iif -eq 1 ]
then
amountstock=`echo "$amountstock + 1" | bc -l`
tmp=`echo "(($eur_ - ($eur_ * 0.2)) >= 0) && (($eur_ - ($eur_ * 0.2)) >= 0.10) && (($eur_ * 0.2) >= 0.10)" | bc -l`
if [ $tmp -eq 1 ]
then
buyST=`echo "($eur_ * 0.2) / $stock" | bc -l`
eur_=`echo "$eur_ - ($eur_ * 0.2)" | bc -l`
stock_=`echo "$stock_ + $buyST" | bc -l`
msgstock
fi
fi
if [ $aif -eq 1 ]
then
amountstock=`echo "$amountstock - ($amountstock * 0.90)" | bc -l`
tmp=`echo "$stock_ - ($stock_ * 0.90) >= 0.0000010" | bc -l`
if [ $tmp -eq 1 ]
then
sellST=`echo "($stock_ * 0.90) * $stock" | bc -l`
#echo $sellST
eur_=`echo "$eur_ + $sellST" | bc -l`
stock_=`echo "$stock_ - ($stock_ * 0.90)" | bc -l`
msgsellstock
fi
fi
}
botForex()
{
low=`echo "$lowForex * 1.20" | bc -l`
iif=`echo "$forex <= $low" | bc -l`
aif=`echo "$forex >= ($upForex * 0.99) && $forex_ > 0" | bc -l`
if [ $iif -eq 1 ] && [ $aif -eq 1 ]
then
tmp=`echo "$forex_ > 0" | bc -l`
if [ $tmp -eq 1 ]
then
sellFO=`echo "$forex_ * $forex" | bc -l`
eur_=`echo "$eur_ + $sellFO" | bc -l`
forex_=0
msgsellforex
fi
return 1
fi
if [ $iif -eq 1 ]
then
amountforex=`echo "$amountforex + 1" | bc -l`
tmp=`echo "(($eur_ - ($eur_ * 0.2)) >= 0) && (($eur_ - ($eur_ * 0.2)) >= 0.10) && (($eur_ * 0.2) >= 0.10)" | bc -l`
if [ $tmp -eq 1 ]
then
buyFO=`echo "($eur_ * 0.2) / $forex" | bc -l`
eur_=`echo "$eur_ - ($eur_ * 0.2)" | bc -l`
forex_=`echo "$forex_ + $buyFO" | bc -l`
msgforex
fi
fi
if [ $aif -eq 1 ]
then
amountforex=`echo "$amountforex - ($amountforex * 0.90)" | bc -l`
tmp=`echo "$forex_ - ($forex_ * 0.90) >= 0.0000010" | bc -l`
if [ $tmp -eq 1 ]
then
sellFO=`echo "($forex_ * 0.90) * $forex" | bc -l`
eur_=`echo "$eur_ + $sellFO" | bc -l`
forex_=`echo "$forex_ - ($forex_ * 0.90)" | bc -l`
msgsellforex
fi
fi
}
allprice()
{
tmp=`echo "scale=5; ($forex_ * $forex + $btc_ * $crypto + $raw_ * $raw + $stock_ * $stock) / 1" | bc -l`
x=$(( ( ($cols / 2) + 60) ))
y=$(( ( ($rows / 2) + 10) ))
tput cup $y $x
echo " "
tput cup $y $x
printf "Total : \e[0;92m$tmp\e[0m €\e[0m"
}
bot()
{
botCrypto
botRaw
botStock
botForex
allprice
}
#======================================================================================================================================================================================================================================
# CALCULS MEAN
getbtcMA()
{
moy=0
index=0
for index in ${!arrCrypto[@]}
do
moy=`echo "$moy + ${arrCrypto[index]}" | bc -l`
done
if [ $index -ne 0 ]
then
Cryptomoy=`echo "scale=5; $moy / $index" | bc -l`
else
Cryptomoy="???"
fi
}
getrawMA()
{
moy=0
index=0
for index in ${!arrRaw[@]}
do
moy=`echo "$moy + ${arrRaw[index]}" | bc -l`
done
if [ $index -ne 0 ]
then
Rawmoy=`echo "scale=5; $moy / $index" | bc -l`
else
Rawmoy="???"
fi
}
getstockMA()
{
moy=0
index=0
for index in ${!arrStock[@]}
do
moy=`echo "$moy + ${arrStock[index]}" | bc -l`
done
if [ $index -ne 0 ]
then
Stockmoy=`echo "scale=5; $moy / $index" | bc -l`
else
Stockmoy="???"
fi
}
getforexMA()
{
moy=0
index=0
for index in ${!arrForex[@]}
do
moy=`echo "$moy + ${arrForex[index]}" | bc -l`
done
if [ $index -ne 0 ]
then
Forexmoy=`echo "scale=5; $moy / $index" | bc -l`
else
Forexmoy="???"
fi
}
#======================================================================================================================================================================================================================================
getcryptoAverage()
{
standardDeviation=$( echo "${arrCrypto[@]}" | tr " " "\n" | awk '{sum+=$1; sumsq+=$1*$1}END{print sqrt(sumsq/NR - (sum/NR)**2)}' )
}
getrawAverage()
{
standardDeviation=$( echo "${arrRaw[@]}" | tr " " "\n" | awk '{sum+=$1; sumsq+=$1*$1}END{print sqrt(sumsq/NR - (sum/NR)**2)}' )
}
getstockAverage()
{
standardDeviation=$( echo "${arrStock[@]}" | tr " " "\n" | awk '{sum+=$1; sumsq+=$1*$1}END{print sqrt(sumsq/NR - (sum/NR)**2)}' )
}
getforexAverage()
{
standardDeviation=$( echo "${arrForex[@]}" | tr " " "\n" | awk '{sum+=$1; sumsq+=$1*$1}END{print sqrt(sumsq/NR - (sum/NR)**2)}' )
}
getlowcrypto()
{
getcryptoAverage
if [ $index -ne 0 ]
then
lowCrypto=`echo "$Cryptomoy - ($standardDeviation * 2)" | bc -l`
else
lowCrypto="???"
fi
}
getuppercrypto()
{
getcryptoAverage
if [ $index -ne 0 ]
then
upCrypto=`echo "$Cryptomoy + ($standardDeviation * 2)" | bc -l`
else
upCrypto="???"
fi
}
getlowraw()
{
getrawAverage
if [ $index -ne 0 ]
then
lowRaw=`echo "$Rawmoy - ($standardDeviation * 2)" | bc -l`
else
lowRaw="???"
fi
}
getupperraw()
{
getrawAverage
if [ $index -ne 0 ]
then
upRaw=`echo "$Rawmoy + ($standardDeviation * 2)" | bc -l`
else
upRaw="???"
fi
}
getlowstock()
{
getstockAverage
if [ $index -ne 0 ]
then
lowStock=`echo "$Stockmoy - ($standardDeviation * 2)" | bc -l`
else
lowStock="???"
fi
}
getupperstock()
{
getstockAverage
if [ $index -ne 0 ]