I have expertise in python, only need help in trading.
After read a little, I develop a python script that simulate prices of BTC in random.
After some profit, I save a little to later get that money back and let the rest be for trade. I think the problem with this is understand the basic concepts before move to more complicated matter, and is the kind of info I have not found yet.
Is this correct?
(Could run here. Pure python:)
http://rextester.com/CLG92944
from random import randint
from decimal import Decimal
margin = Decimal(0.03)
stance = 'none'
buyPrice = Decimal(0)
sellPrice = Decimal(0)
stockPrice = Decimal(0)
investmentAmount = Decimal(50)
previousPrice = investmentAmount
totalProfit = investmentAmount
coins = Decimal(0)
totalCoins = Decimal(0)
savings = Decimal(0)
savingsAmount = Decimal(0.2)
BUY_MSG = "BUY %.2f coins at %.2f (%.2f). Profit %.2f"
SELL_MSG = "SELL %.2f coins at %.2f (%.2f). Profit %.2f"
def getValue():
for x in xrange(100):
yield Decimal(randint(750, 890))
#print list(getValue())
for stockPrice in getValue():
if stance == 'none':
if stockPrice totalProfit:
buyPrice = totalProfit
else:
buyPrice = stockPrice
coins = buyPrice / stockPrice
totalCoins += coins
totalProfit -= buyPrice
print BUY_MSG % (coins, buyPrice, stockPrice, totalProfit)
stance = 'holding'
else:
if stockPrice > buyPrice * margin + buyPrice:
coins = totalCoins
sellPrice = stockPrice * totalCoins
totalCoins = Decimal(0)
totalProfit += sellPrice
print SELL_MSG % (coins, sellPrice, stockPrice, totalProfit)
# Ahora guardar un poco en el ahorro!
if totalProfit > investmentAmount:
amountToSave = savingsAmount * totalProfit
savings += amountToSave
totalProfit -= amountToSave
print "\tSaved %.2f" % amountToSave
stance = 'none'
previousPrice = stockPrice
print "\n\n"
print "Initial investment:", investmentAmount
print "Final: %.2f Coins = %.2f" % (totalProfit, totalCoins)
print "In savings: %.2f" % savings