# Estrategia de inversión

Thu Aug 05 2021 14:53:54 GMT+0000 (Coordinated Universal Time)

Saved by @CleverIT

```def full_pred(x, y):
btc = [5.0] + [np.nan] * (len(dff)-1)
cash = [0] + [np.nan] * (len(dff)-1)
prediction = list(dff['Predictions'])
price = list(dff['Price'])
for i in range(1, len(dff)-1):
for j in range(0, 2):
if prediction[i+1] > (prediction[i] * (1.0 + y/100.0)):
if cash[i] > price[i]:
btc[i] = btc[i-1] + 1.0
cash[i] = cash[i-1] - price[i]
elif price[i] > cash[i-1] > 0.0:
btc[i] = btc[i-1] + (cash[i-1] / price[i])
cash[i] = 0.0
else:
btc[i] = btc[i - 1]
cash[i] = cash[i - 1]
elif (prediction[i] * (1.0 - x/100.0)) > prediction[i+1]:
if btc[i-1] >= 1.0:
btc[i] = btc[i-1] - 1.0
cash[i] = cash[i-1] + price[i]
elif 1.0 > btc[i-1] > 0.0:
btc[i] = 0.0
cash[i] = cash[i-1] + (price[i] * btc[i-1])
else:
btc[i] = btc[i - 1]
cash[i] = cash[i - 1]
else:
btc[i] = btc[i-1]
cash[i] = cash[i-1]
dff['BTC'] = btc
dff['Cash'] = cash
dff['Strategy'] = dff['Price'] * dff['BTC'] + dff['Cash']