added multiple script modifications and finalized the dockerfile
This commit is contained in:
parent
de1c0750df
commit
df961f50c6
@ -235,6 +235,7 @@ venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
env.list
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -157,3 +157,5 @@ Package Control.user-ca-bundle
|
||||
oscrypto-ca-bundle.crt
|
||||
bh_unicode_properties.cache
|
||||
GitHub.sublime-settings
|
||||
|
||||
env.list
|
||||
@ -1,4 +1,4 @@
|
||||
FROM python:3.11-buster as builder
|
||||
FROM python:3.11-buster
|
||||
|
||||
RUN curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.7.1 python3 -
|
||||
|
||||
@ -10,19 +10,14 @@ ENV POETRY_NO_INTERACTION=1 \
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY pyproject.toml poetry.lock ./
|
||||
RUN touch README.md
|
||||
COPY pyproject.toml poetry.lock /app/
|
||||
COPY market_trade /app/market_trade/
|
||||
COPY tools /app/tools
|
||||
|
||||
RUN mkdir --parents --mode 0700 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
|
||||
RUN --mount=type=ssh --mount=type=cache,target=$POETRY_CACHE_DIR $HOME/.local/bin/poetry install --without dev --no-root
|
||||
|
||||
FROM python:3.11-slim-buster as runtime
|
||||
RUN --mount=type=ssh --mount=type=cache,target=$POETRY_CACHE_DIR $HOME/.local/bin/poetry install --without dev
|
||||
|
||||
ENV VIRTUAL_ENV=/app/.venv \
|
||||
PATH="/app/.venv/bin:$PATH"
|
||||
|
||||
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
|
||||
|
||||
COPY market_trade ./market_trade
|
||||
|
||||
ENTRYPOINT ["python", "-m", "annapurna.main"]
|
||||
ENTRYPOINT ["python", "tools/save_currencies_data.py"]
|
||||
0
market_trade/__init__.py
Normal file
0
market_trade/__init__.py
Normal file
@ -1,10 +1,9 @@
|
||||
[tool.poetry]
|
||||
name = "markettrade"
|
||||
name = "market_trade"
|
||||
version = "0.2.0"
|
||||
description = ""
|
||||
authors = ["Mark <strategy155@gmail.com>", "Sasha <redsandybn@yandex.ru>"]
|
||||
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.9,<3.13"
|
||||
pandas = "^2.1.3"
|
||||
|
||||
0
tools/__init__.py
Normal file
0
tools/__init__.py
Normal file
@ -1,9 +1,18 @@
|
||||
import argparse
|
||||
import pathlib
|
||||
import time
|
||||
import grpc
|
||||
import market_trade.constants
|
||||
import tinkoff_grpc.src.instruments
|
||||
import tinkoff_grpc.src.marketdata
|
||||
import tinkoff_grpc.src.channel
|
||||
import grpc
|
||||
|
||||
|
||||
# initializing argument parser
|
||||
argument_parser = argparse.ArgumentParser(prog="currencies saver")
|
||||
|
||||
# this argument is used to save the currency trades into distinct dir
|
||||
argument_parser.add_argument("-o", "--output-directory", type=pathlib.Path, dest="output_directory", action="store")
|
||||
|
||||
|
||||
def get_all_currencies(channel: tinkoff_grpc.src.channel.Channel):
|
||||
@ -15,7 +24,7 @@ def get_all_currencies(channel: tinkoff_grpc.src.channel.Channel):
|
||||
# initializing service
|
||||
instruments_service = tinkoff_grpc.src.instruments.InstrumentsService(channel)
|
||||
|
||||
# getting currencies
|
||||
# getting currencies list
|
||||
currencies = instruments_service.get_currencies(
|
||||
instrument_status_name=market_trade.constants.DEFAULT_INSTRUMENT_STATUS
|
||||
)
|
||||
@ -23,6 +32,14 @@ def get_all_currencies(channel: tinkoff_grpc.src.channel.Channel):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# getting the paths loaded
|
||||
cli_args = argument_parser.parse_args()
|
||||
|
||||
if cli_args.output_directory:
|
||||
output_data_path = cli_args.output_directory
|
||||
else:
|
||||
raise NotImplementedError("We would like to have a path where we would save data")
|
||||
|
||||
api_address = market_trade.constants.TINKOFF_API_ADDRESS
|
||||
token = market_trade.constants.TINKOFF_BEARER_TOKEN
|
||||
authorization_field = market_trade.constants.TINKOFF_AUTHORIZATION_HEADER
|
||||
@ -34,7 +51,7 @@ if __name__ == '__main__':
|
||||
time.sleep(1)
|
||||
try:
|
||||
tinkoff_trades_saver = tinkoff_grpc.savers.TradesSaver(channel=tinkoff_channel, instruments=currencies,
|
||||
filepath=market_trade.constants.CURRENCIES_TRADES_PATH)
|
||||
filepath=output_data_path)
|
||||
tinkoff_trades_saver.start()
|
||||
except grpc.RpcError as grpc_error:
|
||||
pass
|
||||
|
||||
@ -8,30 +8,32 @@ import time
|
||||
import grpc
|
||||
import argparse
|
||||
|
||||
|
||||
# initializing argument parser
|
||||
argument_parser = argparse.ArgumentParser(prog="shares saver")
|
||||
|
||||
|
||||
argument_parser.add_argument("-s", "--shares", dest="shares_data_path", action="store")
|
||||
# this argument is used for shares info location, it contains the liquidity info
|
||||
argument_parser.add_argument("-s", "--shares", type=pathlib.Path, dest="shares_data_path", action="store")
|
||||
|
||||
argument_parser.add_argument("-o", "--output-directory", dest="output_directory", action="store")
|
||||
# this argument is used to save the output into distinct dir
|
||||
argument_parser.add_argument("-o", "--output-directory", type=pathlib.Path, dest="output_directory", action="store")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli_args = argument_parser.parse_args()
|
||||
|
||||
|
||||
# filling the shares data path, no other modes are though of
|
||||
if cli_args.shares_data_path:
|
||||
shares_path = pathlib.Path(cli_args.shares_data_path)
|
||||
else:
|
||||
raise NotImplementedError("No path provided for shares liquidity data")
|
||||
|
||||
# filling the output directory data path, where the trades would be saved
|
||||
if cli_args.output_directory:
|
||||
output_data_path = pathlib.Path(cli_args.output_directory)
|
||||
else:
|
||||
raise NotImplementedError("No path for the output data of shares")
|
||||
|
||||
|
||||
# loading shares liquidity stats gathered
|
||||
with open(shares_path, encoding="utf-8", mode="r") as shares_stats_file:
|
||||
sorted_shares_liquidity_stats = json.load(shares_stats_file)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user