SimBot 0.1.4 → 0.1.5

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: 465b3f2a610b3e4d75575bea6ad533ea7e8d1ba2bcc72fca04c2679fa7614c91
4
- data.tar.gz: 775f9186f34f6f9fb86b5907090bc0c620a4cb0f438ce1aeaee2948c2adb3767
3
+ metadata.gz: 4a7fab3eadb3a1cfceaca93287f42a418e9eb0bfb6424ad9e26d5ea5dd5f11c0
4
+ data.tar.gz: e8ef748461040232b333f155da20c1d131d8efa6dd4ef24d228ae0c3c8dda39d
5
5
  SHA512:
6
- metadata.gz: ccb458d5f8d70496a84d968443612bd3315aa9b8cf6e7d24202f39d3c1c6dbd143a96e28161abe01eda98a1f49205f34007cc0c8bbaa972dbd8f8228d9cd0cd8
7
- data.tar.gz: 3af48d4a8e66525fa0e7c1d61e0ca016b676d658cbf20f536b2d623897537bc63b74be5ff287a98b93f49f5e1502594aed004e4532ccdc6b6b7cf2130439b957
6
+ metadata.gz: d76226bf798e072594bf0ecf58d46e83d305dae59d9593b999ea52a1d99d7869830f8224867b9359f082f943268849a59ce428dd4f3e970c007209d105e27d81
7
+ data.tar.gz: d1b671223dfaf4cf18837b44c623423df7732c5ba1c3f99be5f97f9c5001a9fc4aa707ce637bf9b4adef9491666aec5c7a15d0cb8e8022e9833e662b6935a39a
@@ -2,14 +2,9 @@
2
2
  <project version="4">
3
3
  <component name="ChangeListManager">
4
4
  <list default="true" id="d905eaf2-5cab-434b-a4d1-1ccf165356a4" name="Default" comment="">
5
- <change afterPath="$PROJECT_DIR$/lib/barong.rb" afterDir="false" />
6
- <change beforePath="$PROJECT_DIR$/.idea/SimBot.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/SimBot.iml" afterDir="false" />
7
- <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
8
- <change beforePath="$PROJECT_DIR$/Gemfile.lock" beforeDir="false" afterPath="$PROJECT_DIR$/Gemfile.lock" afterDir="false" />
9
- <change beforePath="$PROJECT_DIR$/SimBot.gemspec" beforeDir="false" afterPath="$PROJECT_DIR$/SimBot.gemspec" afterDir="false" />
5
+ <change beforePath="$PROJECT_DIR$/lib/Deamons/wash_trade.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/Deamons/wash_trade.rb" afterDir="false" />
10
6
  <change beforePath="$PROJECT_DIR$/lib/SimBot.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/SimBot.rb" afterDir="false" />
11
7
  <change beforePath="$PROJECT_DIR$/lib/SimBot/version.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/SimBot/version.rb" afterDir="false" />
12
- <change beforePath="$PROJECT_DIR$/lib/api_controller.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/api_controller.rb" afterDir="false" />
13
8
  <change beforePath="$PROJECT_DIR$/lib/utils.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/utils.rb" afterDir="false" />
14
9
  </list>
15
10
  <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -20,7 +15,7 @@
20
15
  <option name="LAST_RESOLUTION" value="IGNORE" />
21
16
  </component>
22
17
  <component name="CoverageDataManager">
23
- <SUITE FILE_PATH="coverage/SimBot@Install_My_Gem.rcov" NAME="Install My Gem Coverage Results" MODIFIED="1528473090970" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="SimBot" />
18
+ <SUITE FILE_PATH="coverage/SimBot@Install_My_Gem.rcov" NAME="Install My Gem Coverage Results" MODIFIED="1528479809312" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="SimBot" />
24
19
  </component>
25
20
  <component name="FileEditorManager">
26
21
  <splitter split-orientation="horizontal" split-proportion="0.52644426">
@@ -29,8 +24,8 @@
29
24
  <file leaf-file-name="SimBot.rb" pinned="false" current-in-tab="false">
30
25
  <entry file="file://$PROJECT_DIR$/lib/SimBot.rb">
31
26
  <provider selected="true" editor-type-id="text-editor">
32
- <state relative-caret-position="604">
33
- <caret line="36" selection-start-line="36" selection-end-line="36" />
27
+ <state relative-caret-position="365">
28
+ <caret line="26" column="23" lean-forward="true" selection-start-line="26" selection-start-column="23" selection-end-line="26" selection-end-column="23" />
34
29
  </state>
