aboutsummaryrefslogtreecommitdiff
path: root/simulate.py
diff options
context:
space:
mode:
Diffstat (limited to 'simulate.py')
-rw-r--r--simulate.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/simulate.py b/simulate.py
index 0ecdaff..8d69b3d 100644
--- a/simulate.py
+++ b/simulate.py
@@ -34,14 +34,14 @@ def backtest_algo(algo : Algo, timestamps, prices, init_offset=5, starting_money
current_liquid = 0
is_bought = 1.0
buy_data.append(i)
- print("buy", shares_owned, current_liquid, datetime.datetime.fromtimestamp(timestamps[i]))
+ #print("buy", shares_owned, current_liquid, datetime.datetime.fromtimestamp(timestamps[i]))
elif current_signal == 0.0: # signal sell all
if is_bought == 1.0: # if we have bought, sell!
current_liquid = shares_owned * cur_p
shares_owned = 0
is_bought = 0.0
sell_data.append(i)
- print('sell', shares_owned, current_liquid, datetime.datetime.fromtimestamp(timestamps[i]))
+ #print('sell', shares_owned, current_liquid, datetime.datetime.fromtimestamp(timestamps[i]))
# calculate total assets
@@ -74,14 +74,18 @@ def test():
ema_algo = Ema_Algo()
+ ticker = 'ADA-USD'
+ period = '5d'
+ interval = '1m'
+
# get data
- data = fetch_chart_data('SPY', '1y', '1d')
+ data = fetch_chart_data(ticker, period, interval)
print(data.keys())
url_params = {
- "ticker" : 'SPY',
- "period" : '1yr',
- "interval" : '1d',
+ "ticker" : ticker,
+ "period" : period,
+ "interval" : interval,
}
results = backtest_algo(ema_algo, data['timestamps'], data['prices'], 13)