mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-02 20:28:51 +08:00
Adjust examples plots to display price of full coin
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user