3

I'm not sure if this is the good place to ask this question, but lets give it a try. To try to learn how Stellar works I tried to use the Kelp trading bot. I've made a trustline with WSD and try to trade WSD/XLM on StellarX. My config is quite simple (not much changed compared to the example files), but I keep getting an error. My first orders XLM -> WSD are placed and filled immediately. But selling WSD -> XLM is never working. These are the errors I keep getting.

:~/Documents/kelp-v1.0.0-rc3 $ cat /home/pi/Documents/kelp-v1.0.0-rc3/TradingResult.txt | grep -E "programm|error"  
2018/10/15 19:47:17 error in buying sub-strategy: error: (programmer?) unable to place offer with the new (reduced) selling and buying amounts, oldSellingAmount=11.3398371, newSellingAmount=3.6671172, oldBuyingAmount=49.9999998, newBuyingAmount=16.1691793  
2018/10/15 19:47:17 liabilities (force recomputed) after encountering an error after a call to UpdateWithOps  
2018/10/15 19:49:19 error in buying sub-strategy: error: (programmer?) unable to place offer with the new (reduced) selling and buying amounts, oldSellingAmount=11.3401784, newSellingAmount=3.6671172, oldBuyingAmount=49.9999999, newBuyingAmount=16.1686927  
2018/10/15 19:49:19 liabilities (force recomputed) after encountering an error after a call to UpdateWithOps  
2018/10/15 19:51:22 error in buying sub-strategy: error: (programmer?) unable to place offer with the new (reduced) selling and buying amounts, oldSellingAmount=11.3284197, newSellingAmount=3.6671172, oldBuyingAmount=50.0000002, newBuyingAmount=16.1854756  
2018/10/15 19:51:22 liabilities (force recomputed) after encountering an error after a call to UpdateWithOps  
2018/10/15 19:53:16 error in buying sub-strategy: error: (programmer?) unable to place offer with the new (reduced) selling and buying amounts, oldSellingAmount=48.6799925, newSellingAmount=3.6671172, oldBuyingAmount=214.7483647, newBuyingAmount=16.1772297  
2018/10/15 19:53:16 liabilities (force recomputed) after encountering an error after a call to UpdateWithOps  
2018/10/15 19:55:24 error in buying sub-strategy: error: (programmer?) unable to place offer with the new (reduced) selling and buying amounts, oldSellingAmount=48.6799925, newSellingAmount=3.6671172, oldBuyingAmount=214.7483647, newBuyingAmount=16.1772297  
2018/10/15 19:55:24 liabilities (force recomputed) after encountering an error after a call to UpdateWithOps  
2018/10/15 19:57:27 error in buying sub-strategy: error: (programmer?) unable to place offer with the new (reduced) selling and buying amounts, oldSellingAmount=48.6847281, newSellingAmount=3.6671172, oldBuyingAmount=214.7483649, newBuyingAmount=16.1756562  
2018/10/15 19:57:27 liabilities (force recomputed) after encountering an error after a call to UpdateWithOps  
2018/10/15 19:59:35 error in buying sub-strategy: error: (programmer?) unable to place offer with the new (reduced) selling and buying amounts, oldSellingAmount=48.6768367, newSellingAmount=3.6671172, oldBuyingAmount=214.7483647, newBuyingAmount=16.1782785  
2018/10/15 19:59:35 liabilities (force recomputed) after encountering an error after a call to UpdateWithOps  
2018/10/15 20:00:30 error in buying sub-strategy: error: (programmer?) unable to create offer but available capacities were more than the attempted offer amounts, sellingCapacity=3.6671172, incrementalSellAmount=2.2660619, buyingCapacity=179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0000000, incrementalBuyAmount=10.0000000  
2018/10/15 20:00:30 liabilities (force recomputed) after encountering an error after a call to UpdateWithOps  
2018/10/15 20:02:33 error in buying sub-strategy: error: (programmer?) unable to create offer but available capacities were more than the attempted offer amounts, sellingCapacity=3.6671172, incrementalSellAmount=2.2659831, buyingCapacity=179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0000000, incrementalBuyAmount=9.9999998

UPDATE:

./kelp version
  version: v1.0.0-rc3  
  git hash: c8363e74c80cc3854dfbf19110f10b8ad21fe3d4  
  build date: 20180929T155837Z    
  GOOS: Linux  
  GOARCH: arm  

