-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Controlling deposit/withdraw policy by the admin
So the users won't troll
- Loading branch information
1 parent
3413228
commit da6a6d2
Showing
7 changed files
with
88 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ SQLALCHEMY_DB_SQLITE3_PATH="sqlite:///kcx.db" | |
TEST_ACCOUNT_ID="test" | ||
TEST_ACCOUNT_PW="test" | ||
TEST_ACCOUNT_EMAIL="[email protected]" | ||
STARTING_BALANCE_IN_KRW=20000000000 # 20 billion KRW | ||
|
||
# An example SECRET KEY for JWT. Change this to a random in production! | ||
JWT_SECRET_KEY="KCXU$3R$3CR3T4JWT_" | ||
|
@@ -12,4 +13,9 @@ JWT_TOKEN_EXPIRES_MINUTES=360 # 6 hours | |
REDIS_PORT=6379 | ||
REDIS_DB=0 | ||
REDIS_UDPATE_INTERVAL_IN_SECONDS=1 | ||
USER_RANKING_UPDATE_INTERVAL_IN_SECONDS=10 | ||
USER_RANKING_UPDATE_INTERVAL_IN_SECONDS=10 | ||
|
||
# Service configuration | ||
# - Money balance (Disable(false) this if you want to use a fixed starting balance for all users) | ||
ALLOW_ARBITRARY_BALANCE_DEPOSIT=false | ||
ALLOW_ARBITRARY_BALANCE_WITHDRAW=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,63 @@ | ||
# KCX | ||
> **K**nightchaser's **C**ryptocurrency e**X**change | ||
## TECH STACK | ||
- **Service buildup** | ||
|
||
 | ||
 | ||
 | ||
 | ||
 | ||
 | ||
 | ||
 | ||
 | ||
|
||
- **Deployment** | ||
|
||
 | ||
 | ||
|
||
## A Free-From-Risk cryptocurrency exchange simulation web application | ||
|
||
You can try KCX at **[https://kcx.knightchaser.com/](https://kcx.knightchaser.com/)**, which is hosted via AWS Lightsail by the repository owner. Note that the specifications, service status, and other things might be changed depending on the development contexts and situations. (Try only for fun! :D) | ||
|
||
## Service environmental variables | ||
Currently, there are environment variables to set up the services as you need. Read the next chapter(`Deployment`) for complete contextual information. | ||
```env | ||
SQLALCHEMY_DB_SQLITE3_PATH="sqlite:///kcx.db" | ||
TEST_ACCOUNT_ID="test" | ||
TEST_ACCOUNT_PW="test" | ||
TEST_ACCOUNT_EMAIL="[email protected]" | ||
COMMON_STARTING_BALANCE_IN_KRW=20000000000 # 20 billion KRW | ||
# An example SECRET KEY for JWT. Change this to a random in production! | ||
JWT_SECRET_KEY="KCXU$3R$3CR3T4JWT_" | ||
JWT_TOKEN_EXPIRES_MINUTES=360 # 6 hours | ||
# A custom API server built with Redis | ||
REDIS_PORT=6379 | ||
REDIS_DB=0 | ||
REDIS_UDPATE_INTERVAL_IN_SECONDS=1 | ||
USER_RANKING_UPDATE_INTERVAL_IN_SECONDS=10 | ||
# Service configuration | ||
# - Money balance (Disable(false) this if you want to use a fixed starting balance for all users) | ||
ALLOW_ARBITRARY_BALANCE_DEPOSIT=false | ||
ALLOW_ARBITRARY_BALANCE_WITHDRAW=false | ||
``` | ||
- Permanent data for this service will be stored in SQLite3. Configure `SQLALCHEMY_DB_SQLITE3_PATH` for the specified path. | ||
- As a default, there are default account settings. | ||
- The service will create a default account for testing when the service starts. (Will not if it's already created) | ||
- Configure `TEST_ACCOUNT_ID`(ID = username), `TEST_ACCOUNT_PW`(password), and `TEST_ACCOUNT_EMAIL`(email) for the test account. | ||
- `COMMON_STARTING_BALANCE_IN_KRW` defines how much fund will be initially granted to the new user. | ||
- This server uses JWT for user authentication. Configure `JWT_SECRET_KEY` for JWT server key(change to another random value or your own) and `JWT_TOKEN_EXPIRES_MINUTES` for JWT expiary period. | ||
- For the price information, this service uses the market data provided from UpBIT. Of course this also mimics the cryptocurrency exchange, there are a lot of requests about the crypto market data(Generally 3 to 5 requests per second per connected user) To reduce the direct API request to UpBIT, this use REDIS database as a cache. The server caches the market data every second and multiple connected users obtain the data from this REDIS cache. | ||
- `REDIS_UPDATE_INTERVAL_IN_SECONDS` means which second this service refreshes the market data from UpBIT to the REDIS cache periodically. Basically, you can safely request up to 5 requests per second to UpBIT according to the current policy. | ||
- `USER_RANKING_UPDATE_INTERVAL_IN_SECONDS` means which second this service calculate the users' ranking data according to the calculated estimated total asset value periodically (for leaderboard). Note that this ranking calculation relatively takes a lot of computational loads(iterating all users and calculating all types of assets for estimation), so don't make it too short. | ||
- `ALLOW_ARBITRARY_BALANCE_*` configures whether the user controls their virtual balances on their own. If these are set true, then they can unlimitedly deposit(increase) and withdraw(decrease) the wallet, that may impact on the leaderboard. If you run this service for competitions or some rules, set it to false so no one except for the administrator can control the user's balances. (By accessing the SQLite3 database.) | ||
|
||
## Deployment | ||
- Clone the repository on your server/environments | ||
```sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters