-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
186 additions
and
29 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Cache folder | ||
|
||
Store downloaded trading data files here. | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Executor configurations | ||
|
||
This folder contains configuration scripts for different trading strategy executions | ||
|
||
- Strategy Python file | ||
- Used Python hot wallet | ||
- Discord webhooks | ||
|
||
These scripts are used to create `.env` file that you can use with `docker-compose` or directly `source` in shell. | ||
|
||
The configuration is created by splicing together | ||
|
||
- Shared secret variables (e.g. JSON-RPC endpoints) | ||
- Strategy specific secret variables (e.g. hot wallet private key) | ||
- Public variables (e.g. strategy icon, name and description, gas pricing parameters) |
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Prepare environment variable list. | ||
Because the configuration options list is so long, it is hard to manage by hand. | ||
- Reads the current environment variable list | ||
- Writes out cleaned up .env file to stdout | ||
Very useful with Docker. | ||
""" | ||
|
||
import os | ||
|
||
from tradeexecutor.cli.env import get_available_env_vars | ||
|
||
vars = get_available_env_vars() | ||
|
||
# print("Strategy execution settings are:", ", ".join(vars)) | ||
|
||
for desc in vars: | ||
value = os.environ.get(desc.name) | ||
print(f"# {desc.help}") | ||
print(f"# Type: {desc.type}") | ||
if value is not None: | ||
print(f"{desc.name}={value}") | ||
else: | ||
print(f"{desc.name}=") | ||
print() | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# State files | ||
|
||
Running strategy executors will write their state files here. | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"""Environment variable managment.""" | ||
from dataclasses import dataclass | ||
from typing import List | ||
|
||
from click import Context | ||
from typer.main import get_command | ||
|
||
from tradeexecutor.cli.main import app | ||
|
||
|
||
@dataclass | ||
class EnvVarDescription: | ||
name: str | ||
help: str | ||
type: str | ||
|
||
|
||
def get_available_env_vars() -> List[EnvVarDescription]: | ||
"""Get list of environment variable configuration options for trade-executor. | ||
:return: | ||
List of environment variable names | ||
""" | ||
command = get_command(app) | ||
start = command.commands["start"] | ||
ctx = Context(start) | ||
params = start.get_params(ctx) | ||
result = [] | ||
for p in params: | ||
envvar = p.envvar | ||
if envvar: | ||
# Option --help does not have envvar, etc. | ||
result.append( | ||
EnvVarDescription( | ||
envvar, | ||
p.help, | ||
p.type, | ||
) | ||
) | ||
|
||
return result |
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