ctubio / tribeca

Self-hosted crypto trading bot (automated high frequency market making) in node.js, angular, typescript and c++
https://127.0.0.1:3000
Other
95 stars 26 forks source link

Display evolution of Profit/Loss of Total values #55

Closed beegmon closed 7 years ago

beegmon commented 7 years ago

Hello,

I hopefully have two quick questions.

1) Is there an easy/quick way I can tell what my profit/loss is over time in the UI?

I am not 100% sure what "Value:" represents or how that tracks over the course of the day as price changes. Right now I am just noting the "Value:" in relation to the market price every 30 min and calculating the difference in profit/loss from there. However, It would be nice to see the profit/loss graphed, or maybe just indicated in in the GUI somewhere based on something like 5m/15m/30m/60m/ or 1d intervals. It might be there in the UI already as well and I just missing it.

2) I keep getting pushed into USD overnight. I am pretty sure it due to the lack of volatility in the market as it has tendency to "stair step" up in price for several hours during the night. This lack of volatility and one-way movement with long periods of sideways/flat price action results in sells only, with no buys (since the price doesn't move down, save for a cent or so, within these time periods). The result of course is that I wake up in the morning and find my self mostly in USD and sold out of BTC.

I have been trying different trds/sec settings to restrict the amount of one sided action Tribeca takes by extending the timeout period or reducing the trds. But, that also hurts when there is volatility at night; which does happen occasionally and it has been profitable to take advantage of when it does occur.

Is APR the answer, and if so how un-safe is it really?

Thanks for any input you can provide.

Camille92 commented 7 years ago

Hello,

I can't really help for the first point, but maybe for the second. I track myself the results on a excel file, where I note the evolution of value in comparison to the evolution of the bitcoin price.

May I ask you how much you trade with, I never had the issue. What's your setting concerning tbp ? Do you use the manual of the Ewma basic option ?

beegmon commented 7 years ago

My bid/ask sizes are .01 (just really testing right now and trying to get a feel for how things work)

I started with 1 btc and 100 USD in terms of holdings last night.

The number of bullets is a value I am still getting a feel for but usually run between 5 and 13. Last night I was running 13.

I use the EWMA to calculate the TBP so it ranges. Pdiv is set to 0.8 for right now, which is probably why I likely got pushed out into USD overnight.

I am not using EWMA 100 minute for controlling the order flow. Maybe that would help as well?

I think what basically happened is two fold.

My pDIV is set too high allowing to much drawdown on the BTC holdings. When combined with the fact that no buy orders to offset the sells that were being filled for several hours, the BTC side slowly drained to near 0.

Setting PDiv seems to be hard because EWMA TBP changes a lot and may swing pretty drastically making a static PDiv value correct (or balanced) only a small part of the time. I have yet to come up with a good formula or way to set PDiv based on other factors, like bid/ask size, amount of filled orders on the bid/ask side, etc. I could change it to percentage, but that also changes bid/ask and other parameters to percentage and I get confused easily :). (At least at the moment as I am still learning)

I wonder what it would be like if you could set PDiv separately for up or down situations. Say for example, if TBP is currently set to .589 by EWMA, you could allow for 1.2 Above that and .2 below it.

Secondly, the number of bullets accelerated things and perhaps I should be using the EWMA 100 line to control order flow. I don't really understand how bullets or the bid/ask size scales in comparison to the amount of holdings one has, and the average order fill time. Like for example, it's pretty clear that it wouldn't be wise to set bid/ask size to .5 when only 1 BTC and 100 USD are available for trading. There isn't enough room to move around, especially is the market is moving quickly, or very slowly (sideways/flat/one-sided).

I figured .01 BTC given the holdings above would scale reasonably well with 13 bullets, but it appears to much sell activity severely impacted the overall balance of things, and left me lop-sided, with my PDiv set too high.

ctubio commented 7 years ago

Hello'¡ about the first point, i agree, would be nice to have somewhere in the UI the amount traded and the difference of the values during various periods of time; I will try to come up with a place/form to display it (and a nice way to collect this values without impact the main propose of the application xD)

many thanks'¡

Camille92 commented 7 years ago

Hey so after thinking about that:

Don't forget that bullets is still a work in progress and is not a smooth as it can be.

Also you get drained because more people buy at market price than people sell at market price.

Indeed having a tighter pdiv should help. TBP is set to be full btc if ewma 100 is more than 0.2% higher than ewma 200.

It might be a little bit tight I will try with different settings and come back with something.

If you run the manual version you can easily change that for yourself and tell us what works best for you.

ctubio commented 7 years ago

:panda_face: maaaaaybe having a bidSize higher than the askSize helps too to avoid the drain

beegmon commented 7 years ago

I moved to manual for now and adjusted the TBP to 1 and Pdiv to .2 so things are tighter at this point. At least with the manual mode things are static on both sides of the equation.

Yes, making bid size higher than ask size would help offset a short term ask order run , but only if there is eventually enough bid order fills to offset things, and in a relatively quick timeframe.

Last night was quite strange in terms of market activity. There were long periods of flat to no change in price, with larger jumps to a higher price, followed by another long run of no price change, followed by jump in price. There wasn't really ever a period where the market took a turn downward that would has exposed my bid orders to begin with. It only went in 1 direction (up), and it was just enough to expose my asks. So there was no opportunity to offset the ask fills with more inventory on the bid side. A tighter PDiv would have at least ceased asks until a bid order or two was filled, so I have that covered now with my manual settings.

There is also more potential risk, or I would imagine there is, from buying in larger increments and selling in smaller increments. Especially if you can't clear the inventory fast enough with smaller increments before the price turns on you. However, this may not be too much of a problem if market orders typically skew toward asks anyways, and BTC is always going to the moon right? :)

I thought about changing my widths to something tighter around the average spread I was seeing at the time as well, but I was leery of doing that just incase something broke loose and lots of volatility occurred, as that could also spell disaster with not being able to move quickly enough (at least per my experiments a few weeks ago).

Thanks again for all your input. Hopefully things will become easier for me to intuit as I poke and prod at Tribeca, while also trying to understand the risk/reward of moving around variable values.

ctubio commented 7 years ago

:sunflower: another anti-drain mode is pingAt set only to BidSide

beegmon commented 7 years ago

So the manual TBP and Pdiv worked out great for me last night! I wasn't pushed out of BTC and was able to find good PDiv, width, size, and bullet values that kept me in the market on both sides most of the time, without too much drainage. This is with the same type of market activity that I saw the night previous (flat, little value change, nearly always up in price), so thanks again for all your help and input!

I have some thoughts around a potential behavior change when breaching TBP +/- Pdiv thresholds but will put those thoughts in a separate issue.

ctubio commented 7 years ago

oh boy, i like good news, and also new features'¡! many thanks for your time sharing''

beegmon commented 7 years ago

@Camille92 In regards to your profit/loss tracking on the excel spread sheet. Do you expect to see a gain of both the BTC and USD value when BTC price increases, or are they asymmetric in some ways?

I can't seem to find a good method to tie the value (in BTC or USD) as reported in the UI, to the BTC price at a particular time and track that (still).

Every Kdiff report in the trade window I have seen thus far shows green text and are a positive USD value, but I am not sure if this means anything good and I can't escape the feeling that while Kdiff reports are always a positive value I am still trickling out money somewhere and actually loosing vs winning most of the time.

On the graphs my buy line is nearly always below my sell line by a good distance and fair value runs generally in the middle between the two (unless there is a quick down or up turn in the price). That tells me I am on average buying lower than I am selling and at a discount and premium in regards to fair price, but an actual number would be nice to get a more definitive hold on changes (hopefully positive) over time.

This will likely come with the improvement/feature noted earlier, I would just like to get a handle on it while that awesomeness eventually gets merged.

Another thought would also be to also graph the actual Market Price in addition to the what is already being Graphed. This is basically just graphing the trades that have come in from the exchange, which is already present in the UI if you enable that window. Maybe update the market Price Line on the graph based on the last trade Price and the UI refresh time?

ctubio commented 7 years ago

i may say that evey ping cleaned can be considered a bad trade

aaand a K (or pong) trade is positive only at the time it was done, but maybe related to the current market move, it is by now really worthless and would be best option to just keep the coins instead (selling too soon while price goes up even if you bought cheaper, may let you win a few, but will not let you win all you could if 100% of your funds were in 1 side only, [pongs are not a loose, but a partial win xD])

ctubio commented 7 years ago

btw a graph of market data was planned, but found it to be very heavy, so ended up conforming myself just with the Market link under the wallet :P (also the oficial graphs of the exchanges are quite better than anything i can do (cos the main function of the app is to trade not to record and display stats)

the current graphs are starting to be heavy, and i have pending to reduce a bit more the data in them, or something, to recover the <30Mb UI

Camille92 commented 7 years ago

@beegmon Hello Beegmon, I'm going to try to be as precise as possible but for that technical matter is a bit complicated.

As explained there https://github.com/ctubio/tribeca/issues/51 I am able to get more btc and more fiat together most of the time. However, when btc makes 8% in a day like today. There is a very low probability of being over buy&hold. In this situation, I am happy when I make a 5 or 6%.

capture d ecran 2017-05-04 a 10 57 53 Here is a screenshot of my results from 23/04 to 03/05. As you can see I am above B&H most of the time but not always.

Explanation: Day € % : How many % of € I have more from yesterday. Day B % : How many % of Btc I have more from yesterday. Performance over buy and hold. The bitcoin price And the evolution of the bitcoin price since yesterday.

The issue you're encountering is that tribeca doesn't take in its calculation the btc you have 'sleeping' in your wallet.

For instance let's say you have half btc half eur. If the price moves up by 1%, you will make only half of what bitcoin does. To make a profit on both eur and btc you have to be sure that the market making activity of tribeca will get you another 0.5% a day.

The part in the middle only takes into account the market-making part you have to be careful with your setting to be sure to have a tight pdiv and take as much as you can making the market.

beegmon commented 7 years ago

Ok, after some coffee and reading over this a few times I think it finally made it through my thick skull.

You are saying that everyday, hopefully at same time everyday, you do the following:

Take the Sum Total of Currency (USD/EUR/GBP) both sleeping and what is currently in open orders from tribeca.

Take the Sum Total of BTC both sleeping and what is currently in open orders from tribeca.

You also take the market price of BTC at that time from the exchange tribeca is trading in.

Then in your spreadsheet you log the amount of Currency, the Amount of BTC, and the Bitcoin Market Price.

You compare the amount of Currency and BTC you have now to the day before to give you an amount the represents a gain or loss over the last 24 hrs.

You also compare the BTC price from now to the day before to give you to give you an amount the represents the a gain or loss in BTC's price over that last 24 hours.

The gain or loss from trading vs the gain or loss in the BTC price over 24 hours shows the difference between trading and Buy and Hold.

I to am completely ok leaving some gains on the table when compared to Buy and Hold. I try to target 4 - 6 % in general, as that allows for some wiggle room around market moves as well. Also, with the good parameters tribeca does seem to help offset market downturns a bit which is nice.

I purposefully set a tight Pdiv in order to hold more and trade with just a little BTC. This somewhat hinders tribeca's ability to buffer market downturns as well though.

I do like the idea you proposed in your safeties issue. By allowing tribeca to take emergency action when the market is dumping rapidly, by doing a market sell of BTC, was something I was playing with in code a few weeks back, but I just haven't found the time to actually work on it. It made sense to me though, and would allow for tight Pdivs with some safety net in case things go really haywire.

Thanks for the clarity!

Camille92 commented 7 years ago

Quite that but not exactly.

I take all the funds I have converted to btc and fiat at the same time. So if I have 0.5 btc and $725 I would write : 1450 in fiat and 1btc.

But yes the rest is true, i calculate how much I made trading compared to how much I would have had by doing buy and hold. Because if btc is making 2% in the period and I'm making only 1% it's bad and I should review my settings.

Are you seriously making 4 - 6% a day with tribeca (outside of this crazy rising last few days)?

Yes I play with tight Pdiv as well. The hardest part is to define how tight you should be comparison to the size of the orders.

Thanks for the safeties, yes I believe it's good.

I'm thinking as well about proposing new strategies instead of ewmabasic.

beegmon commented 7 years ago

I should have made that clearer. That is 4 - 6% per day across my entire crypto portfolio, though these past couple of weeks have been much better than that thanks to all the crazy going around.

I would be over the moon if tribeca was giving me that much alone, but after reviewing all the trades I have made so far with it, it seems that the suspicion I had about loosing more than winning was true. In fact, 90% of the time I was loosing. Oh well, back to the parameters drawing board.

In general, as you have mentioned before, I think tribeca on a good day with perfect parameters might net about 80% of what buy and hold might do in that given day (excluding the crazy times we are in now).

It probably averages out to more like 60 - 70% but I agree that if tribeca is returning 50% or less of what buy and hold did in a day then there is a problem with the parameters.

On the whole though, as you stated in the other issue, it appears that tribeca makes a good trade off between what buy and hold might give you and buffering against market dips if you have good parameters. In general, I see about 20% - 38% of the loss, when compared to buy and hold, when in a down market (again in normal times, not the crazy ones we see currently). At least in my backtests with older data.

Anyways, back to figuring out parameters.

ctubio commented 7 years ago

about point 1, there is a lovely idea for new charts at https://github.com/ctubio/tribeca/issues/62 so we can display without record the data :D

but but point 1 also talks about display of evolution of the personal profit/loss (that will not be provided by #62 for sure cos is only about market data), so keeping this issue open'¡! (let me mod the title to only this point 1, ty').

ctubio commented 7 years ago

:bulb: point 1 can be displayed in a popover similat to Sumbit Order form but floating over Total Values

beegmon commented 7 years ago

It's awesome! Thanks for all the work!