Skip to content

Commit

Permalink
feat: update protos and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
keivanipchihagh committed Feb 16, 2024
1 parent b080d71 commit 50dce8e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 54 deletions.
23 changes: 23 additions & 0 deletions protos/athena.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
syntax = "proto3";

package athena.v1;

import "athena_struct.proto";
import "candlestick_struct.proto";

// [Request] RequestBacktest
// broker: Broker properties.
// historicals: Historical data.
message RequestBacktest {
Broker broker = 1;
Historical historicals = 2;
}

// [Response] ResponseBacktest
message ResponseBacktest {
int64 id = 1;
}

service Athena {
rpc Backtest (RequestBacktest) returns (ResponseBacktest);
}
17 changes: 17 additions & 0 deletions protos/athena_struct.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
syntax = "proto3";

package athena.v1;

// Broker configuration.
// commission: Commission rate charged by the broker for each trade.
// cache: Initial balance for trading.
// capital_risk: Capital risk limit imposed by the broker.
// trade_on_close: Indicates whether to trade on open or close.
// exclusive_orders: Indicates whether the broker accepts exclusive orders.
message Broker {
float commission = 1;
float cache = 2;
float capital_risk = 3;
bool trade_on_close = 4;
bool exclusive_orders = 5;
}
2 changes: 0 additions & 2 deletions protos/candlestick_struct.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
syntax = "proto3";

package candle_struct.v1;

import "google/protobuf/timestamp.proto";

// Open, high, Low, Close, and Volume data for a single candlestick.
Expand Down
42 changes: 9 additions & 33 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,19 @@ working_dir=$(pwd)
proto_dirs=($(pwd)/protos) # ./protos/
python_dir=($(pwd)/src) # ./src/

# Add execute permission to `create_dir.sh`
chmod +x ./scripts/create_dir.sh

# Create ./src/ directory
./scripts/create_dir.sh src

# Create ./src/ dirctory
directory="src"
if [ ! -d "$directory" ]; then
# Create the directory
mkdir -p "$directory"
echo "Directory '$directory' created successfully."
else
echo "Directory '$directory' already exists."
fi

# Build *.proto files within the ./protos/ directory
python3 -m grpc_tools.protoc\
--proto_path=$proto_dirs\
--python_out=$python_dir\
--grpc_python_out=$python_dir\
$proto_dirs/*.proto # ./protos/*.proto


# Find subdirectories under ./protos/
subdirectories=$(find "$proto_dirs" -mindepth 1 -maxdepth 1 -type d)

# .*proto files within subdirectories
for proto_dir in $subdirectories
do
src_dir="${proto_dir/protos/src}"

# Check if the directory is empty
if [ -z "$(ls -A "$proto_dir")" ]; then
echo "Directory $proto_dir is empty. Skipping..."
continue
fi

# Create corresponding subdirectories under ./src/
dir="${src_dir##*/}"
./scripts/create_dir.sh "src/$dir"

python3 -m grpc_tools.protoc\
-I.\
--proto_path=$proto_dirs\
--python_out=$src_dir\
--grpc_python_out=$src_dir\
$proto_dir/*.proto # ./protos/<subdir>/*.proto
done
19 changes: 0 additions & 19 deletions scripts/create_dir.sh

This file was deleted.

0 comments on commit 50dce8e

Please sign in to comment.