Skip to content

Instantly share code, notes, and snippets.

@codcodog
Created November 13, 2020 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codcodog/2c4c569501788e352eabd45e7e7a4331 to your computer and use it in GitHub Desktop.
Save codcodog/2c4c569501788e352eabd45e7e7a4331 to your computer and use it in GitHub Desktop.
bias calculate
#!/usr/bin/env python
import sys
avg_price = float(sys.argv[1])
new_price = float(sys.argv[2])
bias = float(sys.argv[3])
unit = (new_price - avg_price) / bias
buy_price1 = round(avg_price - unit * 3, 3)
buy_price2 = round(avg_price - unit * 5, 3)
buy_price3 = round(avg_price - unit * 7, 3)
sell_price1 = round(avg_price + unit * 3, 3)
sell_price2 = round(avg_price + unit * 5, 3)
sell_price3 = round(avg_price + unit * 7, 3)
sell_price4 = round(avg_price + unit * 10, 3)
print("-3 bias: ", buy_price1)
print("-5 bias: ", buy_price2)
print("-7 bias: ", buy_price3)
print("")
print("22 price: {}, now price: {}, now bias: {}".format(avg_price, new_price, bias))
print()
print("3 bias: ", sell_price1)
print("5 bias: ", sell_price2)
print("7 bias: ", sell_price3)
print("10 bias: ", sell_price4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment