bmino / binance-triangle-arbitrage

Detect in-market cryptocurrency arbitrage
MIT License
1.07k stars 336 forks source link

Code not placing actual orders #116

Closed calatravaj closed 3 years ago

calatravaj commented 3 years ago

Hi Brandon, First of all, thanks for your amazing code.

I have a small issue, maybe I just need help... I have configured it for my exchange and with the minimum requirements, but although I saw some trades with a very nice potential profit, I never saw the trading orders in Binance... Whay I am doing wrongly? Thanks in advance for your support The following is my config.json file: {

"KEYS": {
    "API": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "SECRET": "***********************************************************"
},

"INVESTMENT": {
    "BASE": "USDT",
    "MIN": 10.00,
    "MAX": 20.00,
    "STEP": 0.50
},

"TRADING": {
    "ENABLED": true,
    "EXECUTION_STRATEGY": "linear",
    "EXECUTION_TEMPLATE": [],
    "EXECUTION_CAP": 1,
    "TAKER_FEE": 0.075,
    "PROFIT_THRESHOLD": 0.05,
    "AGE_THRESHOLD": 100,
    "WHITELIST": []
},

"HUD": {
    "ENABLED": true,
    "ARB_COUNT": 5
},

"LOG": {
    "LEVEL": "debug",
    "PRETTY_PRINT": true
},

"DEPTH": {
    "SIZE": 100
},

"WEBSOCKETS": {
    "BUNDLE_SIZE": 1,
    "INITIALIZATION_INTERVAL": 75
},

"TIMING": {
    "RECEIVE_WINDOW": 10000,
    "USE_SERVER_TIME": false,
    "CALCULATION_COOLDOWN": 250,
    "STATUS_UPDATE_INTERVAL": 120000
}

}

bmino commented 3 years ago

Hey, thanks!

What did you see that made you want a trade to be executed? Did the bot display logs indicating it performed orders?

I'd want to see your logs (from the /logs) directory for further understanding

calatravaj commented 3 years ago

Hi Bradon, I saw some profitable triangles in the HUD, even above 1%. My threshold is 0,1% so I thought these orders should be done. On top of this, I tried one manually and it was a profit... I will send the logs ASAP Thanks and regards Javier

El sáb., 17 oct. 2020 7:56, Brandon notifications@github.com escribió:

Hey, thanks!

What did you see that made you want a trade to be executed? Did the bot display logs indicating it performed orders?

I'd want to see your logs (from the /logs) directory for further understanding

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bmino/binance-triangle-arbitrage/issues/116#issuecomment-710756759, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARM6G4K5LJFYLRK2T2ELDULSLEWXNANCNFSM4ST2DZJQ .

calatravaj commented 3 years ago

My logs of last execution Thanks for your support

binance.log execution.log performance.log

bmino commented 3 years ago

Okay I notice a few things going through those logs. Mostly that websockets are timing out and reconnecting (something I hope to have fixed in v4).

You said you saw something in the HUD with a calculated profit above 1%? Did this entry also have an age below your allowed threshold of 100 ms? Keep in mind ages in the HUD are displayed in terms of seconds, not milliseconds. This is my suspicion

calatravaj commented 3 years ago

So I should change the age threshold accordingly?

El sáb., 17 oct. 2020 20:05, Brandon notifications@github.com escribió:

Okay I notice a few things going through those logs. Mostly that websockets are timing out and reconnecting (something I hope to have fixed in v4).

You said you saw something in the HUD with a calculated profit above 1%? Did this entry also have an age below your allowed threshold of 100 ms? Keep in mind ages in the HUD are displayed in terms of seconds, not milliseconds. This is my suspicion

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bmino/binance-triangle-arbitrage/issues/116#issuecomment-711058555, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARM6G4KGGKKIXUTCRP56AJTSLHMFLANCNFSM4ST2DZJQ .

bmino commented 3 years ago

I think the trade you saw in the HUD had an acceptable profit, but an unacceptable age and therefore wasn't executed.

You can increase your age threshold to something higher if you wish, but I think an age threshold of 100 ms is perfectly fine.

calatravaj commented 3 years ago

I have modified the age threshold a bit is is doing some orders, it is true that a high threshold would allow some orders that are not as profitable as shown, but I am just testing now in a controlled sub-account Are you working in V4 of software? By when it would be published in GitHub? Thanks again for your knowledge and support Regards

El sáb., 17 oct. 2020 23:12, Brandon notifications@github.com escribió:

I think the trade you saw in the HUD had an acceptable profit, but an unacceptable age and therefore wasn't executed.

You can increase your age threshold to something higher if you wish, but I think an age threshold of 100 ms is perfectly fine.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bmino/binance-triangle-arbitrage/issues/116#issuecomment-711081071, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARM6G4PUBT6DFUDN6XY6YGTSLICEHANCNFSM4ST2DZJQ .

bmino commented 3 years ago

Age threshold regulates how old order book data can be until you don't trust it anymore. We are receiving order book updates via websocket at best every 100ms. Consider the following example:

Time (ms) Event Age of Tickers Overall Age
0 Order book update received for AB and BC tickers 0 - 0 - null null
70 Order book update received for AB ticker 70 - 70 - 0 70
120 Order book update received for unrelated ticker 120 - 120 - 50 120

And age threshold of 70 or less would have executed this position at time=70 when the AB ticker update was received. I wouldn't recommend setting an age threshold of anything higher than 150 ms. Ideally it should be about the same as your latency.

calatravaj commented 3 years ago

I agree with you, but there are potential arbitrage triangles that are valid for a few minutes. As I said before, I am now trying some different values to see which one is better. And I also consider 300ms as my latency is normally around 290ms... I will keep you informed Regards

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Libre de virus. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

El dom., 18 oct. 2020 a las 6:44, Brandon (notifications@github.com) escribió:

Age threshold regulates how old order book data can be until you don't trust it anymore. We are receiving order book updates via websocket at best every 100ms. Consider the following example: Time (ms) Event Age of Tickers Overall Age 0 Order book update received for AB and BC tickers 0 - 0 - null null 70 Order book update received for AB ticker 70 - 70 - 0 70 120 Order book update received for unrelated ticker 120 - 120 - 50 120

And age threshold of 70 or less would have executed this position at time=70 when the AB ticker update was received. I wouldn't recommend setting an age threshold of anything higher than 150 ms. Ideally it should be about the same as your latency.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bmino/binance-triangle-arbitrage/issues/116#issuecomment-711115952, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARM6G4NQODUS4WU4AMGVUALSLJXBRANCNFSM4ST2DZJQ .

georgekhanachat commented 3 years ago

Hey @bmino!

I just recently cloned your repo, honestly looks pretty neat. I've had the same problem where its not been placing orders even at really high percentages of 4% that have been going own for an age of around 40 to 100 seconds. I have a very similar config file. The logs still show that WebSocket are being disconnected so i increased the bundle size in hopes of reducing the number of sockets but that didn't fix the issue. The program would run on the HUD make a max of one trade and exit with the following error: image

I hope to reopen this issue to help make this program work!