35
30
  </provider>
36
31
  </entry>
@@ -65,8 +60,8 @@
65
60
  <file leaf-file-name="api_controller.rb" pinned="false" current-in-tab="false">
66
61
  <entry file="file://$PROJECT_DIR$/lib/api_controller.rb">
67
62
  <provider selected="true" editor-type-id="text-editor">
68
- <state relative-caret-position="414">
69
- <caret line="18" column="53" lean-forward="true" selection-start-line="18" selection-start-column="53" selection-end-line="18" selection-end-column="53" />
63
+ <state relative-caret-position="184">
64
+ <caret line="8" column="24" selection-start-line="8" selection-start-column="24" selection-end-line="8" selection-end-column="24" />
70
65
  </state>
71
66
  </provider>
72
67
  </entry>
@@ -75,11 +70,11 @@
75
70
  </split-first>
76
71
  <split-second>
77
72
  <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
78
- <file leaf-file-name="utils.rb" pinned="false" current-in-tab="false">
73
+ <file leaf-file-name="utils.rb" pinned="false" current-in-tab="true">
79
74
  <entry file="file://$PROJECT_DIR$/lib/utils.rb">
80
75
  <provider selected="true" editor-type-id="text-editor">
81
- <state relative-caret-position="299">
82
- <caret line="13" column="38" selection-start-line="13" selection-start-column="38" selection-end-line="13" selection-end-column="38" />
76
+ <state relative-caret-position="439">
77
+ <caret line="47" lean-forward="true" selection-start-line="47" selection-end-line="47" />
83
78
  </state>
84
79
  </provider>
85
80
  </entry>
@@ -93,11 +88,11 @@
93
88
  </provider>
94
89
  </entry>
95
90
  </file>
96
- <file leaf-file-name="barong.rb" pinned="false" current-in-tab="true">
91
+ <file leaf-file-name="barong.rb" pinned="false" current-in-tab="false">
97
92
  <entry file="file://$PROJECT_DIR$/lib/barong.rb">
98
93
  <provider selected="true" editor-type-id="text-editor">
99
- <state relative-caret-position="552">
100
- <caret line="24" column="3" lean-forward="true" selection-start-line="24" selection-start-column="3" selection-end-line="24" selection-end-column="3" />
94
+ <state relative-caret-position="115">
95
+ <caret line="5" selection-start-line="5" selection-end-line="8" selection-end-column="7" />
101
96
  </state>
102
97
  </provider>
103
98
  </entry>
@@ -105,8 +100,17 @@
105
100
  <file leaf-file-name="SimBot.gemspec" pinned="false" current-in-tab="false">
106
101
  <entry file="file://$PROJECT_DIR$/SimBot.gemspec">
107
102
  <provider selected="true" editor-type-id="text-editor">
108
- <state relative-caret-position="416">
109
- <caret line="27" column="5" selection-start-line="27" selection-start-column="5" selection-end-line="27" selection-end-column="5" />
103
+ <state relative-caret-position="483">
104
+ <caret line="21" column="32" selection-start-line="21" selection-start-column="32" selection-end-line="21" selection-end-column="32" />
105
+ </state>
106
+ </provider>
107
+ </entry>
108
+ </file>
109
+ <file leaf-file-name="wash_trade.rb" pinned="false" current-in-tab="false">
110
+ <entry file="file://$PROJECT_DIR$/lib/Deamons/wash_trade.rb">
111
+ <provider selected="true" editor-type-id="text-editor">
112
+ <state relative-caret-position="731">
113
+ <caret line="37" column="9" lean-forward="true" selection-start-line="37" selection-start-column="9" selection-end-line="37" selection-end-column="9" />
110
114
  </state>
111
115
  </provider>
112
116
  </entry>
@@ -137,9 +141,12 @@
137
141
  <option value="$PROJECT_DIR$/exe/SimBot" />
138
142
  <option value="$PROJECT_DIR$/lib/utilities.rb" />
139
143
  <option value="$PROJECT_DIR$/.gitignore" />
140
- <option value="$PROJECT_DIR$/SimBot.gemspec" />
141
144
  <option value="$PROJECT_DIR$/lib/api_controller.rb" />
142
145
  <option value="$PROJECT_DIR$/lib/barong.rb" />
