I'm trying to create a simple program that creates a Bitcoin price, starting at $270, which changes either 1, 3, or 5 upwards or downwards.If the price goes up 3 times in a row, I would like to issue a "buy," and put $1000 in at whatever price Bitcoin is currently at, and sell out when the price has declined twice in a row. Right now, I'm simply trying to create 3 variables, each holding one of the last 3 prices. Here is my code, and the error:
import random
class pricechanger(object):
price = 270
pricedirection = random.randint(1,4)
pricevelocity = random.randrange(1,3)
def _init_(self):
return 0
def pricemover(self):
if pricedirection == 1 or pricedirection == 3:
if pricevelocity == 1:
price += 1
if pricevelocity == 2:
price+=3
if pricevelocity == 3:
price+=5
if pricedirection == 4:
if pricevelocity == 1:
price = price-1
if pricevelocity == 2:
price = price-3
if pricevelocity == 3:
price=price-5
import pricechanger
import time
class FakeBitcoinTrader():
def prices():
while True:
a=1
price = pricechanger.pricemover(x)
if a == 1:
price = price1
if a == 2:
price = price2
if a == 3:
a=0
print("price:"+price)
print("price1"+price1)
print("price2"+price2)
print("a:"+a)
time.sleep(10)
a=a+1
prices()
#price1
#price2
Error:
Every other time the code runs, it does not return an error. Sometimes it outputs a value 270+/-5, sometimes it doesn't output anything.
Every second time (so far anyways) it outputs this.
Traceback (most recent call last):
File "/home/matthew/FakeBitcoinTrader.py", line 44, in <module>
class FakeBitcoinTrader():
File "/home/matthew/FakeBitcoinTrader.py", line 69, in FakeBitcoinTrader
prices()
File "/home/matthew/FakeBitcoinTrader.py", line 50, in prices
price = pricechanger.pricemover(x)
AttributeError: 'module' object has no attribute 'pricemover'

New Topic/Question
Reply


MultiQuote



|