Giter Site home page Giter Site logo

kieran-mackle / autotrader-demo Goto Github PK

View Code? Open in Web Editor NEW
65.0 65.0 42.0 77 KB

A repository containing algo-trading strategies built for AutoTrader. See the website below.

Home Page: https://kieran-mackle.github.io/AutoTrader/

Python 100.00%
algo-trading forex-trading oanda python trading-strategies

autotrader-demo's People

Contributors

kieran-mackle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

autotrader-demo's Issues

nothing work

Describe the bug
A clear and concise description of what the bug is.
i install from code, pip install, and all go wrong
To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.
autotrader version

Screenshots
If applicable, add screenshots to help explain your problem.

File "/Users/bruno/AutoTrader/autotrader/autoplot.py", line 8, in
from bokeh.plotting import figure, output_file, show
File "/Users/bruno/.pyenv/versions/3.9.1/lib/python3.9/site-packages/bokeh/plotting/init.py", line 67, in
from ..document import Document; Document
File "/Users/bruno/.pyenv/versions/3.9.1/lib/python3.9/site-packages/bokeh/document/init.py", line 35, in
Additional context
Add any other context about the problem here.

Peer closed connection. clientId 3 already in use?

Hello,
I tried to use feed='ib' for testing macd strategy example provided and every time I try to connect to TWS this happens:

runfile.py

from autotrader import AutoTrader

# Create AutoTrader instance, configure it, and run backtest
at = AutoTrader()
keys_config = {
    "IB": {
        "host": "127.0.0.1",
        "clientID": 7497,
        "clientID": 0
    }
}
at.configure(global_config=keys_config, verbosity=1, show_plot=True, feed='ib')
at.add_strategy('macd')
at.backtest(start='1/1/2021', end='1/5/2022')
at.virtual_account_config(initial_balance=1000, leverage=30)
at.run()

output:
Peer closed connection. clientId 3 already in use?
API connection failed: TimeoutError()

Unsure of how to define the IB connection parameters

Hello!

I am trying to use autotrader with IB, and I can't seem to get it to connect to the InteractiveBroker Gateway. When I specify the feed=ib and broker=ib, the runfile.py errors that it can't connect. Originally, I was running my IB GW on port 5000 as that is the default. I tried defining "HOST" and "PORT" in my GLOBAL.yaml, but nothing I define there would actually point the connection to another host/port. I am certain that I am reading in the GLOBAL.yaml because if I comment out the IB section, the script bombs asking for HOST to be defined. I moved my IB GW from 5000 to 7497 since that is what the script appears to be asking for, and I was able to get past the "connection refused" errors. However...

Once I could get runfile.py to communicate with the IB GW, the script errors with a timeout. I suspect it may not understand that it needs to speak SSL to the IB GW? But I don't know if that can be defined.

My question is this. Can you give a sample config file for the IB section of the GLOBAL.yaml? I'd like to know what I can set so I can tweak it to work.

Also, great job on everything so far. I don't know what you consider to be a good strat, but I have written one backtesting over 200% in 2 years. I am happy to share it with you privately.

ccxt btc sample

Describe the bug
A clear and concise description of what the bug is.
how to configure ccxt with cypto (bybit)
To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

[STRATEGY REQUEST]

strat2.txt
Describe the strategy you'd like to see added
A clear and concise description of the strategy, including entry and exits conditions, position sizing, indicators, etc.

Is your strategy request related to one posted online somewhere? Please provide any links.
A clear and concise description of where you found the strategy.

Additional context
Add any other context or screenshots about the feature request here.

[STRATEGY REQUEST]

Describe the strategy you'd like to see added
A clear and concise description of the strategy, including entry and exits conditions, position sizing, indicators, etc.

Is your strategy request related to one posted online somewhere? Please provide any links.
A clear and concise description of where you found the strategy.

Additional context
Add any other context or screenshots about the feature request here.

yfinance error——AttributeError: 'Index' object has no attribute 'tzinfo'

