-
Notifications
You must be signed in to change notification settings - Fork 26
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
Improvement : Auto managing width with volatility #46
Comments
More development on the idea. The difficulty is to guess what is maximum price investors are willing to pay me my BTC and what is the minimum price they are willing to sell me those their BTC at any given time. The simplest strategy is to always be on top of the market at any given point, doing so you're going to make a lot of trades but with a very small share of profit. Also, another bot on the market might compete with you and that will drastically reduce profit for the two bots. In order to not fall into excesses we have the 'width' parameters that prevent from buying and selling with a too small profit. However the market change quickly and those settings not as they have to be changed manually. In time of big price movement you can expect more from the market as the price is evolving a lot. When it's calm you might want to take advantage of very small profits rather than nothing. In the current state of tribeca the ewma security setting can help, as it will protect from selling too low or buying too high during a price swing. The proposed solution here is to have an evolutionary width based on what the market is actually willing to spend for that. Or at least trying to guess it. There is two ways to implement this feature: Ie: If the SMA 20 = 1200 and Sdev = 2 However this can suffer a bit from the same drawbacks of the ewma security as it is based on a moving average. Also this would not give us an interesting information during quick price move. If we take the same example, once the price reaches 1203 the security would still have 1202 as a target. The second and in my opinion best solution is to report the Sdev from the Fair value calculated from tribeca. |
well lets try to first dispay the SMA(20) value in the UI and later we take it in consideration as a safety, hope you agree with the plan' this could be en/disabled with a simple checkbox like ewma i think i just need to find out the math behind it xD can you put an example of lets saaay, what is the ¿3? values for SMA(20) and in what times they are recorded if we have a timeline of 1h and every minute the price goes up +1 starting by 1200? many thanks'¡ (is just to make sure that im not messing it) |
what i dont understand is:
the first two lines suggest to use pDiv as a width? |
I'm sorry for the confusion with pdiv, I wanted to write Sdev for standard deviation. I corrected it in the post :) |
Concerning the first comment, I'll try to explain better the maths behind the idea. Here we are trying to define how much the price usually diverge from the mean. You have two bouquets of flowers. So you have a total of 210 petals, so an average of 10.5 petals per rose. Now in the second one, you have still 20 roses but in this case, 10 have 10 petals and 10 have 11 petals. The standard deviation (or Sdev) determines by how many petals on average a random flower diverges from the mean (or your 10.5 petals). To calculate the standard deviation we need:
In the first bouquet your standard deviation is equal to: Step 2: get the mean of the deviation: Now for the Second bouquet: Now you know that if you pick a random flower from bouquet 1 it will be on average 5.788 petals away from the mean and if you pick from bouquet 2 will be on average 0.5 petals away from the mean. Let's go back to our topic now and change the flowers for minutes and the petals with a price and you can see how it is useful for Tribeca. If you're in a situation of bouquet 1: The prices are quite random and move a lot from one minute to another by calculating the standard deviation you know that you should be always 5.78 away from FV (your width) because it's on average how much the price will diverge each time. If the price is very calm and don't move a lot like in bouquet number 2, you should only be 0.5 away from fair value because that's how much the market is diverging. I hope it's more clear for you know what I'm trying to predict with that. The SMA20 is just a way to have an approximation of how much the price is diverging from one minute to another. Of course, it needs some tweaking and to try it against a market to be most efficient but the logic is there. Trying to guess how much the price will move from one minute to another so Tribeca can adjust it width to be not too low or too high! 🤓 |
To support commits at ctubio/tribeca, you can buy-me-a-drink with a small git tip at: 1GitTipgxvKB3zjCLXRcSgDhC9pivkpc7u I promise to drink chocolate milk in the development of the next commit. To request new features or in case this commit breaks something for you, please create a new github issue with all possible details, but never share your API Keys! Signed-off-by: Carles Tubio <ctubio@users.noreply.github.com>
Lastly, I want to add that it helps with the setting of the bot. If I have a pretty good idea of what's the optimum width for the bitcoin market, I'm quite lost when I have to enter settings for ETH/BTC or LTC/USD! This system solves the issue as you just need to enter minimums and tribeca will calculate the "optimum" width according to the standard deviation :) |
Hello and thank you for the work !!!! I thought you would do that next week! 😃 I'm' going to review that and try that. I'm also going to try different "ways" of using stdev and come back to you! :DD |
i may be wrong cos i have zero math knowledge, but i can see in my Total values a clearly an amazing positive benefit after resolving this issue (because the app doesnt drains so easilly now, before fast moving markets were eating the funds xD; and if it drains, it does in much less frequency and with higher widths :D), can you please consider to answer if protecting the widh with STDEV is matematically compatible with protecting the widh also with EWMA? or is best to just have enabled only one of them? (from the mathematical point of view, not from the practical xD if you know what i mean.. :P [i see no problem in having both enabled but asking to the experts never hurts'¡]) thanks'¡!¡ (if the answer is yes, then i will leave both enabled by default for everybody) |
🌻 @ekienmeier @beegmon check this out! Camille is a genius xDD |
YES!!!! I am pulling this down now to give it a run...but looks very promising! Awesome work all! |
Yes! It's very cool! I'm trying to play with it for a bit with different settings, I'll send you a feedback about it tonight: ) |
Hi Carles and everyone,
Couldn't sleep but just got what I believe might be a simple and great idea!
This would act like the EWMA safety but in a more clever way imho.
The idea is to use standard deviation of the price as a safety for defining the width.
20 period is the most commonly used value (BB bands etc) so it might be good just to start with that and maybe change it later.
The standard deviation is not very hard to calculate and is a very useful tool to measure how much a price moves from its mean.
We need to calculate the SMA(20) = the average of the price on close on a 20mn period
Then substrat this mean to the 20 composing the moving average and square them.
Lastly to find the average of this number and find the square root of it.
You can see at the bottom of thus chart what the value would be for the above period. It has the ability to move quickly from a period with big change to very calm time.
At the end we get, like for the ewma protection a minimum value that should protect from bad trade even if the width is set to be smaller.
Lastly it can be used for defining the bullets of AK47. For instance with 2 bullets the second one could be at Standard deviation * 2 from fair value!
The text was updated successfully, but these errors were encountered: