GithubHelp home page GithubHelp logo

Comments (10)

Rakambda avatar Rakambda commented on August 26, 2024 1

So what I got for now on my branch after letting it run over the night.

A prediction win will show that we got back 1521 points, with a difference of 275 (won - placed)

02/02 10:29:22 - πŸ“Š  EventPrediction: xxx? - Result: WIN, Points won: 1k, Diff: 383   

Though I can't find a good name for the diff πŸ˜† .

A prediction that is a loss is basically the same except that the points won are... well... negative

02/02 10:34:45 - πŸ“Š  EventPrediction: xxx? - Result: LOSE, Points won: 0, Diff: -1k

When a refund happens this is where it's a bit shady:

02/02/21 01:04:48 - INFO - TwitchChannelPointsMiner.classes.WebSocketsPool - [on_message]: πŸš€  +216 β†’ itsspoit (2.167 points) - Reason: REFUND.
02/02/21 01:04:48 - INFO - TwitchChannelPointsMiner.classes.WebSocketsPool - [on_message]: πŸ“Š  EventPrediction: Will they win? - Result: REFUND, Points won: 0, Diff: -216

Here the 2 events are separated. The 216 is a refund by itself, while the prediction just showed that we lost whatever we placed.
As you suggested we could somehow merge the 2 messages together and interpret it as being the refund of the bet. Now I don't really know how to do that. The on_message method seem to take messages one by one, so we can't really do any comparison between messages.

As for the summary part this looks like it for now.
The easiest is when there's no refund:

02/02/21 08:38:18 - INFO - TwitchChannelPointsMiner.TwitchChannelPointsMiner - [__print_report]: πŸ€–  Streamer(username=kinggeorge, channel_id=117379932, channel_points=12.471), Total Points Gained (after farming - before farming): 709
02/02/21 08:38:18 - INFO - TwitchChannelPointsMiner.TwitchChannelPointsMiner - [__print_report]: πŸ’°  WATCH(42 times, 420 gained), WATCH_STREAK(1 times, 450 gained), CLAIM(14 times, 700 gained), PREDICTION(7 times, -861 gained)

If we sum up everything we get back to 709 πŸ˜ƒ

With a refund:

02/02/21 08:38:18 - INFO - TwitchChannelPointsMiner.TwitchChannelPointsMiner - [__print_report]: πŸ€–  Streamer(username=itsspoit, channel_id=144516280, channel_points=2.187), Total Points Gained (after farming - before farming): 121
02/02/21 08:38:18 - INFO - TwitchChannelPointsMiner.TwitchChannelPointsMiner - [__print_report]: πŸ’°  WATCH(2 times, 20 gained), CLAIM(1 times, 50 gained), PREDICTION(3 times, -165 gained), REFUND(1 times, 216 gained)

Again summing up everything we get the right sum. Just that the refund is in a separate category.
Personally I think it's still quite understandable that way. But of course if we can do the merging of the refund messages then it'd be even better.

Also the number of times a prediction happens is different, and I think the reason for that is that now a refund will be counted as a prediction where we lost x points. So to me it makes sense to keep it that way.

from twitch-channel-points-miner-v2.

Tkd-Alex avatar Tkd-Alex commented on August 26, 2024

I'm totally agreed with you, I'll as soon as possible.
Or if you want to submit a pull request, you are welcome!
The first idea It's fine but for have a perfect report we should also remove the REFUND sections and simply write:
PREDICTION(10 times, (won - placed + refund) gained) and the times should be equal to prediction-made.

Most of the time I've (after farming - before farming) < 0, but I don't know why or where I have lost my points πŸ˜†

from twitch-channel-points-miner-v2.

Rakambda avatar Rakambda commented on August 26, 2024

Merging REFUND completely with the predictions can lead to false results (maybe). The sources of this can be multiple:

  • A prediction has been cancelled
  • You bought something with the channel points and it has been refunded to you

I don't really know the "api" or the data you get from twitch, but if the refund takes into account both cases then we'll have to be careful.
Or maybe the coded REFUND only applies to prediction refunds?

from twitch-channel-points-miner-v2.

Rakambda avatar Rakambda commented on August 26, 2024

As an info I checked the REFUND and it is also fired when something bought with channel points is refunded.

So maybe it is a better idea to keep it separated for now or find a way to distinguish it from refunds from predictions.

from twitch-channel-points-miner-v2.

Tkd-Alex avatar Tkd-Alex commented on August 26, 2024

I need to check in my logs if with the REFUND status we have also the event_id.
Maybe this can help us to understand if the REFUND It's related to a prediction or not.

We can also check if we have a refund after the event cancelled.
For example If the event 0000 was deleted and after that we have a REFUND of x channel points - the same points place on the event 0000 - we know that the two event are correlated.

from twitch-channel-points-miner-v2.

Rakambda avatar Rakambda commented on August 26, 2024

I don't think REFUND is linked to predictions as it's in the community-points-user-v1 part and basically lists the reasons why you get points.

Now, we can get the info that it is a refund from a prediction in the predictions-user-v1 part.
For now I just try things on a forked branch, logging what seems interesting and will see if anything comes out of it.

What is a bit of a burden is that the update of the streamer history is always done in the community-points-user-v1 part. I wonder if it wouldn't be easier to also copy that part into the predictions so that we have better control of it. Of course we'd have to not update the streamer history if the type of update is prediction related. Though in the predictions-user-v1 we'd have better control of the update and can update the history with always the PREDICTION type (so it mixes prediction results/refunds) and value:

  • If the prediction is a WIN/LOSE then the points won are won - placed.
  • If a prediction is cancelled, then the points won are 0, or we could even not count that bet at all.

Now with that comes another problem (which is essentially the same as before), how do we filter out the predictions refunds from community-points-user-v1.

from twitch-channel-points-miner-v2.

Tkd-Alex avatar Tkd-Alex commented on August 26, 2024

Awesome! Thanks for your contribution πŸ₯³
Here all the messages πŸ˜„
Message 0

{
   "type":"MESSAGE",
   "data":{
      "topic":"community-points-user-v1.0000000",
      "message":{
         "type":"points-spent",
         "data":{
            "timestamp":"2021-01-22T14:01:11.954376605Z",
            "balance":{
               "user_id":"0000000",
               "channel_id":"*******",
               "balance":60158
            }
         }
      }
   }
}

Message 1

{
   "type":"MESSAGE",
   "data":{
      "topic":"community-points-user-v1.0000000",
      "message":{
         "type":"points-earned",
         "data":{
            "timestamp":"2021-01-22T13:59:52.917057178Z",
            "channel_id":"*******",
            "point_gain":{
               "user_id":"0000000",
               "channel_id":"*******",
               "total_points":4522,
               "baseline_points":4522,
               "reason_code":"REFUND",
               "multipliers":[
                  
               ]
            },
            "balance":{
               "user_id":"0000000",
               "channel_id":"*******",
               "balance":64686
            }
         }
      }
   }
}

Message 2

{
   "type":"MESSAGE",
   "data":{
      "topic":"predictions-user-v1.0000000",
      "message":{
         "type":"prediction-result",
         "data":{
            "timestamp":"2021-01-22T13:59:52.922967445Z",
            "prediction":{
               "id":"a1d58cc540ff732a7442626676b609d93c8ff89d6092e756c817708588dc7697",
               "event_id":"dd6066bd-8ace-4cae-b3d1-e136c5a69706",
               "outcome_id":"b64ed86c-ab1a-44fc-b6d8-f59a39637087",
               "channel_id":"*******",
               "points":4522,
               "predicted_at":"2021-01-22T13:49:55.146374343Z",
               "updated_at":"2021-01-22T13:59:52.919010766Z",
               "user_id":"0000000",
               "result":{
                  "type":"REFUND",
                  "points_won":null,
                  "is_acknowledged":false
               },
               "user_display_name":null
            }
         }
      }
   }
}

This is should be the condition for link the two events

message1.type == "points-earned"  
and message2.type == "prediction-result" 
and message1.data.point_gain.reason_code == "REFUND" 
and message2.prediction.result.type == "REFUND" 
and message2.prediction.points == message1.data.point_gain.total_points

from twitch-channel-points-miner-v2.

Tkd-Alex avatar Tkd-Alex commented on August 26, 2024

Though I can't find a good name for the diff πŸ˜† .

Maybe gained ?

A prediction that is a loss is basically the same except that the points won are... well... negative

I'm currently working a little f/e with apexcharts.js and I'm currently recording all the community-points-user-v1.
I've the idea also to write points annotation when a Bet It's WON or LOSE.
Here an example (please don't look at the red squared -- / -0, It's an error).

image

But the idea It's to use:

03/02/21 02:47:28 - πŸ“Š  EventPrediction(event_id=xxxxxx, title=ONE) - Result: WIN, Points won: +2.32k
03/02/21 11:50:36 - πŸ“Š  EventPrediction(event_id=xxxxxx, title=TWO) - Result: LOSE, Points won: -2k

if message.type == "prediction-result":
event_result = message.data["prediction"]["result"]
bet = ws.events_predictions[event_id].bet
poinst_placed = bet.decision["amount"]
points_prefix = (
"+" if event_result["points_won"] else "-"
)
points_won = (
event_result["points_won"]
if event_result["points_won"]
else poinst_placed
)
logger.info(
f"{ws.events_predictions[event_id]} - Result: {event_result['type']}, Points won: {points_prefix}{_millify(points_won)}",
extra={"emoji": ":bar_chart:"},
)
ws.events_predictions[event_id].final_result = {
"type": event_result["type"],
"won": f"{points_prefix}{_millify(points_won)}",
}
# ws.events_predictions[event_id].streamer
ws.streamers[streamer_index].persistent_points(
event_result["type"],
f"{points_prefix}{points_won} - {event_result['type']}: {ws.events_predictions[event_id].title}",
)

Maybe we don't really need the diff and we can use only Points won: +/-
The problem It's also with this I've a - on points won in REFUND case

03/02/21 00:06:16 - πŸ“Š  EventPrediction(event_id=c3a3acf9-5575-4b76-b1b6-c2686f776b43, title=vincerΓ  homyatol?) - Result: REFUND, Points won: --2k

But we can easily handle this by change the condition:

points_prefix = (
    "+" if event_result["points_won"] or event_result['type'] == "REFUND" else "-"
)

About the main topic of this issue:
We have always a message from community-points-user-v1 -> points-earned -> REFUND and after this a message from predictions-user-v1 -> prediction-result -> REFUND

We can do the following:

ON (community-points-user-v1 -> points-earned -> REFUND):
    ws.streamers[streamer_index].update_history(reason_code, earned)
    # So in this case nothing change.

ON(predictions-user-v1 -> prediction-result -> REFUND):
    ws.streamers[streamer_index].history["REFUND"]["counter"] -= 1
    ws.streamers[streamer_index].history["REFUND"]["amount"] -= bet-placed

from twitch-channel-points-miner-v2.

Rakambda avatar Rakambda commented on August 26, 2024

Yeah I saw a bit what you did in the other branch. It is interesting and of course can be used that way along with the last block in your comment above.

So to sum it up, assuming the analytics branch is merged first, what this issue would mean is:

  • Move the update of the history for the predictions from the community-points to the prediction-user (this allow us to perform the earned-placed or 0 for refund)
  • When a refund of a prediction is made, subtract a refund from the history and count it as a bet with 0 of reward.

I'll do the changes that way in my branch so I can let it run a bit and see if it leads to problems white the analytics branch moves forward.

from twitch-channel-points-miner-v2.

Tkd-Alex avatar Tkd-Alex commented on August 26, 2024

Yup. Work on your branch, and I'll wait for the PR πŸ₯³
I think the analytics branch will be merged in the future, we have currently issues more important

from twitch-channel-points-miner-v2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.