Skip to content

Commit

Permalink
commenting out messages (#214)
Browse files Browse the repository at this point in the history
ensuring we have stock_records to process in run_rule
  • Loading branch information
josev814 authored May 4, 2024
1 parent b7a39fb commit bbf0973
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions django/rules/management/commands/process_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def run_rule(self, record:Rules):
self.update_rule_growth(record, record.shares, current_stock_price)
return
print('Matching Stock Records: ', stock_records.count())
print(stock_records.query)
# print(stock_records.query)

action = record.rule['action']
trigger = record.rule['trigger']
Expand All @@ -252,9 +252,11 @@ def run_rule(self, record:Rules):
stock_records = stock_records.filter(timestamp__gte=trx_wait)

##### TODO: ######
if stock_records.count() == 0:
return

for stock_record in stock_records:
self.output_info(f'stock_time: {stock_record.timestamp} - trx_wait: {trx_wait}')
# self.output_info(f'stock_time: {stock_record.timestamp} - trx_wait: {trx_wait}')
if trx_wait is not None and stock_record.timestamp <= trx_wait:
continue
pre_trx_balance = balance
Expand Down Expand Up @@ -386,9 +388,9 @@ def get_profit_loss(self, record, number_of_shares, current_stock_price):
record.id,
symbol_id
)
print('Current Stock Price: ', current_stock_price)
print('AVG Cost: ', average_cost)
print('SHARES: ', number_of_shares)
# print('Current Stock Price: ', current_stock_price)
# print('AVG Cost: ', average_cost)
# print('SHARES: ', number_of_shares)
total_investment = number_of_shares * average_cost
current_value = number_of_shares * current_stock_price
return current_value - total_investment
Expand Down Expand Up @@ -435,7 +437,6 @@ def get_stock_price_from_timestamp(self, stock_id, timestamp):
F('timestamp') - Value(timestamp), function='ABS'
)
).order_by('timestamp_difference')
print(qs.query)
return qs.first().low

def get_rule_growth(
Expand Down

0 comments on commit bbf0973

Please sign in to comment.