diff options
author | loit <michael.foiani@gmail.com> | 2025-07-29 21:15:50 -0400 |
---|---|---|
committer | loit <michael.foiani@gmail.com> | 2025-07-29 21:15:50 -0400 |
commit | 9e58ec4f60cd42111ed4d5d52830c2402bae263b (patch) | |
tree | 4d9ba3d4fc22c8baad08895c94d97682475a01a1 /simulate.py | |
parent | 4722ce02ff70cd30ceb11b0ffa93f4e53ca6f80c (diff) |
fix small bugs
Diffstat (limited to 'simulate.py')
-rw-r--r-- | simulate.py | 16 |
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) |