added multiple script modifications and finalized the dockerfile

This commit is contained in:
2023-12-26 22:42:52 +02:00
parent de1c0750df
commit df961f50c6
8 changed files with 37 additions and 21 deletions

View 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