146
+ <option value="$PROJECT_DIR$/SimBot.gemspec" />
147
+ <option value="$PROJECT_DIR$/lib/Deamons/WashTrade.rb" />
148
+ <option value="$PROJECT_DIR$/lib/Deamons/deamon.rb" />
149
+ <option value="$PROJECT_DIR$/lib/Deamons/wash_trade.rb" />
143
150
  <option value="$PROJECT_DIR$/lib/utils.rb" />
144
151
  <option value="$PROJECT_DIR$/lib/SimBot.rb" />
145
152
  <option value="$PROJECT_DIR$/lib/SimBot/version.rb" />
@@ -156,9 +163,9 @@
156
163
  <packageJsonPaths />
157
164
  </component>
158
165
  <component name="ProjectFrameBounds">
159
- <option name="x" value="1554" />
166
+ <option name="x" value="1440" />
160
167
  <option name="y" value="22" />
161
- <option name="width" value="1625" />
168
+ <option name="width" value="1615" />
162
169
  <option name="height" value="1058" />
163
170
  </component>
164
171
  <component name="ProjectView">
@@ -174,10 +181,21 @@
174
181
  <item name="SimBot" type="b2602c69:ProjectViewProjectNode" />
175
182
  <item name="SimBot" type="462c0819:PsiDirectoryNode" />
176
183
  </path>
184
+ <path>
185
+ <item name="SimBot" type="b2602c69:ProjectViewProjectNode" />
186
+ <item name="SimBot" type="462c0819:PsiDirectoryNode" />
187
+ <item name="bin" type="462c0819:PsiDirectoryNode" />
188
+ </path>
189
+ <path>
190
+ <item name="SimBot" type="b2602c69:ProjectViewProjectNode" />
191
+ <item name="SimBot" type="462c0819:PsiDirectoryNode" />
192
+ <item name="lib" type="462c0819:PsiDirectoryNode" />
193
+ </path>
177
194
  <path>
178
195
  <item name="SimBot" type="b2602c69:ProjectViewProjectNode" />
179
196
  <item name="SimBot" type="462c0819:PsiDirectoryNode" />
180
197
  <item name="lib" type="462c0819:PsiDirectoryNode" />
198
+ <item name="Deamons" type="462c0819:PsiDirectoryNode" />
181
199
  </path>
182
200
  <path>
183
201
  <item name="SimBot" type="b2602c69:ProjectViewProjectNode" />
@@ -246,27 +264,28 @@
246
264
  <option name="presentableId" value="Default" />
247
265
  <updated>1525279604835</updated>
248
266
  <workItem from="1525279607229" duration="36216000" />
249
- <workItem from="1528301072964" duration="18218000" />
267
+ <workItem from="1528301072964" duration="31359000" />
250
268
  </task>
251
269
  <servers />
252
270
  </component>
253
271
  <component name="TimeTrackingManager">
254
- <option name="totallyTimeSpent" value="54434000" />
272
+ <option name="totallyTimeSpent" value="67575000" />
255
273
  </component>
256
274
  <component name="ToolWindowManager">
257
- <frame x="1554" y="22" width="1625" height="1058" extended-state="0" />
275
+ <frame x="1440" y="22" width="1615" height="1058" extended-state="0" />
258
276
  <editor active="true" />
259
277
  <layout>
260
- <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.22362603" />
261
278
  <window_info anchor="bottom" id="TODO" order="6" />
262
- <window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
263
279
  <window_info anchor="bottom" id="Event Log" order="7" sideWeight="0.50380623" side_tool="true" weight="0.28540304" />
264
- <window_info anchor="right" id="Database" order="3" />
265
280
  <window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" />
266
281
  <window_info anchor="bottom" id="Version Control" order="7" />
267
- <window_info anchor="bottom" id="Run" order="2" sideWeight="0.48719722" weight="0.28649238" />
282
+ <window_info anchor="bottom" id="Run" order="2" sideWeight="0.48719722" visible="true" weight="0.28540304" />
283
+ <window_info anchor="bottom" id="Terminal" order="7" sideWeight="0.49619377" weight="0.41463414" />
284
+ <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.22504768" />
285
+ <window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
286
+ <window_info anchor="right" id="Database" order="3" />
287
+ <window_info anchor="bottom" id="Find" order="1" sideWeight="0.49896193" weight="0.32897604" />
268
288
  <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
269
- <window_info anchor="bottom" id="Terminal" order="7" sideWeight="0.49619377" weight="0.3453159" />
270
289
  <window_info id="Favorites" order="2" side_tool="true" />
271
290
  <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
272
291
  <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
@@ -275,7 +294,6 @@
275
294
  <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
