S#

Can you please explain about this code line?


Can you please explain about this code line?
Atom Reply
6/17/2019


Hello Stocksharp team.

Can you please explain in detail what's the meaning of this line?

https://github.com/Stock...ting/SmaStrategy.cs#L109

Here what "Position", "Volume" means for?

As long as I understand, position means this one?
https://www.investopedia...erms/o/open-position.asp

Thanks



Thanks:




7 Answers
Support

Avatar
Date: 6/17/2019
Reply


Position means this one https://www.investopedia...rms/p/positiontrader.asp

Volume is parameterizable option. You can skip it is your code, but in that case size of your trading algo will be hard coded.
Thanks:

Pandotex

Avatar
Donator
Date: 6/17/2019
Reply


I can understand "Volume is parameterizable option". but I still don't understand that line. Would you please elaborate more?

`var volume = Position == 0 ? Volume : Position.Abs().Min(Volume) * 2;`

"Position == 0" means, there are no active orders for selected security?
Why they're comparing to find min value like "Position.Abs().Min(Volume)"? After that why they're multiplying by 2?
Topic starter
Thanks:

Pandotex

Avatar
Donator
Date: 6/17/2019
Reply


I assume that that "SmaStrategy.cs" only works with spot trading (no margin or leverage trading).
Given that it is true, I don't understand why we use "position" term here.
Because as long as I understand, "position" term (open position, long position, short position) are only being used in leverage trading.
Topic starter
Thanks:

Support

Avatar
Date: 6/17/2019
Reply


The line mean Revert position. For this operation required double time position with opposite sign. To convert for example 5 position to -5 we need 10 sell order. Min is just modification. You can remote it (remember that is just examples).

SMA works with any market. It depends from connectors, but not from algo.

Orders are not affected on positions. Only trades.

Short positions can possibly on markets or brokers that allow that.



Thanks:

Pandotex

Avatar
Donator
Date: 6/18/2019
Reply


Thanks for your explanation.
But I still don't understand "Position" here.
Lets say `Position=5` in here. Then what does it mean for? (selected security is BTC/USDT)
Then it means that I own 5 BTC?
Topic starter
Thanks:

Pandotex

Avatar
Donator
Date: 6/18/2019
Reply


Following up previous question, if "Position=-5" here, then what does it mean?
Does it mean that I have 5 USDT in my account of exchange website?
Topic starter
Thanks:

Support

Avatar
Date: 6/20/2019
Reply


Position 5 means 5 BTC in most of popular exchanges. Minus position are possible for crypto exchanges with future contracts. For margin trading it is not allowed and you need modify the algorithm.
Thanks: Pandotex


Attach files by dragging & dropping, , or pasting from the clipboard.

loading
clippy