Command to trade:

./kelp trade --botConf ./trader.cfg --strategy buysell --stratConf ./buysell.cfg &>> TradingResult.txt

Summary of trader.cfg:

TRADING_SECRET_SEED="SECRET"    
ASSET_CODE_A="XLM"  
ASSET_CODE_B="WSD"  
ISSUER_B="WSD-ISSUER-ADDRESS"  
TICK_INTERVAL_SECONDS=120  
HORIZON_URL="https://horizon.stellar.org"  

buysell.cfg is the same as the example file. Have tried some variations in amount, but no difference.

Balance of stellar account: 20.2597866 XLM. Just started really low, since I want to learn Stellar and the trading bot.

0

1 Answer 1

0

Your ISSUER_B value should be a public key, not a private key! See the account setup walkthrough and the sample trader config for details.

If you are looking for the WSD token on stellar, the public key is listed in their stellar.toml.


The suggested approach to testing out Kelp is to run it on the testnet. This way you can have higher balances in the account without risking any real money.

Since you are running in production, you should set your AMOUNT and AMOUNT_OF_A_BASE values to be very low to start out and also just stick to 1 level. This will ensure that the bot has the full balance available in its account to place all its trades which will prevent the code from going into the CAP-0003 logic for the bot (which is where this error is being triggered).

Once you get that part working it would make sense to try to slowly scale up from there.


After looking at the log file you shared via Keybase Chat, I found this log line to the best indicator of the root cause:

we will oversell the asset 'native', amountSelling = 0.0101223, bal = 20.2597866, minAccountBal = 22.0000000, liabilities.Selling = 0.0000000

This shows that your native balance was too low (bal = 20.2597866, minAccountBal = 22.0000000). The minimum balance on your account as computed for this log line is 1 XLM for your Stellar account + 0.5 XLM for the WSD trustline + 0.5 XLM for the offer you have outstanding + 20 XLM as a buffer required by Kelp. This is how the bot arrived at a minimum balance requirement of 22 XLM for your current setup.

If Kelp ever reaches a situation where it has run out of one of its assets then it will only place offers to purchase that asset until it has enough of both assets to place offers on both sides. This automatic adjustment ensures that your bot is always active in the market, allowing itself to eventually build up to providing liquidity to both sides of a market even if you may have started out with just one of the two assets.

You can always deposit more lumens into the account so the bot can place offers to sell both assets.


Here's some more information on the minimum balance requirements of Kelp:

  • every Stellar account needs a minimum balance of 1 XLM as off the time of writing this post
  • each subentry on your Stellar account increases the minimum balance requirement by a factor equal to the baseReserve of 0.5 XLM as off the time of writing. Having a trustline to the WSD asset is 1 subentry, having an offer is another subentry. If you want to provide liquidity to a token against XLM, you will need to set your levels to 1 so it can place one bid and one ask. You would need enough base reserve to cover 1 trustline and 2 offers, making this limit equal to 1.5 XLM. These requirements will depend on the market you are making and the number of levels/offers you want to place. You can read more about fees in Stellar here.
  • Kelp requires you to have an additional balance of 20 XLM so you can never get into a state where you cannot unwedge yourself manually if your account was to ever get stuck.

Adding all this up brings your minimum XLM balance to 22.5 XLM (1 + 1.5 + 20). Any XLM you keep on top of this will be used as a capacity with which to place offers. If you are not using a separate source_account from which to pay fees then your trading account would need to maintain a slightly higher balance beyond this.

Let me know if you are still getting this error message after increasing your native balance.

2
  • Thanks again! I've added the WSD public key correctly, but changed it wrongly in my question. Thanks for the tips. I don't have a testnet account, so now I'm running with --sim behind it. The depth change didn't seem to help, still sort of same error occuring. Also The 'balanced' strategy seems to trigger this same event, eventhough the depth is only set on 1. error in buying sub-strategy: error: (programmer?) unable to create offer but available capacities were more than the attempted offer amounts,
    – Caros
    Commented Oct 16, 2018 at 19:22
  • Can you share your strategy file? -- feel free to change up some values so you don't expose details of your trading strategy. Are you on Keybase? It's what we use for IM/chat in the Stellar community (keybase.io)
    – nikhils
    Commented Oct 16, 2018 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.