ApiRequest
Class that handles the API requests for the interface
Source code in make_us_rich/interface/api_request.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
number_of_available_models()
Number of available models endpoint.
Returns:
Type | Description |
---|---|
Dict
|
Dictionary containing the number of available models. |
Source code in make_us_rich/interface/api_request.py
45 46 47 48 49 50 51 52 53 54 |
|
prediction(currency, compare, token)
Predict endpoint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
currency |
str
|
Currency used in the model. |
required |
compare |
str
|
Compare used in the model. |
required |
token |
str
|
API token of the user. |
required |
Returns:
Type | Description |
---|---|
Dict
|
Dictionary containing the data and the prediction. |
Source code in make_us_rich/interface/api_request.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
Authentication
Source code in make_us_rich/interface/authentication.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
__init__(key='mur-key', cookie_ttl=10)
Initialize the Authentication class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cookie_ttl |
int
|
The time to live of the cookie. Default is 10. |
10
|
Returns:
Type | Description |
---|---|
Tuple[str, bool]
|
The token and the status of the authentication. |
Source code in make_us_rich/interface/authentication.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
_decode_token()
Decode the token.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The decoded token. |
Source code in make_us_rich/interface/authentication.py
62 63 64 65 66 67 68 69 70 71 |
|
_generate_cookie_token()
Generate a random string to be used as the token for authentication cookie.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The JWT token. |
Source code in make_us_rich/interface/authentication.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
_generate_expiration_date()
Generate the expiration date of the token.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The expiration date of the token. |
Source code in make_us_rich/interface/authentication.py
50 51 52 53 54 55 56 57 58 59 |
|
DatabaseHandler
This class handles the database connection and the queries.
Source code in make_us_rich/interface/database_handler.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
|
_add_member_role_to_user(username)
classmethod
Adds the role of the user to the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The username of the user. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, Any]
|
A dictionary with the success of the creation. |
Source code in make_us_rich/interface/database_handler.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
|
_check_user_role(username)
classmethod
Checks the role of the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The username of the user. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, str]
|
A dictionary with the role of the user. |
Source code in make_us_rich/interface/database_handler.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
|
_connect()
classmethod
Connects to the database.
Source code in make_us_rich/interface/database_handler.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
|
_disconnect()
classmethod
Closes the connection to the database.
Source code in make_us_rich/interface/database_handler.py
338 339 340 341 342 343 344 345 346 |
|
_generate_token_for_user(username)
classmethod
Generates a token for the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The username of the user. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
Dict[str, Any]
|
The token of the user. |
Source code in make_us_rich/interface/database_handler.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
_init_api_limit_for_user(username)
classmethod
Initializes the API limit for the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The username of the user. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, Any]
|
A dictionary with the success of the creation. |
Source code in make_us_rich/interface/database_handler.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
|
authentication(username, password)
classmethod
Checks if the user and password are correct
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The username of the user. |
required |
password |
str
|
The password of the user. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, bool]
|
A dictionary with the success of the authentication. |
Source code in make_us_rich/interface/database_handler.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
check_if_user_exist(username)
classmethod
Checks if a user exists in the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The username of the user. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, Any]
|
A dictionary with the success of the check. |
Source code in make_us_rich/interface/database_handler.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
create_user(username, password)
classmethod
Creates a new user in the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The username of the new user. |
required |
password |
str
|
The password of the new user. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, Any]
|
A dictionary with the success of the creation. |
Source code in make_us_rich/interface/database_handler.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
get_api_token(username)
classmethod
Gets the API token of a user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The username of the user. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, str]
|
A dictionary with the API token of the user. |
Source code in make_us_rich/interface/database_handler.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
get_user_api_consumption(username)
classmethod
Gets the API consumption of a user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The username of the user. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, Any]
|
A dictionary with the API consumption of the user. |
Source code in make_us_rich/interface/database_handler.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
increment_user_api_consumption(username)
classmethod
Increments the API consumption of a user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The username of the user. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, Any]
|
A dictionary with the success of the increment. |
Source code in make_us_rich/interface/database_handler.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
Plots
candlestick_plot(data, currency, compare, pred)
Create candlestick plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
pd.DataFrame
|
Dataframe containing the data to plot. |
required |
currency |
str
|
Currency to plot. |
required |
compare |
str
|
Currency to compare. |
required |
pred |
float
|
Prediction to plot. |
required |
Returns:
Type | Description |
---|---|
go.Figure
|
Plotly figure. |
Source code in make_us_rich/interface/plots.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
format_data(data)
Format data from API response before plotting.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Dict[str, Any]
|
Data from API response. |
required |
Returns:
Type | Description |
---|---|
Tuple[pd.DataFrame, float]
|
Dataframe containing the data to plot and the prediction. |
Source code in make_us_rich/interface/plots.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
scatter_plot(data, currency, compare, pred)
Create scatter plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
pd.DataFrame
|
Dataframe containing the data to plot. |
required |
currency |
str
|
Currency to plot. |
required |
compare |
str
|
Currency to compare. |
required |
pred |
float
|
Prediction to plot. |
required |
Returns:
Type | Description |
---|---|
go.Figure
|
Plotly figure. |
Source code in make_us_rich/interface/plots.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|