kemargrant / c4d

A crypto trading robot that performs triangular arbitrage
Other
47 stars 10 forks source link

Tests Failing #3

Closed beneaththeglamour closed 6 years ago

beneaththeglamour commented 6 years ago

Trying to setup the software but the test fails on 2 cases with the default configurations.

    ##Trade (>100)
Binance Bot: 100.020% Sat Apr 21 2018 10:48:30
0.004889btc => 43.23826711 usdt @8843.99
43.23829284000001usdt => 2.36004 ltc @18.321
2.36ltc => 0.004890 btc @0.002072

Optimal Trade Not Found: 2018-04-21T10:48:30.301Z
      1) Should return false (sub optimal trade)
    ##Trade (<100)
Binance Bot: 99.764% Sat Apr 21 2018 10:48:30
0.45ltc => 398.80350000000004 usdt @886.23
398.80444545usdt => 0.037129 btc @10741.05
0.03704130btc => 0.45 ltc @0.082314

Optimal Trade Not Found: 2018-04-21T10:48:30.304Z
      2) Should return false

  222 passing (10s)
  2 failing

  1) #Arbitrage
       ##Trade (>100)
         Should return false (sub optimal trade):

      AssertionError [ERR_ASSERTION]: false == true
      + expected - actual

      -false
      +true

      at Context.<anonymous> (test/binance.js:225:11)

  2) #Arbitrage
       ##Trade (<100)
         Should return false:

      AssertionError [ERR_ASSERTION]: false == true
      + expected - actual

      -false
      +true

      at Context.<anonymous> (test/binance.js:260:11)

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |    97.45 |    91.03 |    90.94 |    99.28 |                   |
 c4d.js   |    97.45 |    91.03 |    90.94 |    99.28 |... 1068,1522,2378 |
----------|----------|----------|----------|----------|-------------------|
npm ERR! Test failed.  See above for more details.
beneaththeglamour commented 6 years ago

On an unrelated note, could you please explain how the "limits" configuration settings work (such as "Trades > 100% Lower Limit", etc.)

kemargrant commented 6 years ago

Can you tell me a bit more about your environment setup. Node version mocha version etc...

Limits: There are two kinds of trades, one where the relation of the pairs is over 1 or under 1. I use 100% through out the code but there is no difference.

When a trade is below 100% for example you want to define some limits about where you are willing to trade. If there was a 50% imbalance for example that would not be a trade likely to be resolved however highly profitable. So you want to set your "under" lower limit to something about 80% and your "under" upper limit to anything under 100%.

kemargrant commented 6 years ago

The program was developed with node v7.7.2 so I will take a guess you are using node higher than v7. While developing the program I have tried different versions of node and mocha and have seen issues between different versions of node.

beneaththeglamour commented 6 years ago

I've tried node 6.1, the current LTS (8.11.1), as well as node 9.11.1, so pretty much everything besides node v7.x I'll try v7.7.2 and see if it still happens.

Thanks for the explanation!

kemargrant commented 6 years ago

The code is full of undefined references, when the project stabilizes I will expand the readme. I have also made some changes so do a git pull.

beneaththeglamour commented 6 years ago

Pulled and tried again; same tests fail as in the original post (8.11.1)

Edit: Node 7.7.2 doesn't work either (error below)

@ test /home/ubuntu/c4d nyc mocha test/tests.js --exit