276
295
  <window_info anchor="bottom" id="Message" order="0" />
277
296
  <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
278
- <window_info anchor="bottom" id="Find" order="1" sideWeight="0.49896193" weight="0.32897604" />
279
297
  <window_info anchor="bottom" id="Messages" order="7" sideWeight="0.49965397" weight="0.3293348" />
280
298
  </layout>
281
299
  <layout-to-restore>
@@ -304,12 +322,15 @@
304
322
  <component name="TypeScriptGeneratedFilesManager">
305
323
  <option name="version" value="1" />
306
324
  </component>
325
+ <component name="UnknownFeatures">
326
+ <option featureType="com.intellij.fileTypeFactory" implementationName="*.rb" />
327
+ </component>
307
328
  <component name="VcsContentAnnotationSettings">
308
329
  <option name="myLimit" value="2678400000" />
309
330
  </component>
310
331
  <component name="XDebuggerManager">
311
332
  <breakpoint-manager>
312
- <option name="time" value="2" />
333
+ <option name="time" value="4" />
313
334
  </breakpoint-manager>
314
335
  </component>
315
336
  <component name="editorHistoryManager">
@@ -379,25 +400,18 @@
379
400
  </state>
380
401
  </provider>
381
402
  </entry>
382
- <entry file="file://$PROJECT_DIR$/bin/setup">
383
- <provider selected="true" editor-type-id="text-editor">
384
- <state>
385
- <caret line="6" selection-start-line="6" selection-end-line="6" />
386
- </state>
387
- </provider>
388
- </entry>
389
- <entry file="file://$PROJECT_DIR$/bin/console">
403
+ <entry file="file://$PROJECT_DIR$/lib/utilities.rb" />
404
+ <entry file="file://$PROJECT_DIR$/.gitignore">
390
405
  <provider selected="true" editor-type-id="text-editor">
391
406
  <state relative-caret-position="322">
392
407
  <caret line="14" selection-start-line="14" selection-end-line="14" />
393
408
  </state>
394
409
  </provider>
395
410
  </entry>
396
- <entry file="file://$PROJECT_DIR$/lib/utilities.rb" />
397
- <entry file="file://$PROJECT_DIR$/exe/SimBot">
411
+ <entry file="file://$PROJECT_DIR$/lib/api_controller.rb">
398
412
  <provider selected="true" editor-type-id="text-editor">
399
- <state relative-caret-position="92">
400
- <caret line="4" column="7" selection-start-line="4" selection-start-column="7" selection-end-line="4" selection-end-column="7" />
413
+ <state relative-caret-position="184">
414
+ <caret line="8" column="24" selection-start-line="8" selection-start-column="24" selection-end-line="8" selection-end-column="24" />
401
415
  </state>
402
416
  </provider>
403
417
  </entry>
@@ -408,45 +422,66 @@
408
422
  </state>
409
423
  </provider>
410
424
  </entry>
411
- <entry file="file://$PROJECT_DIR$/SimBot.gemspec">
425
+ <entry file="file://$PROJECT_DIR$/bin/setup">
412
426
  <provider selected="true" editor-type-id="text-editor">
413
- <state relative-caret-position="416">
414
- <caret line="27" column="5" selection-start-line="27" selection-start-column="5" selection-end-line="27" selection-end-column="5" />
427
+ <state relative-caret-position="184">
428
+ <caret line="8" lean-forward="true" selection-start-line="8" selection-end-line="8" />
415
429
  </state>
416
430
  </provider>
417
431
  </entry>
418
- <entry file="file://$PROJECT_DIR$/.gitignore">
432
+ <entry file="file://$PROJECT_DIR$/bin/console">
419
433
  <provider selected="true" editor-type-id="text-editor">
420
434
  <state relative-caret-position="322">
421
435
  <caret line="14" selection-start-line="14" selection-end-line="14" />
422
436
  </state>
423
437
  </provider>
424
438
  </entry>
425
- <entry file="file://$PROJECT_DIR$/lib/api_controller.rb">
439
+ <entry file="file://$PROJECT_DIR$/SimBot.gemspec">
426
440
  <provider selected="true" editor-type-id="text-editor">
427
- <state relative-caret-position="414">
428
- <caret line="18" column="53" lean-forward="true" selection-start-line="18" selection-start-column="53" selection-end-line="18" selection-end-column="53" />
441
+ <state relative-caret-position="483">
442
+ <caret line="21" column="32" selection-start-line="21" selection-start-column="32" selection-end-line="21" selection-end-column="32" />
429
443
  </state>
430
444
  </provider>
431
445
  </entry>
432
- <entry file="file://$PROJECT_DIR$/lib/utils.rb">
446
+ <entry file="file://$PROJECT_DIR$/lib/barong.rb">
433
447
  <provider selected="true" editor-type-id="text-editor">
434
- <state relative-caret-position="299">
435
- <caret line="13" column="38" selection-start-line="13" selection-start-column="38" selection-end-line="13" selection-end-column="38" />
448
+ <state relative-caret-position="115">
449
+ <caret line="5" selection-start-line="5" selection-end-line="8" selection-end-column="7" />
436
450
  </state>
437
451
  </provider>
438
452
  </entry>
439
- <entry file="file://$PROJECT_DIR$/lib/barong.rb">
453
+ <entry file="file://$PROJECT_DIR$/lib/Deamons/deamon.rb">
440
454
  <provider selected="true" editor-type-id="text-editor">
441
- <state relative-caret-position="552">
442
- <caret line="24" column="3" lean-forward="true" selection-start-line="24" selection-start-column="3" selection-end-line="24" selection-end-column="3" />
455
+ <state relative-caret-position="69">
456
+ <caret line="3" column="3" lean-forward="true" selection-start-line="3" selection-start-column="3" selection-end-line="3" selection-end-column="3" />
457
+ </state>
458
+ </provider>
459
+ </entry>
460
+ <entry file="file://$PROJECT_DIR$/lib/Deamons/wash_trade.rb">
461
+ <provider selected="true" editor-type-id="text-editor">
462
+ <state relative-caret-position="731">
463
+ <caret line="37" column="9" lean-forward="true" selection-start-line="37" selection-start-column="9" selection-end-line="37" selection-end-column="9" />
464
+ </state>
465
+ </provider>
466
+ </entry>
467
+ <entry file="file://$PROJECT_DIR$/lib/utils.rb">
468
+ <provider selected="true" editor-type-id="text-editor">
469
+ <state relative-caret-position="439">
470
+ <caret line="47" lean-forward="true" selection-start-line="47" selection-end-line="47" />
443
471
  </state>
444
472
  </provider>
445
473
  </entry>
446
474
  <entry file="file://$PROJECT_DIR$/lib/SimBot.rb">
447
475
  <provider selected="true" editor-type-id="text-editor">
448
- <state relative-caret-position="604">
449
- <caret line="36" selection-start-line="36" selection-end-line="36" />
476
+ <state relative-caret-position="365">
477
+ <caret line="26" column="23" lean-forward="true" selection-start-line="26" selection-start-column="23" selection-end-line="26" selection-end-column="23" />
478
+ </state>
479
+ </provider>
480
+ </entry>
481
+ <entry file="file://$PROJECT_DIR$/exe/SimBot">
482
+ <provider selected="true" editor-type-id="text-editor">
483
+ <state relative-caret-position="92">
484
+ <caret line="4" column="7" selection-start-line="4" selection-start-column="7" selection-end-line="4" selection-end-column="7" />
450
485
  </state>
451
486
  </provider>
452
487
  </entry>
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- SimBot (0.1.3)
4
+ SimBot (0.1.4)
5
5
  json
6
6
  pusher-client
7
7
  rest-client
Binary file
Binary file
Binary file
@@ -0,0 +1,54 @@
1
+
2
+ module Deamons
3
+ # Simple process to add wash trades to a market in order to simulate trade matching for QA and dev
4
+ class WashTrade
5
+ require 'utils'
6
+ def initialize(api, market, freq)
7
+ @api = api
8
+ @market = market
9
+ @freq = freq
10
+ Process.fork do
11
+ Process.daemon(true)
12
+ pid = Process.pid
13
+ redirect("#{pid}.outfile","#{pid}.errfile")
14
+ write_pid_file(pid, "#{pid}.pid")
15
+ start
16
+ end
17
+ puts "SimBot started on #{market} @ freq #{freq}"
18
+ end
19
+
20
+ def start
21
+ count = 0
22
+ loop do
23
+ vol = rand(1...10)
24
+ price = Utils.get_bchbtc_price
25
+ @api.post_order(@market, price, vol, 'sell')
26
+ delay = (1.00 / @freq)
27
+ sleep(delay)
28
+ @api.post_order(@market, price, vol, 'buy')
29
+ puts "order ##{count} placed"
30
+ count += 1
31
+ end
32
+ end
33
+
34
+ # Attempts to write the pid of the forked process to the pid file.
35
+ def write_pid_file(pid, pidfile)
36
+ File.open pidfile, "w" do |f|
37
+ f.write pid
38
+ end
39
+ rescue ::Exception => e
40
+ $stderr.puts "While writing the PID to file, unexpected #{e.class}: #{e}"
41
+ Process.kill "HUP", pid
42
+ end
43
+
44
+ # Send stdout and stderr to log files for the child process
45
+ def redirect(outfile, errfile)
46
+ $stdin.reopen '/dev/null'
47
+ out = File.new outfile, "a"
48
+ err = File.new errfile, "a"
49
+ $stdout.reopen out
50
+ $stderr.reopen err
51
+ $stdout.sync = $stderr.sync = true
52
+ end
53
+ end
54
+ end
@@ -7,6 +7,7 @@ module SimBot
7
7
  require 'utils'
