I want to run some AmiBroker APX every day in batch processing. So this process is entirely automated and there is no manual step. These APX use different databases with different sets of symbols. The currency symbols are also different in these databases. The APX are intended for different base currencies and some make usage of "Trade using FX cash conversion" and some do not.
So I need different settings in Currencies tab of preferences dialog for different APX files.
I was thinking about copying a broker.prefs for each APX to the AmiBroker installation in the batch but I am not sure whether this is a recipe for disaster... I would feel more comfortable if there is a controlled way through AmiBroker to change this preferences.
Does somebody have an idea how to solve this problem with AFL or maybe OLE/COM?
Really no ideas on this? I am wondering whether I am the first one with this issue...
It would be fantastic if each DB could have its own currency symbol table. But alas, this is not so.
I workaround this by using the IBdictionary.txt file as well as the Alias field. But I only use IBKR and Norgate so it's not too complex. I use the Norgate symbology, even in my IBKR DB, and use the Alias field and the dictionary file for the actual IBKR symbol.
Swapping out broker.prefs sounds dangerous. You could consider running multiple Windows user accounts or Kubernetes containers.
Well, swapping broker.prefs is not really dangerous if the only thing you change is just currency table. Just do that when AmiBroker is closed.
so I will give this a try and copy the correct broker.prefs before running the APX script. I will also keep some backups of broker.prefs
It would be fantastic if each DB could have its own currency symbol table.
I agree this would be a good feature. However, I think it will still lack some functionallity. Honestly I also don't know the perfect solution... For example the checkbox "Trade using FX cash conversion" should not be tied to the database because it can change from one APX to another APX. So at least this option should move to the APX and it should be possible to set it with AFL function SetOption(). I can also imagine scenarios where you want to use a different currency price series for the same curreny pair. For example if you calculate your own EUR/USD price series including swap and you want to use that one for some of the APX files and database standard EUR/USD for others.
Maybe the best solution would be an unlimited list of currency settings stored in the database like the watchlists. Then it would be possible to create a currency setting for each use case, give it a name and choose it for the APX with a dropbox from the GUI or SetOption() from the AFL code. If each setting is stored in its own file (simple csv will do), than it could be transfered to other installations by just a copy like a watchlist.
Please note that RIGHT NOW, each database CAN have its "own currency table".
Just do the following:
- instead of fixed rate, use DYNAMIC RATE. FX symbols are defined in the preferences
- now EACH DATABASE separately can have its own data in symbols defined as "dynamic rate symbols" - and they will be used for this and only this database.
If you have problem with naming conventions used by plugins, you can always use ALIAS field
I would only need to make ONE CHANGE in AmiBroker (allowing Alias to be used for multi-currency backtest, because right now it only uses main symbol)
I will also move "Trade using FX cash conversion" to per-Analysis setting
just an additional idea to your posted picture.
What do you think about a drop down menu to save/apply per "Base Currency" templates of tables?
Well I would say that individual user has one (his own country's) base currency. If multiple are needed then one could use 2 installations with separate prefs files, or just two different "start in" folders.
Thank you for your support. I have to think about your ideas and also have to talk to other AB developers I know who have similar issues like me. But what I can say at the moment:
- Moving the "Trade using FX cash conversion" to the APX analysis file is welcomed.
- The additional check to the alias field will not hurt but in one of my databases the symbol is an arbitrary number which only the database vendor uses and nobody else. So I have to use the alias field to store the ISIN to have a connection from the database to the real world. Therefore Alias will not solve my problem with different currency symbols in that database.
- I understand that current AB beeing in the state of a release candidate there is not much room for major changes. Any minor change is still helpfull and appreciated. Maybe major changes can be implemented in next release whatever these major changes may be...
- Maybe this idea is a minor change and can be implemented easily. Add these features to the current Currency Settings dialog:
** Move the "Trade using FX cash conversion" to the APX analysis file as suggested.
** It should be possible to store multiple entries for a currency pair. For example if base currency is USD and trade currency is EUR then it should be possible to enter one line with "Currency" = "EUR" and "Dynamic rate symbol" = "EURUSD" and another line with "Currency" = "EUR" and "Dynamic rate symbol" = "1234567" (and maybe some more lines for other dynamic symbols of other databases in use). AB will use the first symbol found. So if symbol "EURUSD" is not in the database (including unsuccessfull search for alias) AB will go to the next line and check for "1234567" and so on until a symbol or alias is found.
** Because the sorting of the lines is important in that szenario there should be some features to sort or group the lines for columns with 1st and 2nd order (Currency, Dynamic rate symbol) and also to move certain lines manually up and down.
There is still an issue with the base curreny. I understand your argument with an user having a personal (= single) base currency and this will be true for most AB users. But in real life its possible that you run different APX files for different portfolios and each portfolio has its own base currency. However I also understand that moving base currency to the APX file might be a major change to AB because this may completely change the way how trades with FX conversions are executed in AB.
Sorry for my English but I hope I could explain my ideas good enough to understand what I mean.
I talked to some colleagues and we think there might be an even more simple solution which fits at least our needs (other needs may differ):
Just make it possible to override all settings in the currency dialog with AFL functions like SetOption() does already for analysis files.
I don't know the depth of AB coding for the fx exchange but I can imagine that just setting the values of the dialog (base currency, trade using FX cash conversion, exchange rate settings for a currency) with AFL function would not be much different from setting these data manually and thus it should not affect AB coding very much. On our side we would have complete flexibility in AFL for each APX.
However I think, the AFL changed settings should not be persisted in broker.prefs after AB closes or at least that should be an optional feature in the function call. Maybe it is also a good idea to highlight that this function changes AB preference settings and therefore use a special name like SetPreference which should be accompanied by corresponding GetPreference function.
So the API could look like
SetPreference("BaseCurrency", string CurrencySymbol, float Persist);
SetPreference("TradeUsingFXCashConversion", float OnOff, float Persist);
SetPreference("ExchangeRate", string Currency, float FixedRate, string DynamicRateSymbol, float Multiplier, float Inverse, float Persist);
This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.