Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use hedge #2

Closed
inmyth opened this issue May 18, 2017 · 4 comments
Closed

How to use hedge #2

inmyth opened this issue May 18, 2017 · 4 comments

Comments

@inmyth
Copy link

inmyth commented May 18, 2017

Hello and thank you in advance for sharing this project.
I am currently trying to run the bot on altnet with config generated from altnet command.
The command I use is xmm -c dummy.json hedge fund1 -n 3 -y (enclosed in loop like your example) where fund1 is a wallet that has been funded with BTC, USD, and XRP.
I am assuming that Talmudic algorithm does market making by maintaining order pairs with spread that keeps those assets balanced all the time.
After I run it, I created some random offers from another account. I think if the bot works then it should consume some of those offers before creating new order pairs.
Currently the bot doesn't seem to do anything. It also cancels all the orders created from fund1.
Perhaps you could advise me how to use the hedge command or point on things that I did wrong.
Thank you.

@codedot
Copy link
Owner

codedot commented May 18, 2017

Hello,

Thank you for your interest in this project. The documentation is indeed quite far from complete.

In configuration, the hedge command expects a hedge field which should be an array of strings of the following format:

chain : chain '/' side
      |           side 
      ;
side  : list
      | '*'
      ;
list  : list ',' ASSET
      |          ASSET
      ;

where * is equivalent to comma-separated list of all assets. Chains that consist of just one <side> are equivalent to <side>/<side>, e. g. * selects all possible combinations. The following example:

        "hedge": [
                "XRP,BTC/*"
        ],

makes hedge command to maintain offers for both XRP and BTC against all assets, including the XRP/BTC pair.

Another example is quite useful for selecting maximum number of pairs so that the bot would still tolerate delays and downtime before updating offers:

        "hedge": [
                "XRP/USD/BTC/EUR/XRP"
        ],

which is basically a shorthand for

        "hedge": [
                "XRP/USD",
                "USD/BTC",
                "BTC/EUR",
                "EUR/XRP"
        ],

but is easier to manipulate. If such a chain starts and ends with the same asset and all other assets are included exactly once, then whichever offers are consumed, change in geometric mean of balances is guaranteed to be positive (given that transaction fees are negligible).

Please note that hedge also removes offers whose estimated profit is below threshold calculated based on --delta if the corresponding pair is not specified in configuration.

Let me know if you have further questions.

Best regards,
Anton

@inmyth
Copy link
Author

inmyth commented May 18, 2017

Thank you for your reply. I see your explanation ties up with the hedge option mentioned in the documentation. However I'm unable to make it work. I'm using the example command for three assets like this :

xmm -c dummy.json hedge --hedge ["XRP/USD", "USD/BTC", "BTC/XRP"] fund1 -n 3 -y
or even
xmm -c dummy.json hedge --hedge {"hedge": ["XRP/USD/BTC/XRP"]} fund1 -n 3 -y

but it throws an error at Yarg module :

message: 'Unexpected token in JSON at position 1' }

Could you advise me on how to build such command ?

@codedot
Copy link
Owner

codedot commented May 18, 2017

While raw JSON is allowed as command line option like --hedge '["XRP/USD/BTC/XRP"]', options --assets, --wallets, and --hedge are intended to be specified in JSON configuration file instead (that is why they do not have single letter option aliases). It is also easier to tune --delta, -d, --maxfee, -m, and --cushion, -f in JSON configuration file rather than in command line.

Another parameter to play with is --count, -n (equals 1 by default). It should be equal to --offset, -o (equals 3 by default) when running the hedge command in a loop, e. g. -n 2 -o 2. Setting these two options to equal values ensures transactions to either succeed or permanently fail.

Feel free to ask further, because answering your questions has a side effect of writing down missing parts of documentation which can be later included into the project's wiki.

@inmyth
Copy link
Author

inmyth commented May 20, 2017

Thank you. It works now although I haven't tried the file method. I can see the bot consumes random offers I created. I am not a trader but by reading the documentation I think the market-making algorithm this bot does results in slow but safe gain. I haven't studied the code but I would like to add a custom strategy. I think for algorithm and other questions I may have, I will open another thread. Thank you again.

@inmyth inmyth closed this as completed May 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants