-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.py
38 lines (32 loc) · 1.11 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from MtGox import MtGox
from DataSet import DataSet
from Data import Data
import time
import os
#############################################
# Change the following variables as desired #
#############################################
SELL_THRESHOLD = 20.00 # Bot will sell bitcoins once the sell value goes above this
BUY_THRESHOLD = 12.00 # Bot will buy bitcoins once the buy value goes below this
UPDATE_TIME = 2 # How often the bot retrieves new data in seconds
PERCENT_SELL = 0.5 # Percentage of BTC funds to sell when making a sell order
PERCENT_BUY = 0.5 # Percentage of USD funds to buy with when making a buy order
def main():
m = MtGox()
d = DataSet()
while True:
m.updateDataSet(d)
if m.getSell() > SELL_THRESHOLD:
m.sellBTC(m.getBTC()*PERCENT_SELL,m.getSell())
if m.getBuy() < BUY_THRESHOLD:
m.buyBTC((m.getUSD()*PERCENT_BUY)/m.getBuy(), m.getBuy())
m.updateDataSet(d)
os.system("clear")
m.printTitle()
d.printData()
m.printFunds()
m.printOrders()
m.printStatus()
time.sleep(UPDATE_TIME)
if __name__ == "__main__":
main()