widichandra commited on
Commit
49beef8
·
verified ·
1 Parent(s): 1c47213

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +78 -30
src/streamlit_app.py CHANGED
@@ -1,40 +1,88 @@
1
- import altair as alt
2
- import numpy as np
3
- import pandas as pd
4
  import streamlit as st
 
 
 
 
5
 
6
- """
7
- # Welcome to Streamlit!
 
 
 
 
8
 
9
- Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
10
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
11
- forums](https://discuss.streamlit.io).
12
 
13
- In the meantime, below is an example of what you can do with just a few lines of code:
14
- """
 
 
 
15
 
16
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
17
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
 
 
 
 
 
 
 
18
 
19
- indices = np.linspace(0, 1, num_points)
20
- theta = 2 * np.pi * num_turns * indices
21
- radius = indices
 
 
 
 
 
 
22
 
23
- x = radius * np.cos(theta)
24
- y = radius * np.sin(theta)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
- df = pd.DataFrame({
27
- "x": x,
28
- "y": y,
29
- "idx": indices,
30
- "rand": np.random.randn(num_points),
 
 
 
 
 
 
31
  })
32
 
33
- st.altair_chart(alt.Chart(df, height=700, width=700)
34
- .mark_point(filled=True)
35
- .encode(
36
- x=alt.X("x", axis=None),
37
- y=alt.Y("y", axis=None),
38
- color=alt.Color("idx", legend=None, scale=alt.Scale()),
39
- size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
40
- ))
 
 
 
 
 
 
 
 
 
1
+
 
 
2
  import streamlit as st
3
+ import random
4
+ import pandas as pd
5
+
6
+ st.title("Stake Dice Strategy Simulator: ZachXBT vs ZachXBT+")
7
 
8
+ # Sidebar inputs
9
+ st.sidebar.header("Simulation Settings")
10
+ initial_balance = st.sidebar.number_input("Starting Balance (USD)", value=200.0, step=10.0)
11
+ base_bet = st.sidebar.number_input("Base Bet (USD)", value=0.0001, step=0.0001, format="%.4f")
12
+ num_rounds = st.sidebar.number_input("Number of Bets", value=5000, step=1000)
13
+ seed = st.sidebar.number_input("Random Seed (optional)", value=42)
14
 
15
+ random.seed(seed)
 
 
16
 
17
+ # Constants
18
+ multiplier_2_02 = 49.5
19
+ multiplier_5_00 = 19.0
20
+ win_chance_2_02 = 0.0202
21
+ win_chance_5_00 = 0.05
22
 
23
+ def simulate(improved=False):
24
+ balance = initial_balance
25
+ bet = base_bet
26
+ win_chance = win_chance_2_02
27
+ current_multiplier = multiplier_2_02
28
+ results = []
29
+ losses = 0
30
+ profit = 0.0
31
+ win_streak = 0
32
 
33
+ for _ in range(num_rounds):
34
+ roll = random.random()
35
+ if roll < win_chance:
36
+ win = bet * current_multiplier
37
+ balance += win - bet
38
+ profit += win - bet
39
+ bet = base_bet
40
+ win_streak += 1
41
+ losses = 0
42
 
43
+ if improved:
44
+ if profit > 0.05:
45
+ bet = max(base_bet, bet * 0.5)
46
+ if profit < -0.10:
47
+ win_chance = win_chance_5_00
48
+ current_multiplier = multiplier_5_00
49
+ else:
50
+ win_chance = win_chance_2_02
51
+ current_multiplier = multiplier_2_02
52
+ else:
53
+ balance -= bet
54
+ profit -= bet
55
+ losses += 1
56
+ win_streak = 0
57
+ if losses % 10 == 0:
58
+ bet *= 2
59
 
60
+ results.append(balance)
61
+ return results
62
+
63
+ # Run simulations
64
+ original = simulate(improved=False)
65
+ improved = simulate(improved=True)
66
+
67
+ # Plotting
68
+ st.line_chart({
69
+ "Original ZachXBT": original,
70
+ "Improved ZachXBT+": improved
71
  })
72
 
73
+ # Summary
74
+ def summarize(data, label):
75
+ return {
76
+ "Strategy": label,
77
+ "Final Balance": round(data[-1], 2),
78
+ "Max Balance": round(max(data), 2),
79
+ "Min Balance": round(min(data), 2),
80
+ "Profit": round(data[-1] - initial_balance, 2),
81
+ "Max Drawdown": round(max(data) - min(data), 2),
82
+ }
83
+
84
+ st.subheader("Simulation Summary")
85
+ st.write(pd.DataFrame([
86
+ summarize(original, "Original ZachXBT"),
87
+ summarize(improved, "Improved ZachXBT+")
88
+ ]))