SHARE
TWEET

Untitled

barrick09 Nov 11th, 2019 (edited) 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def trade_action(current_shares, purchase_price, market_price, available_funds):
  2.     decision_action = calculate_action(current_shares, purchase_price, market_price, available_funds)  
  3.     number_of_shares = calculate_stock_number(decision_action)  
  4.     shares = str(number_of_shares)
  5.     if decision_action == "buy":
  6.         return print("Buy " + shares + " shares")
  7.     elif decision_action == "sell":
  8.         return print("Sell " + shares + " shares" )
  9.     else:
  10.         return print("Hold shares")
  11.    
  12. def calculate_action(current_shares, purchase_price, market_price, available_funds):
  13.     if purchase_price > market_price:
  14.         if (available_funds - 10) / market_price >= 1:
  15.             if ((available_funds - 10) / market_price) * (purchase_price - market_price) > 10:
  16.                 decision_action = "buy"
  17.     elif purchase_price < market_price:
  18.         if (market_price - purchase_price) * (current_shares / market_price) > 10:
  19.             decision_action = "sell"
  20.         return decision_action
  21.            
  22. def calculate_stock_number(decision_action):
  23.     if decision_action == "buy":
  24.        number_of_shares = (available_funds - 10) / market_price
  25.     if decision_action == "sell":
  26.        number_of_shares = current_shares
  27.     return number_of_shares
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top