blankly-finance / blankly

🚀 💸 Easily build, backtest and deploy your algo in just a few lines of code. Trade stocks, cryptos, and forex across exchanges w/ one package.
https://package.blankly.finance
GNU Lesser General Public License v3.0
2.09k stars 266 forks source link

Alpaca Cryptocurrency error(maybe just an alpaca related data error) #242

Closed Rxann closed 1 year ago

Rxann commented 1 year ago

Description

When entering something like ethusd into a Strategies add_price_event, it gives the error below and won't work. This also happens when I use the stock ticker APPL (Apple)

Error (if applicable)

Exception in thread Thread-2 (main):
Traceback (most recent call last):
  File "C:\Users\ryans\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "C:\Users\ryans\AppData\Local\Programs\Python\Python310\lib\threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\ryans\AppData\Local\Programs\Python\Python310\lib\site-packages\blankly\frameworks\strategy\strategy.py", line 159, in main
    self.run_live()
  File "C:\Users\ryans\AppData\Local\Programs\Python\Python310\lib\site-packages\blankly\frameworks\strategy\strategy.py", line 191, in run_live
    self.__run_init()
  File "C:\Users\ryans\AppData\Local\Programs\Python\Python310\lib\site-packages\blankly\frameworks\strategy\strategy.py", line 183, in __run_init
    kwargs['init'](kwargs['symbol'], kwargs['state'])
  File "C:\Coding\b\bot.py", line 31, in init_NN
    variables["history"] = interface.history(symbol, 300, resolution, return_as="list")[
  File "C:\Users\ryans\AppData\Local\Programs\Python\Python310\lib\site-packages\blankly\exchanges\strategy_logger.py", line 81, in history
    return self.interface.history(symbol, to=to,
  File "C:\Users\ryans\AppData\Local\Programs\Python\Python310\lib\site-packages\blankly\exchanges\interfaces\abc_base_exchange_interface.py", line 56, in history
    response = self.overridden_history(symbol, start, stop, res_seconds, to=to,)
  File "C:\Users\ryans\AppData\Local\Programs\Python\Python310\lib\site-packages\blankly\exchanges\interfaces\alpaca\alpaca_interface.py", line 482, in overridden_history
    response = pd.concat([response, find_last_n_points(batched_ranges[0], batched_ranges[1])])
  File "C:\Users\ryans\AppData\Local\Programs\Python\Python310\lib\site-packages\blankly\exchanges\interfaces\alpaca\alpaca_interface.py", line 459, in find_last_n_points
    start=utils.iso8601_from_epoch(epoch_start_)).df)
  File "C:\Users\ryans\AppData\Local\Programs\Python\Python310\lib\site-packages\blankly\utils\utils.py", line 278, in iso8601_from_epoch
    return dt.utcfromtimestamp(epoch).isoformat() + 'Z'
OSError: [Errno 22] Invalid argument

Platform Info

EmersonDove commented 1 year ago

Can you send the code under if __name__ == "__main"? I can't replicate on my end.