Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker (TradingBot) #180

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions csharp/TraderBot/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bin/
obj/
appsettings.json
19 changes: 19 additions & 0 deletions csharp/TraderBot/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
LOG_LEVEL_DEFAULT="Information"
MICROSOFT_HOSTING_LIFETIME="Information"
ACESS_TOKEN="t.siwZq-73Z1gAy4K-a6Tu146xG341WHe1dT37wR8kVNB1"
feelan03 marked this conversation as resolved.
Show resolved Hide resolved
APP_NAME="LinksPlatformScalper"
INSTRUMENT="Etf"
TICKER="TRUR"
CASH_CURRENCY="rub"
ACCOUNT_INDEX=-1
MINIMUM_PROFIT_STEPS=-2
MARKET_ORDER_BOOK_DEPTH=10
MINIMUM_MARKET_ORDER_SIZE_TO_CHANGE_BUY_PRICE=250000
MINIMUM_MARKET_ORDER_SIZE_TO_CHANGE_SELL_PRICE=0
MINIMUM_MARKET_ORDER_SIZE_TO_BUY=250000
MINIMUM_MARKET_ORDER_SIZE_TO_SELL=0
MINIMUM_TIME_TO_BUY="09:00:00"
MAXIMUM_TIME_TO_BUY="14:45:00"
EARLY_SELL_OWNED_LOTS_DELTA=250000
EARLY_SELL_OWNED_LOTS_MULTIPLIER=0
LOAD_OPERATIONS_FROM="2022-08-21T00:00:01.3389860Z"
1 change: 1 addition & 0 deletions csharp/TraderBot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
17 changes: 17 additions & 0 deletions csharp/TraderBot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0 as build-env
WORKDIR /app

COPY config.sh ./

RUN apt update && \
apt install jq -y && \
bash /app/config.sh > appsettings.json

COPY app ./
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=build-env /app/out .
COPY --from=build-env /app/appsettings.json .
ENTRYPOINT ["dotnet", "TraderBot.dll"]
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
}
},
"InvestApiSettings": {
"AccessToken": "",
"AccessToken": "t.siwZq-73Z1gAy4K-KL1aw7XvNQySsfKC5lQBQNCGeIVnwLPAFYgFOjmXq5TN39AQabBRrAqq4UPBvdptLzdv3w",
feelan03 marked this conversation as resolved.
Show resolved Hide resolved
"AppName": "LinksPlatformScalper"
},
"TradingSettings": {
"Instrument": "Etf",
"Ticker": "TRUR",
"CashCurrency": "rub",
"AccountIndex": -1,
"AccountIndex": 0,
feelan03 marked this conversation as resolved.
Show resolved Hide resolved
"MinimumProfitSteps": -2,
"MarketOrderBookDepth": 10,
"MinimumMarketOrderSizeToChangeBuyPrice": 250000,
Expand Down
File renamed without changes.
54 changes: 54 additions & 0 deletions csharp/TraderBot/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

set -o pipefail
set +e

jq -n \
--arg logLevelDefault "$LOG_LEVEL_DEFAULT" \
--arg microsoftHostingLifetime "$MICROSOFT_HOSTING_LIFETIME" \
--arg accessToken "$ACESS_TOKEN" \
feelan03 marked this conversation as resolved.
Show resolved Hide resolved
--arg appName "$APP_NAME" \
--arg instrument "$INSTRUMENT" \
--arg ticker "$TICKER" \
--arg cashCurrency "$CASH_CURRENCY" \
--arg accountIndex "$ACCOUNT_INDEX" \
--arg minimumProfitSteps "$MINIMUM_PROFIT_STEPS" \
--arg marketOrderBookDepth "$MARKET_ORDER_BOOK_DEPTH" \
--arg minimumMarketOrderSizeToChangeBuyPrice "$MINIMUM_MARKET_ORDER_SIZE_TO_CHANGE_BUY_PRICE" \
--arg minimumMarketOrderSizeToChangeSellPrice "$MINIMUM_MARKET_ORDER_SIZE_TO_CHANGE_SELL_PRICE" \
--arg minimumMarketOrderSizeToBuy "$MINIMUM_MARKET_ORDER_SIZE_TO_BUY" \
--arg minimumMarketOrderSizeToSell "$MINIMUM_MARKET_ORDER_SIZE_TO_SELL" \
--arg minimumTimeToBuy "$MINIMUM_TIME_TO_BUY" \
--arg maximumTimeToBuy "$MAXIMUM_TIME_TO_BUY" \
--arg earlySellOwnedLotsDelta "$EARLY_SELL_OWNED_LOTS_DELTA" \
--arg earlySellOwnedLotsMultiplier "$EARLY_SELL_OWNED_LOTS_MULTIPLIER" \
--arg loadOperationsFrom "$LOAD_OPERATIONS_FROM" \
'{
"Logging": {
"LogLevel": {
"Default": $logLevelDefault,
"Microsoft.Hosting.Lifetime": $microsoftHostingLifetime
}
},
"InvestApiSettings": {
"AccessToken": $accessToken,
"AppName": $appName
},
"TradingSettings": {
"Instrument": $instrument,
"Ticker": $ticker,
"CashCurrency": $cashCurrency,
"AccountIndex": $accountIndex,
"MinimumProfitSteps": $minimumProfitSteps,
"MarketOrderBookDepth": $marketOrderBookDepth,
"MinimumMarketOrderSizeToChangeBuyPrice": $minimumMarketOrderSizeToChangeBuyPrice,
"MinimumMarketOrderSizeToChangeSellPrice": $minimumMarketOrderSizeToChangeSellPrice,
"MinimumMarketOrderSizeToBuy": $minimumMarketOrderSizeToBuy,
"MinimumMarketOrderSizeToSell": $minimumMarketOrderSizeToSell,
"MinimumTimeToBuy": $minimumTimeToBuy,
"MaximumTimeToBuy": $maximumTimeToBuy,
"EarlySellOwnedLotsDelta": $earlySellOwnedLotsDelta,
"EarlySellOwnedLotsMultiplier": $earlySellOwnedLotsMultiplier,
"LoadOperationsFrom": $loadOperationsFrom
}
}'
5 changes: 5 additions & 0 deletions csharp/TraderBot/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: "3.9"
services:
trader-bot:
build: .
env_file: .env