Creating/using a synthetic asset

Posted By: Zheka

Creating/using a synthetic asset - 01/27/22 01:06

I would like to create several synthetic assets, say, a Dollar index, Euro index, etc - and do so as:
Code
assetAdd("USD");

var prc;

while(asset(of("EUR/USD", "GBP/USD", "AUD/USD")) {
   prc+=priceC();
}

asset("USD");
priceSet(0, prc, prc,prc,prc);
This - as is - doesn't work, as Zorro requires some valid price history for "USD" (zero-length files or using #USD are not useful).

So, 2 questions:

1) is there a way to create such 'assets' on the fly without having to pre-generate some dummy t6 files? (and if not at the moment - can such a way be provided)

2) how to avoid such synthetic 'assets' being 'subscribed to' by Zorro in Live trading?

Thank you.
Posted By: jcl

Re: Creating/using a synthetic asset - 01/27/22 13:22

For assets with no data, use 3 empty symbols, like "!!!", in the asset list.

But if the price is completely synthetic, you need no asset at all. Just the price series.
Posted By: Zheka

Re: Creating/using a synthetic asset - 01/27/22 14:42

I would like to use 'asset structs' for storing such synthetic price series for all the out-of-the-box convenience and seamless interface of the usual 'named' assets: accessing prices, AssetVars, etc..

I added "USD" explicitly to the asset list with "!!!" for Symbols : Zorro complains of no prices in the init run and then ignores such asset.

- I tried to create some dummy t6 files with 1 record per year -> 'not enough ticks', says Zorro, and ignores the asset

- put "!!!EUR/USD" in the Symbols field - > Zorro - for some reason - returns "USD" as SymbolHist -> and ignores such asset (i.e. the last used asset remains 'active')
Posted By: Spirit

Re: Creating/using a synthetic asset - 01/28/22 14:01

The history symbol is the third, so it would be "!!EUR/USD" for loading the history of EUR/USD.

I think there is no symbol that can prevent a history of an asset, otherwise probably the price functions would crash when that asset is selected. "!!!" prevents live prices.
Posted By: Petra

Re: Creating/using a synthetic asset - 01/29/22 10:51

I believe asset("#USD") creates an asset with no history. I don't have this in the documentation so no guarantee, but I've seen it in some scripts. Try it. Otherwise, asset("") creates a dummy asset with artificial history.
Posted By: Zheka

Re: Creating/using a synthetic asset - 01/29/22 12:13

This is mentioned in the manual and I tried it. Unfortunately, priceSet() will then not work.

@Spirit: !!EUR/USD does not work. Probably a bug because EUR/USD!! correctly recognizes SymbolTrade as EUR/USD and ! EUR/USD ! correctly gives SymbolLive as EUR/USD, but with !!EUR/USD - all 3 Symbolxx are just USD.

Also:
Quote
Symbol - Symbol(s) of the asset. Up to 3 sources and symbols can be entered for trading, live prices, and historical prices, separated by '!' exclamation marks (!trade!live!history).
seems incorrect: there should be no ! prior to the very first symbol

Quote
If several symbols are used and one of them is blank or empty (f.i. "AAPL! !"), the prices of that asset are not downloaded or retrieved from the broker. This can be used in special cases when no market data was subscribed or prices are retrieved by other means, f.i. with the assetHistory or priceQuote functions.
So, is it several or one (as in the example)?
Posted By: Petra

Re: Creating/using a synthetic asset - 01/29/22 13:56

A symbol "!!EUR/USD" will not trade, not get live prices, and get "EUR/USD" history from the broker. Look here:

https://manual.zorro-project.com/symbol.htm

Symbols are for brokers in live trading. Not for files on your PC. That has maybe confused you? The history files on your PC are always expected with the asset name. There is no extra symbol for "PC file names".

priceSet cannot work when an asset has no history because its purpose is to store prices in the history.

What you probably need is a dummy asset, like asset(""). A dummy asset has a history filled with default prices. You can then overwrite them.

Look in the manual, there was an example of dummy assets for the "genSine" function for artificial price curves.


Posted By: Zheka

Re: Creating/using a synthetic asset - 01/29/22 15:51

Ah, ok, i see (but !!EUR/USD still does not set SymbolHist to EUR/USD).

There can only be one 'dummy' asset, and I would like to have 5-6 'indices', for majors...Such capability should come very handy for creating bespoke stock sectors, indicators,etc.
Posted By: Petra

Re: Creating/using a synthetic asset - 01/30/22 14:10

Makes sense. I've forwarded it to the developers. The undocumented "#..." asset names will become dummy assets and we will also check the SymbolHist issue.
Posted By: Zheka

Re: Creating/using a synthetic asset - 01/30/22 16:42

"#name" does seem to be documented:
asset():
Quote
Name - The name of the asset, as in the asset list or the [Asset] selector. An empty string "" creates a dummy asset, a name beginning with '#' prevents loading price history.
Asset Lists:
Quote
The asset is ignored when the name begins with a hash character "#".
This also requires a clarification:
Quote
If several symbols are used and one of them is blank or empty (f.i. "AAPL! !"), the prices of that asset are not downloaded or retrieved from the broker.
(..is it one or several??)
Posted By: jcl

Re: Creating/using a synthetic asset - 01/31/22 11:54

A # at the begin of a CSV line is just a comment character. It comments out the whole line.

A # in asset() selects the asset, but does not load or create history. For your multiple dummy assets, we'll change it so that flat history is instead created.

I do not understand that "several symbols" quote either. I'll reword that in the manual.
Posted By: Zheka

Re: Creating/using a synthetic asset - 01/31/22 12:27

Originally Posted by jcl
For your multiple dummy assets, we'll change it so that flat history is instead created.
great, thanks!
So, the usage will be: asset("#USD"); ....priceSet()....and "!!!" in the Symbols field of an asset list to prevent requests to the broker?
Posted By: jcl

Re: Creating/using a synthetic asset - 02/01/22 15:20

A symbol won't be needed, dummy assets are not in the asset list and don't send broker requests anyway.
© 2024 lite-C Forums