/home/ubuntu/c4d/c4d.js:2
var UnderwasmCode=(cov_1hc2alynpm.s[5]++,new Uint8Array([0,97,115,109,1,0,0,0,1,148,128,128,128,0,3,96,1,127,1,127,96,2,125,127,1,124,96,4,127,125,125,125,1,124,3,132,128,128,128,0,3,0,1,2,4,132,128,128,128,0,1,112,0,0,5,131,128,128,128,0,1,0,1,6,129,128,128,128,0,0,7,159,128,128,128,0,4,6,109,101,109,111,114,121,2,0,5,112,111,119,101,114,0,0,2,103,80,0,1,5,117,110,100,101,114,0,2,10,159,130,128,128,0,3,171,128,128,128,0,1,1,127,65,1,33,1,2,64,32,0,65,1,72,13,0,65,1,33,1,3,64,32,1,65,10,108,33,1,32,0,65,127,106,34,0,13,0,11,11,32,1,11,199,128,128,128,0,2,1,127,1,124,65,1,33,2,2,64,2,64,32,1,65,1,72,13,0,3,64,32,2,65,10,108,33,2,32,1,65,127,106,34,1,13,0,11,32,2,183,33,3,12,1,11,68,0,0,0,0,0,0,240,63,33,3,11,32,3,32,0,187,162,170,183,32,3,163,11,157,129,128,128,0,2,2,127,2,124,68,0,0,0,0,0,0,240,63,33,7,68,0,0,0,0,0,0,240,63,33,6,2,64,32,0,65,1,106,34,4,65,1,72,13,0,65,1,33,5,3,64,32,5,65,10,108,33,5,32,4,65,127,106,34,4,13,0,11,32,5,183,33,6,11,68,0,0,0,0,0,136,141,64,32,6,163,32,3

ReferenceError: WebAssembly is not defined
    at Object.<anonymous> (/home/ubuntu/c4d/c4d.js:2:1261)
    at Module._compile (module.js:571:32)
    at Module.replacementCompile (/home/ubuntu/c4d/node_modules/nyc/node_modules/append-transform/index.js:58:13)
    at module.exports (/home/ubuntu/c4d/node_modules/nyc/node_modules/default-require-extensions/js.js:8:9)
    at Object.<anonymous> (/home/ubuntu/c4d/node_modules/nyc/node_modules/append-transform/index.js:62:4)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/ubuntu/c4d/test/general.js:1:79)
    at Module._compile (module.js:571:32)
    at Module.replacementCompile (/home/ubuntu/c4d/node_modules/nyc/node_modules/append-transform/index.js:58:13)
    at module.exports (/home/ubuntu/c4d/node_modules/nyc/node_modules/default-require-extensions/js.js:8:9)
    at Object.<anonymous> (/home/ubuntu/c4d/node_modules/nyc/node_modules/append-transform/index.js:62:4)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/ubuntu/c4d/test/tests.js:1:63)
    at Module._compile (module.js:571:32)
    at Module.replacementCompile (/home/ubuntu/c4d/node_modules/nyc/node_modules/append-transform/index.js:58:13)
    at module.exports (/home/ubuntu/c4d/node_modules/nyc/node_modules/default-require-extensions/js.js:8:9)
    at Object.<anonymous> (/home/ubuntu/c4d/node_modules/nyc/node_modules/append-transform/index.js:62:4)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at /home/ubuntu/c4d/node_modules/mocha/lib/mocha.js:253:27
    at Array.forEach (native)
    at Mocha.loadFiles (/home/ubuntu/c4d/node_modules/mocha/lib/mocha.js:250:14)
    at Mocha.run (/home/ubuntu/c4d/node_modules/mocha/lib/mocha.js:577:10)
    at Object.<anonymous> (/home/ubuntu/c4d/node_modules/mocha/bin/_mocha:591:18)
    at Module._compile (module.js:571:32)
    at Module.replacementCompile (/home/ubuntu/c4d/node_modules/nyc/node_modules/append-transform/index.js:58:13)
    at module.exports (/home/ubuntu/c4d/node_modules/nyc/node_modules/default-require-extensions/js.js:8:9)
    at Object.<anonymous> (/home/ubuntu/c4d/node_modules/nyc/node_modules/append-transform/index.js:62:4)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Function.Module.runMain (module.js:605:10)
    at runMain (/home/ubuntu/.node-spawn-wrap-11814-8f4fe25e168d/node:68:10)
    at Function.<anonymous> (/home/ubuntu/.node-spawn-wrap-11814-8f4fe25e168d/node:171:5)
    at Object.<anonymous> (/home/ubuntu/c4d/node_modules/nyc/bin/wrap.js:23:4)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Function.Module.runMain (module.js:605:10)
    at /home/ubuntu/.node-spawn-wrap-11814-8f4fe25e168d/node:178:8
    at Object.<anonymous> (/home/ubuntu/.node-spawn-wrap-11814-8f4fe25e168d/node:181:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:425:7)
    at startup (bootstrap_node.js:146:9)
    at bootstrap_node.js:540:3
----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |     0.54 |        0 |        0 |     0.56 |                   |
 c4d.js   |     0.54 |        0 |        0 |     0.56 |... 2582,2583,2586 |
----------|----------|----------|----------|----------|-------------------|
npm ERR! Test failed.  See above for more details.
kemargrant commented 6 years ago

I have updated the code, you will need to use at least node v8 now. I also put it in the readme to be more explicit about the node version the program requires.

I can finally replicate your error on another machine. This is a bug I will have to track down. Interestingly it does not appear on my either of my local machines or circleci integration server otherwise the build would not pass.

beneaththeglamour commented 6 years ago

Odd bug, I feel like this sort of thing happens once in a while with node.js though. I tried on v8 and the same 2 tests fail; I'm on AWS EC2 Ubuntu LTS if that's helpful.

Also, could you explain trades over 100% and their limits please?

kemargrant commented 6 years ago

I have made some updates to the master branch. Try mocha --exit as well as npm test I have narrowed down the problem to mocha....and funky tests. There are some tests in the general.js that when run before binance.js tests cause the binance tests to appear to fail when in reality it is a problem with another test in general.js I have seen this while testing with mocha. It would appear I need a test for my tests. Enter testception.

beneaththeglamour commented 6 years ago

Yippy, all good now.


  228 passing (18s)

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |    97.77 |    92.13 |    92.13 |    99.68 |                   |
 c4d.js   |    97.77 |    92.13 |    92.13 |    99.68 |... 1081,1539,1540 |
----------|----------|----------|----------|----------|-------------------|
ubuntu@ip-172-31-5-142:~/c4d$