Skip to content

Commit

Permalink
minor playing on sucessfull bumblebee
Browse files Browse the repository at this point in the history
  • Loading branch information
miro-ka committed Jul 31, 2017
1 parent e5c7413 commit 478354d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,23 @@ Visualization uses external library [plotly](https://plot.ly/). Below You can se

<img src="https://user-images.githubusercontent.com/1301154/28573699-70c6d14c-7119-11e7-8bb6-06c53908066d.png">

Below is an example of Final Simulation Report summary:
```
****************************************************
Final simulation report:
****************************************************
Wallet at Start: | 50.0DGB |
Wallet at End: | 51.3464723121DGB |
Strategy result: -5.68%
Buy & Hold: -8.16%
Strategy vs Buy & Hold: 2.47%
Total txn: 10
Simulated (data time): 0 days, 4 hours and 55 minutes
Transactions per hour: 2.03
Simulation run time: 0 hours 1 minutes and 13 seconds
Created new window in existing browser session.
```


## Donate
If you would like to support the project in other way than code-contributing, you can donate Mosquito development on
Expand Down
8 changes: 5 additions & 3 deletions core/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def write_final_stats(self, ticker_start, ticker_end, wallet, trades):
print('****************************************************')
print('* Final simulation report: *')
print('****************************************************')
print('Wallet at Start:', self.get_wallet_text(wallet.initial_balance))
print('Wallet at End:', self.get_wallet_text(wallet.current_balance))
print(self.get_color_text('Strategy result: ', curr_bal_percent))
print(self.get_color_text('Buy & Hold: ', buy_and_hold))
print(self.get_color_text('Strategy vs Buy & Hold: ', curr_bal_percent-buy_and_hold))
Expand Down Expand Up @@ -67,7 +69,7 @@ def calc_stats(self, ticker_data, wallet):
date_time = datetime.fromtimestamp(ticker_data['date'][0]).strftime('%c') + ','
current_close = 'close:' + format(ticker_data.iloc[0]['close'], '2f') + ','
# Wallet
wallet_text = self.get_wallet_text(wallet)
wallet_text = self.get_wallet_text(wallet.current_balance)
# Balance
balance = self.calc_balance(ticker_data, wallet.current_balance)
balance_text = self.get_color_text('$: ', balance) + ','
Expand All @@ -90,9 +92,9 @@ def get_wallet_text(wallet, currencies=None):
"""
# TODO return only wallet of given currencies
wallet_string = ''
for symbol, balance in wallet.current_balance.items():
for symbol, balance in wallet.items():
if balance > 0:
wallet_string += ' | ' + str(balance) + symbol
wallet_string += '| ' + str(balance) + symbol
wallet_string += ' |'
return wallet_string

Expand Down
11 changes: 7 additions & 4 deletions strategies/bumblebee.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Bumblebee(Base):
def __init__(self, args):
super(Bumblebee, self).__init__(args)
self.name = 'ema'
self.min_history_ticks = 60 # 60 minute interval
self.min_history_ticks = 60 # 300 minute interval
self.pair = 'BTC_DGB'

def calculate(self, look_back, wallet):
Expand All @@ -40,11 +40,14 @@ def calculate(self, look_back, wallet):
volume = df['volume'].values

# ** Ema **
# ema = talib.EMA(close, timeperiod=len(close))[end_index]
# end_index = len(df.index) - 1
# ema = talib.EMA(close, timeperiod=len(close))[end_index]
# print('ema:', ema)

# ** Slope **
# end_index = len(df.index) - 1
# slope = talib.LINEARREG_SLOPE(close, timeperiod=len(close))[end_index]
# print('slope:', slope)

# ** OBV (On Balance Volume)
obv = talib.OBV(close, volume)
Expand All @@ -58,9 +61,9 @@ def calculate(self, look_back, wallet):
perc_change = percent_change(look_back, 2)
print('perc_change:', perc_change)

if obv >= 200:
if obv >= 20:
new_action = TradeState.buy
elif obv < 0 or perc_change <= -1.0:
elif obv < -5: # or perc_change <= -1.0:
new_action = TradeState.sell

df_last = df.iloc[[-1]]
Expand Down

0 comments on commit 478354d

Please sign in to comment.