1 Failed download:
- ETH-USD: No data found for this date range, symbol may be delisted
Traceback (most recent call last):
  File "D:\my ebooks\autotrader-demo-main\runfile.py", line 26, in <module>
    at.run()
  File "D:\Program Files\anaconda3\envs\atdemo\lib\site-packages\autotrader\autotrader.py", line 1142, in run
    self._main()
  File "D:\Program Files\anaconda3\envs\atdemo\lib\site-packages\autotrader\autotrader.py", line 1613, in _main
    bot = AutoTraderBot(
  File "D:\Program Files\anaconda3\envs\atdemo\lib\site-packages\autotrader\autobot.py", line 223, in __init__
    self._refresh_data(deploy_dt)
  File "D:\Program Files\anaconda3\envs\atdemo\lib\site-packages\autotrader\autobot.py", line 449, in _refresh_data
    data, multi_data, quote_data, auxdata = self.Stream.refresh(timestamp=timestamp)
  File "D:\Program Files\anaconda3\envs\atdemo\lib\site-packages\autotrader\utilities.py", line 1174, in refresh
    data = data_func(
  File "D:\Program Files\anaconda3\envs\atdemo\lib\site-packages\autotrader\autodata.py", line 783, in _yahoo
    if data.index.tzinfo is None:
AttributeError: 'Index' object has no attribute 'tzinfo'

I have tried every solution, but they didn't work. I have tried many versions of yfiance and pandas, but this problem still exist

Simple Moving Average SMA44 rising and falling

Describe the strategy you'd like to see added
While SMA 44 is rising (last 3-5 candles) on 5 min timeframe if green candle crosses and closes above the 44SMA, then buy order must be placed above high (with buffer like 0.2) of that (crossing) candle and stop loss is loss(with some buffer) of same candle.
Target must be 1:4 and Quantity must be calculated based on risk per trade.

Similar steps to be done on sell side.

Is your strategy request related to one posted online somewhere? Please provide any links.
Will add more details later

Basically, candle sticks and SMA(Simple Moving Average) must be used for strategy and Risk Management must be followed.
In this example I am talking about SMA 44 but it can be even SMA 24 or whatever optimized value we get for a particular stock.

Dydx - Invalid value

when i run the file runfile.py, i have selected the data source as dydx, but it gives error dydx3.errors.DydxApiError: DydxApiError(status_code=400, response={'errors': [{'value': '2023-01-05T00:00:00 00:00', 'msg': 'Invalid value', 'param': 'toISO', 'location': 'query'}]})

My code:

from autotrader import AutoTrader

# Create AutoTrader instance, configure it, and run backtest
at = AutoTrader()
at.configure(verbosity=1, show_plot=False, feed='dydx', data_index_time='close')
at.add_strategy('ema_crossover')
at.backtest(start='05/1/2023', end='14/1/2023')
at.virtual_account_config(initial_balance=100, leverage=20)
at.run()

How to resolve it. Many thanks

[STRATEGY REQUEST]

Hello, i have a question of how to use autodetect_divergence()

i have a dataframe with timestamp and ohlc and signalline from macd.

i try to use as followed:

import indicators as indi
import csv
import pandas as pd
df = pd.read_csv ('btc_candles1m.csv')
test=indi.autodetect_divergence(df.filter(['open', 'high', 'low', 'close']),df.filter(['signal']))

and i get this result

Traceback (most recent call last):
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\indexes\range.py", line 351, in get_loc
return self._range.index(new_key)
ValueError: -1 is not in range

could you shed some light for me?:)

very good work with your project, keep it up!

[STRATEGY REQUEST]

Describe the strategy you'd like to see added
A clear and concise description of the strategy, including entry and exits conditions, position sizing, indicators, etc.

Is your strategy request related to one posted online somewhere? Please provide any links.
A clear and concise description of where you found the strategy.

Additional context
Add any other context or screenshots about the feature request here.

unexpected keyword argument

Hi,
Running demo run_scan.py for autotrader-0.9.1 returns the following error for macd strattegy:

raceback (most recent call last):
File "run_scan.py", line 12, in
at.run()
File "/home/kgori/.local/lib/python3.8/site-packages/autotrader/autotrader.py", line 933, in run
self.add_strategy(strategy_filename=strat_config_file)
TypeError: add_strategy() got an unexpected keyword argument 'strategy_filename'

Thanks

' Broker' object has no attribute '_allow_dancing_bears '

I got error when deploying in livetrade mode (auto trade in paper environment)

Error log

2024-03-27 03:08:29,557 | ERROR | autobot | Error when updating strategy: 'Broker' object has no attribute '_allow_dancing_bears' (autobot.py:238)
2024-03-27 03:08:29,558 | INFO | autobot | Traceback (most recent call last):
File "/home/adminuser/venv/lib/python3.11/site-packages/autotrader/autobot.py", line 236, in _update
strategy_orders = self._strategy.generate_signal(timestamp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mount/src/autotrader-forex/strategies/ema_crossover.py", line 55, in generate_signal
data = self.broker.get_candles(self.instrument, granularity="1h", count=300)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/adminuser/venv/lib/python3.11/site-packages/autotrader/brokers/oanda.py", line 269, in get_candles
data = self._response_to_df(response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/adminuser/venv/lib/python3.11/site-packages/autotrader/brokers/oanda.py", line 438, in _response_to_df
if self._allow_dancing_bears:
^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Broker' object has no attribute '_allow_dancing_bears'
(autobot.py:239)

TypeError: Indexing a Series with DataFrame is not supported, use the appropriate DataFrame column

Describe the bug
I have tried running the MACD, EMA Crossover, Long EMA Crossover and SMA Crossover strategies but each of them fail with the error TypeError: Indexing a Series with DataFrame is not supported, use the appropriate DataFrame column. I have tried to upgrade all the packages but nothing seems to resolve the issue.

To Reproduce
Steps to reproduce the behavior:

  1. Copy ema_crossover.py
  2. Copy ema_crossover.yaml
  3. In runfile.py add the following:
from autotrader import AutoTrader

# Create AutoTrader instance, configure it, and run backtest
at = AutoTrader()
at.configure(verbosity=1, show_plot=True, feed='yahoo', mode='continuous')
at.add_strategy('ema_crossover')
at.backtest(start='1/1/2021', end='1/1/2022')
at.virtual_account_config(initial_balance=1000, leverage=30)
at.run()

  1. See error

Expected behavior
The backtest completes without error

Additional context
I am using Python 3.8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.