added multiple script modifications and finalized the dockerfile
This commit is contained in:
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)
|
||||
|
||||
Reference in New Issue
Block a user