Adjust examples plots to display price of full coin

This commit is contained in:
Conner Fromknecht
2017-07-03 00:50:38 -07:00
parent 0a0c96ba0c
commit cbaccda564
2 changed files with 9 additions and 5 deletions
+4 -2
View File
@@ -28,6 +28,8 @@ ASSET = 'USDT_BTC'
TARGET_HODL_RATIO = 0.8
RESERVE_RATIO = 1.0 - TARGET_HODL_RATIO
UNITS_PER_COIN = 10.0
def initialize(context):
context.is_buying = True
context.asset = symbol(ASSET)
@@ -75,7 +77,7 @@ def analyze(context=None, results=None):
ax2 = plt.subplot(512, sharex=ax1)
ax2.set_ylabel('{asset} (USD)'.format(asset=ASSET))
results[['price']].plot(ax=ax2)
(UNITS_PER_COIN * results[['price']]).plot(ax=ax2)
trans = results.ix[[t != [] for t in results.transactions]]
buys = trans.ix[
@@ -83,7 +85,7 @@ def analyze(context=None, results=None):
]
ax2.plot(
buys.index,
results.price[buys.index],
UNITS_PER_COIN * results.price[buys.index],
'^',
markersize=10,
color='g',
+5 -3
View File
@@ -37,6 +37,8 @@ TARGET_INVESTMENT_RATIO = 0.8
SHORT_WINDOW = 30
LONG_WINDOW = 100
UNITS_PER_COIN = 10.0
def initialize(context):
context.i = 0
context.asset = symbol(ASSET)
@@ -112,7 +114,7 @@ def analyze(context=None, results=None):
ax2 = plt.subplot(512, sharex=ax1)
ax2.set_ylabel('{asset} (USD)'.format(asset=ASSET))
results[['price', 'short_mavg', 'long_mavg']].plot(ax=ax2)
(UNITS_PER_COIN*results[['price', 'short_mavg', 'long_mavg']]).plot(ax=ax2)
trans = results.ix[[t != [] for t in results.transactions]]
amounts = [t[0]['amount'] for t in trans.transactions]
@@ -126,14 +128,14 @@ def analyze(context=None, results=None):
ax2.plot(
buys.index,
results.price[buys.index],
UNITS_PER_COIN * results.price[buys.index],
'^',
markersize=10,
color='g',
)
ax2.plot(
sells.index,
results.price[sells.index],
UNITS_PER_COIN * results.price[sells.index],
'v',
markersize=10,
color='r',