frostybot-js
frostybot-js copied to clipboard
maxposqty: incorrect behaviour when multiple trades are executed at the same time
Scenario: my stub is configured to only have 2 maximum positions at the same time (risk assessment). This is done via the command: frostybot config:set adxatrdca:maxposqty=2
Today, I already had one open position on this stub (MATIC). Then I had 3 TV alerts to enter a long position at exactly the same time.
Expected behaviour: only open 1 new position instead of 3. Actual behaviour: I had 4 open positions instead of the maximum of 2.
Logs:
2021-05-22 16:42:05 | DEBUG | Connection from IP: 52.32.178.7 (Context ID: 9af5ffd2-5921-4dd6-b37c-c75d4905d309)
2021-05-22 16:42:05 | DEBUG | Access granted on API using core uuid
2021-05-22 16:42:05 | NOTICE | Whitelist verification is enabled
2021-05-22 16:42:05 | NOTICE | API Access Granted: 52.32.178.7 is whitelisted
2021-05-22 16:42:05 | NOTICE | Command Parameters: {command: trade:long, symbol: MATIC-PERP, stub: adxatrdca}
2021-05-22 16:42:05 | DEBUG | Execute permission granted using standard permission set: trade:long => [core, singleuser]
2021-05-22 16:42:06 | DEBUG | Size not provided, using default size: adxatrdca:defsize
2021-05-22 16:42:08 | DEBUG | Current position size in USD: 0
2021-05-22 16:42:08 | DEBUG | Current available balance in USD: 204.16
2021-05-22 16:42:09 | DEBUG | Order size provided in USD (USD size)
2021-05-22 16:42:09 | NOTICE | Current position USD size is: USD 0
2021-05-22 16:42:09 | NOTICE | Target position USD size is: USD 48
2021-05-22 16:42:09 | NOTICE | Order required to reach target: Buy => USD 48
2021-05-22 16:42:09 | DEBUG | Size provided in USD on a stablecoin-paired asset. Using USD size as quote size.
2021-05-22 16:42:09 | DEBUG | Exchange uses base sizing. Order size converted to MATIC (36.3621212752499)
2021-05-22 16:42:09 | NOTICE | Order added to queue: {symbol: MATIC-PERP, type: market, side: buy, amount: 36, params: {}}
2021-05-22 16:42:10 | DEBUG | Take profit size not provided, using default take profit size: default=100%
2021-05-22 16:42:11 | DEBUG | Order submitted to exchange: 50809099378
2021-05-22 16:42:11 | DEBUG | Order submission doublecheck enabled for exchange, checking order: 50809099378
2021-05-22 16:42:15 | NOTICE | Double-checked that order was created on exchange: 50809099378
2021-05-22 16:42:15 | SUCCESS | Order submitted successfully: {stub: adxatrdca, symbol: MATIC-PERP, type: market, side: buy, amount: 36, params: {}}
2021-05-22 16:42:15 | NOTICE | Processed order queue: 1/1 order(s) submitted successfully.
2021-05-22 16:42:15 | NOTICE | Command Completed: Execution Time: 9.943 seconds
2021-05-22 16:46:04 | DEBUG | Connection from IP: 52.32.178.7 (Context ID: 7839b05b-1aaa-4884-a67d-1a635c277a27)
2021-05-22 16:46:04 | DEBUG | Access granted on API using core uuid
2021-05-22 16:46:04 | NOTICE | Whitelist verification is enabled
2021-05-22 16:46:04 | NOTICE | API Access Granted: 52.32.178.7 is whitelisted
2021-05-22 16:46:04 | NOTICE | Command Parameters: {command: trade:long, symbol: EOS-PERP, stub: adxatrdca}
2021-05-22 16:46:04 | DEBUG | Execute permission granted using standard permission set: trade:long => [core, singleuser]
2021-05-22 16:46:05 | DEBUG | Connection from IP: 34.212.75.30 (Context ID: 56796f25-a115-4d3b-9040-f007c582110b)
2021-05-22 16:46:05 | DEBUG | Access granted on API using core uuid
2021-05-22 16:46:05 | NOTICE | Whitelist verification is enabled
2021-05-22 16:46:05 | NOTICE | API Access Granted: 34.212.75.30 is whitelisted
2021-05-22 16:46:05 | NOTICE | Command Parameters: {command: trade:long, symbol: DOT-PERP, stub: adxatrdca}
2021-05-22 16:46:05 | DEBUG | Execute permission granted using standard permission set: trade:long => [core, singleuser]
2021-05-22 16:46:05 | DEBUG | Connection from IP: 34.212.75.30 (Context ID: dd464886-c0f0-4eaa-a115-e7e59c486bf6)
2021-05-22 16:46:05 | DEBUG | Access granted on API using core uuid
2021-05-22 16:46:05 | NOTICE | Whitelist verification is enabled
2021-05-22 16:46:05 | NOTICE | API Access Granted: 34.212.75.30 is whitelisted
2021-05-22 16:46:05 | NOTICE | Command Parameters: {command: trade:long, symbol: AAVE-PERP, stub: adxatrdca}
2021-05-22 16:46:05 | DEBUG | Execute permission granted using standard permission set: trade:long => [core, singleuser]
2021-05-22 16:46:06 | DEBUG | Size not provided, using default size: adxatrdca:defsize
2021-05-22 16:46:08 | DEBUG | Current position size in USD: 0
2021-05-22 16:46:08 | DEBUG | Current available balance in USD: 204.67
2021-05-22 16:46:08 | DEBUG | Order size provided in USD (USD size)
2021-05-22 16:46:08 | NOTICE | Current position USD size is: USD 0
2021-05-22 16:46:08 | NOTICE | Target position USD size is: USD 48
2021-05-22 16:46:08 | NOTICE | Order required to reach target: Buy => USD 48
2021-05-22 16:46:09 | DEBUG | Size provided in USD on a stablecoin-paired asset. Using USD size as quote size.
2021-05-22 16:46:09 | DEBUG | Exchange uses base sizing. Order size converted to EOS (9.051053599208032)
2021-05-22 16:46:10 | NOTICE | Order added to queue: {symbol: EOS-PERP, type: market, side: buy, amount: 9.1, params: {}}
2021-05-22 16:46:10 | DEBUG | Exchange uses base sizing. Order size converted to DOT (2.143431276234706)
2021-05-22 16:46:11 | NOTICE | Order added to queue: {symbol: DOT-PERP, type: market, side: buy, amount: 2.1, params: {}}
2021-05-22 16:46:11 | DEBUG | Exchange uses base sizing. Order size converted to AAVE (0.141643059490085)
2021-05-22 16:46:11 | NOTICE | Order added to queue: {symbol: AAVE-PERP, type: market, side: buy, amount: 0.14, params: {}}
2021-05-22 16:46:11 | DEBUG | Take profit size not provided, using default take profit size: default=100%
2021-05-22 16:46:12 | DEBUG | Order submitted to exchange: 50810222790
2021-05-22 16:46:12 | DEBUG | Order submission doublecheck enabled for exchange, checking order: 50810222790
2021-05-22 16:46:13 | DEBUG | Order submitted to exchange: 50810226390
2021-05-22 16:46:13 | DEBUG | Order submission doublecheck enabled for exchange, checking order: 50810226390
2021-05-22 16:46:14 | DEBUG | Order submitted to exchange: 50810233650
2021-05-22 16:46:14 | DEBUG | Order submission doublecheck enabled for exchange, checking order: 50810233650
2021-05-22 16:46:16 | NOTICE | Double-checked that order was created on exchange: 50810222790
2021-05-22 16:46:16 | SUCCESS | Order submitted successfully: {stub: adxatrdca, symbol: EOS-PERP, type: market, side: buy, amount: 9.1, params: {}}
2021-05-22 16:46:16 | NOTICE | Processed order queue: 1/1 order(s) submitted successfully.
2021-05-22 16:46:16 | NOTICE | Command Completed: Execution Time: 11.764 seconds
2021-05-22 16:46:17 | NOTICE | Double-checked that order was created on exchange: 50810226390
2021-05-22 16:46:17 | SUCCESS | Order submitted successfully: {stub: adxatrdca, symbol: DOT-PERP, type: market, side: buy, amount: 2.1, params: {}}
2021-05-22 16:46:17 | NOTICE | Processed order queue: 1/1 order(s) submitted successfully.
2021-05-22 16:46:17 | NOTICE | Command Completed: Execution Time: 12.219 seconds
2021-05-22 16:46:18 | NOTICE | Double-checked that order was created on exchange: 50810233650
2021-05-22 16:46:18 | SUCCESS | Order submitted successfully: {stub: adxatrdca, symbol: AAVE-PERP, type: market, side: buy, amount: 0.14, params: {}}
2021-05-22 16:46:18 | NOTICE | Processed order queue: 1/1 order(s) submitted successfully.
2021-05-22 16:46:18 | NOTICE | Command Completed: Execution Time: 13.519 seconds
Additional side-effect: when I have DCA orders on one of these 4 open positions, I get the following error (note that DOT was already closed at that time, so I had only 3 open positions anymore on the time of the DCA order on MATIC):
2021-05-22 20:30:10 | DEBUG | Connection from IP: 34.212.75.30 (Context ID: 85758d13-5fe0-4d95-8aa1-d9ba0ae1da4e)
2021-05-22 20:30:10 | DEBUG | Access granted on API using core uuid
2021-05-22 20:30:10 | NOTICE | Whitelist verification is enabled
2021-05-22 20:30:10 | NOTICE | API Access Granted: 34.212.75.30 is whitelisted
2021-05-22 20:30:10 | NOTICE | Command Parameters: {command: trade:long, symbol: MATIC-PERP, stub: adxatrdca}
2021-05-22 20:30:10 | DEBUG | Execute permission granted using standard permission set: trade:long => [core, singleuser]
2021-05-22 20:30:11 | DEBUG | Size not provided, using default size: adxatrdca:defsize
2021-05-22 20:30:12 | ERROR | Maximum positions on adxatrdca reached: 3 positions
2021-05-22 20:30:12 | NOTICE | Command Completed: Execution Time: 2.129 seconds