8
8
  require 'barong'
9
9
  require 'api_controller'
10
+ require 'deamons/wash_trade'
10
11
  desc 'start', 'Start simulation bot parsing in base-url and auth token.'
11
12
  method_option :email, type: :string, default: 'admin@ovex.io', required: true, desc: 'Your OVEX email address'
12
13
  method_option :password, type: :string, default: '1bQozgrr', required: true, desc: 'Your OVEX password'
@@ -19,15 +20,15 @@ module SimBot
19
20
  count = 0
20
21
  jwt = Barong::API.new(options[:barong_base_url], options[:app_id]).log_in(options[:email], options[:password])
21
22
  api = ApiController.new(options[:peatio_base_url], jwt)
22
- loop do
23
- vol = rand(1...10)
24
- price = Utils.get_bchbtc_price
25
- api.post_order(options[:market], price, vol, 'sell')
26
- sleep(1 / options[:freq])
27
- api.post_order(options[:market], price, vol, 'buy')
28
- puts "order ##{count} placed"
29
- count += 1
30
- end
23
+ Deamons::WashTrade.new(api, options[:market], options[:freq])
24
+ end
25
+ desc 'list', 'Return list of running processes'
26
+ def list
27
+ puts Dir['*.pid']
28
+ end
29
+ desc 'stop pid', 'stop a running process with the given pid'
30
+ def stop(pid)
31
+ Utils.kill_process(pid)
31
32
  end
32
33
  desc 'test_ws', 'connect to web socket and test it is working correctly'
33
34
  def test_ws
@@ -1,3 +1,3 @@
1
1
  module SimBot
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -19,5 +19,29 @@ class Utils
19
19
  hash = JSON.parse (response.body)
20
20
  return hash['data']['quotes']['ETH']['price'].to_f.round(4)
21
21
  end
22
+
23
+ # Try and read the existing pid from the pid file and signal the
24
+ # process. Returns true for a non blocking status.
25
+ def self.kill_process(pid)
26
+ opid = File.read("#{pid}.pid").strip.to_i
27
+ Process.kill "HUP", opid
28
+ File.delete("#{pid}.pid")
29
+ File.delete("#{pid}.outfile")
30
+ File.delete("#{pid}.errfile")
31
+ puts "Stopped process #{pid}"
32
+ true
33
+ rescue Errno::ENOENT
34
+ $stdout.puts "#{pid} did not exist: Errno::ENOENT"
35
+ true
36
+ rescue Errno::ESRCH
37
+ $stdout.puts "The process #{opid} did not exist: Errno::ESRCH"
38
+ true
39
+ rescue Errno::EPERM
40
+ $stderr.puts "Lack of privileges to manage the process #{opid}: Errno::EPERM"
41
+ false
42
+ rescue ::Exception => e
43
+ $stderr.puts "While signaling the PID, unexpected #{e.class}: #{e}"
44
+ false
45
+ end
22
46
  end
23
47
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: SimBot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Ovadia
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-08 00:00:00.000000000 Z
11
+ date: 2018-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -135,10 +135,14 @@ files:
135
135
  - LICENSE.txt
136
136
  - README.md
137
137
  - Rakefile
138
+ - SimBot-0.1.1.gem
139
+ - SimBot-0.1.2.gem
140
+ - SimBot-0.1.3.gem
138
141
  - SimBot.gemspec
139
142
  - bin/console
140
143
  - bin/setup
141
144
  - exe/SimBot
145
+ - lib/Deamons/wash_trade.rb
142
146
  - lib/SimBot.rb
143
147
  - lib/SimBot/version.rb
144
148
  - lib/api_controller.rb