Comments (6)
Hey Lewis, the KeyError
above is popping up because you haven't specified the indicator type
as STOCHASTIC
(the key you have named 'STOCHASTIC' is just the string used to label the indicator on the chart), but you have made me realise that I have actually deprecated the stochastic key, so apologies for the stale docs/code.
The preferred way to plot this would be using type
: multi
, as per the example below.
self.indicators = {"RSI": {"type": "RSI", "data": self.stoch_rsi},
"STOCHASTIC": {"type": "multi",
"K": {"data": self.stoch_rsi_k, "color": "blue"},
"D": {"data": self.stoch_rsi_d, "color": "red"},
},
}
I think I decided to remove the STOCHASTIC type as the multi
type is much more general and customisable, though I probably should have made the change clearer...
As per your other questions:
- Yes, you can do this using the
get_trades
method, with the argumenttrade_status = 'closed'
. This will return all closed trades taken for the instrument/s specified, ordered by time closed (it is basically indexingbroker.trades
. Some notes: this functionality (specific retrieving closed trades) is currently only supported in the virtual broker, ie. in backtesting. To call this method from your strategy, you will need to includeINCLUDE_BROKER: True
in your strategy configuration - see the docs here for an example. - I have a feeling this is due to a margin call occurring, a feature implemented in
v0.6.1
. To check if it is, try increasing thebroker_verbosity
to 1 via theconfigure
method - this will print when a margin call occurs. This should only happen if you are trading on margin (ie. leverage is set greater than 1), and if your margin fraction (available margin/NAV) drops below themargin_call_fraction
. However, I am assuming you will not have changed themargin_call_fraction
from the default of 0, so the only way for this to occur is if your margin available or NAV goes negative. So another check would be to print the NAV each update. If these suggestions don't help, or don't seem relevant, let me know and we can figure out what's going on.
from autotrader.
When using 1 leverage I get Insufficient margin to fill order.
printed for every trade, I am testing it on ETH-USD is this because for a 10,000 account it cannot trade partial amounts with a 1% risk e.g. 1ETH is more than 1%*10000 and with 1 leverage it can't make the trade, therefore, it cancels it
from autotrader.
I can't seem to replicate the issue (tried the macd demo strategy active in the demo runfile), and partial trades are allowed by default.
Looking into the code a bit deeper, I think this is coming from the get_size
method of the broker utilites, and likely the get_pip_ratio
method. The latter method is currently focused towards forex pairs, so might produce unexpected results for non FX instruments. I will need to fix this up to make it more general.
Basically what it looks like is happening, is that your stop losses are too tight (whether true, or not true due to an incorrect pip_value
) forcing the trade size required to risk 1% up too high. This size then gets cancelled when the order reaches the broker, because although the trade would only lose 1% if the stop was hit, the margin required to open such a large trade is greater than the account margin available.
Sorry about the bug, but I can suggest a work around in the meantime: copy the get_size
method into your strategy module, and provide the correct pip_value
(line 82). Then just call this method to calculate the size and provide it when creating your orders.
from autotrader.
Thanks, I will give it a try. I can give you the exact data/strategy if you would like to use it for debugging, its only a simple one
from autotrader.
No problem, let me know how you go. And sure, feel free to email it to me: [email protected]
from autotrader.
It seems to be a problem with RISK_PC using the macd strategy from the demo (latest version) with leverage set to 1 and RISK_PC set to 3 it gets all cancelled trades on EURAUD
and mostly cancelled on ETH-USD
. Might help with debugging.
from autotrader.
Related Issues (20)
- AutoData docs HOT 2
- Can we please get an exact Step-by-Step tutorial of how to set it up with Crypto Exchange? HOT 1
- Crash raise ValueError("No objects to concatenate") HOT 2
- Crash: IndexError: only integers, slices (`:`), ellipsis (`...`),
- Taking profits and leaving runners concept
- Range exception index -1 in indicator method unroll_signal_list
- Plot Error when running backtest on multiple pairs HOT 1
- Not clear how to login, needing simple example template HOT 2
- multi-time frame data not working
- \
- help with issue HOT 1
- 'Index' object has no attribute 'tzinfo', and so on ~ HOT 1
- Running paper trade mode in Oanda
- Display statistics in backtesting mode
- Peer closed connection. clientId 3 already in use?
- Integrate existing indicator library HOT 2
- Custom xml plot path
- Help beginners run the project locally HOT 5
- Divergencies not plot again HOT 1
- Can't use crypto exchange as feed?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autotrader.