Jump to content
KyleK29

DAS - Dynamically Calculate Shares on %Risk or $Risk - Hot Key + Configuration, Updated 8/8/19, v2.00

Recommended Posts

Nice!! Thanks for putting in the time and work to take the script one step further 👍 

Share this post


Link to post
Share on other sites

Holy smokes. You are super smart sir.

I'm brand new and struggling to understand the setup of my initial Hotkeys. This provided version of yours is incredible. Thank you.

Now, if I can only figure out how to program this darn Genovation 24 keypad...but I digress.

seamus

Share this post


Link to post
Share on other sites

Great work @KyleK29 thank you!...

On 9/28/2018 at 1:37 PM, KyleK29 said:

I have a version that uses an AutoHotKey macro to drop a line at the stop location, I can upload that as well if people want it.

I´d like to take a look at this version...

Share this post


Link to post
Share on other sites
On 9/29/2018 at 11:07 AM, Seamus said:

Holy smokes. You are super smart sir.

I'm brand new and struggling to understand the setup of my initial Hotkeys. This provided version of yours is incredible. Thank you.

Now, if I can only figure out how to program this darn Genovation 24 keypad...but I digress.

seamus

Ha, I wouldn't go that far. 

I don't have experience with the Genovation, but a quick glance ( https://store.genovation.com/programmables/cp24-usbhid.html ) tells me it's writing the hotkey command to the hardware memory (so you don't need the driver once you config it). Have you installed the config software for it? 

On 9/30/2018 at 10:29 AM, Abiel said:

Great work @KyleK29 thank you!...

I´d like to take a look at this version...

Give me a little while to test it, I've made a few modifications. Right now it's literally just doing this type of operation (in AHK script language):

IF Active Window = Das Trader Pro
Send RAYLINE Command
Left-Mouse Click
Move Mouse 4px to the right
Left-Mouse Click
Double-Click Left Mouse
Send ORDER Hotkey Command

I use the RayLine because A) I never use it (so I can assign a RED color to it) and B) it allows you to get the longest line without moving them mouse a lot. The difference in order procedure is that you have to HOVER over where you want to place the stop as it does the double-click for you.

 

Share this post


Link to post
Share on other sites

Kyle. 

Appreciate the reply and quick dive on your part into Genovation. I believe that yes, installs are complete. I understand the hotkey creation in DAS without any real issue, so I believe I’ve the handle on basic practice. I’m stuck on what I’d call mapping or quite possibly, I don’t fully understand the Genovation (external keypad) concept. 

A conventional “buy now at +.05” assigned to F1 makes sense. The Geno keypad doesn’t have an F1 and for the matter, it doesn’t appear any key is fixed to the system. I also cannot locate a cell or placement in the setup Geno software where I would establish say, the top left key is recognized by the system as F1 and thus, maps the command when said Geno button is pressed. I’m pretty certain I am making the situation quite complicated.

The trading theory currently studied is rather intuitive in my brain, programming...not so much. 

Thanks again man for the reply. 

Share this post


Link to post
Share on other sites

This is awesome - can't wait to try it out! I've been doing this calculation manually via a scripted webpage I created. Genius use of variables as well as utilizing the double click to set the Stop distance! 

Share this post


Link to post
Share on other sites

This is brilliant. I am going to define my hotkeys using your script template and try it in my simulator (this is my 2nd week in the simulator). 

I think there is one caveat of the script which I describe below. Please correct me if I am wrong.

When calculating the number of shares one could afford with current account buying power:(e.g. DefSahre = BP*0.98), your script would be using the "stop loss" price instead of actual bid/ask price. This difference would lead to not having enough buying power when going for a long position with current account buying power. I guess you must have realized that and hence set 98% of total buying power as default. I could not think of an easy way to deal with this issue as we do need the stop loss price in the calculation. But I think this could be listed as "know issues" of the script to warn potential users. 

(Additional note: DefSahre = BP*0.98: This was confusing to me at first: how could buying power ($) multiple 0.98 is equal to share number?. After I checked the Dastrader manual and realized that it was actually calculating BP*0.98/Price. This was really Dastrader's fault. I share this here in case other users had the same confusion.)

Share this post


Link to post
Share on other sites
1 hour ago, Jason W said:

Thanks again for this amazing script.  

 

I download this sheet as .xlsx on my computer, it needs to ENABLE EDITING to change the value. But after I enable editing, the spreadsheet stop working.  

 

Is there anyway to fix this ? 

 

Thank you 

reference isn't valid.png

reference isn't valid 2.png

I had the same issue. It seemed to me that the calculations only work in the google spreadsheet. 

Share this post


Link to post
Share on other sites

Yo IB requires 25% for margin so it 4:1 on long, but 30% for margin on short, so that's 3.33333:1 on short ?

So if we gonna do a short script with 1% risk  , is this the correct script ?

DefShare=BP*0.98; Share=DefShare*0.333333333333333* Price * 0.01; Price = Price - Bid + 0.02;SShare = Share / Price; Share = DefShare - SShare; DefShare = DefShare + SShare; SShare = Share; SShare = DefShare - SShare; Share = 0.5 * SShare; TogSShare; ROUTE =LIMIT; Price = Bid - 0.05; TIF=DAY+; SELL=Send; DefShare = 500;

                                     

or is it Share=DefShare*0.3* Price * 0.01 ?

Thanks again man !!

Share this post


Link to post
Share on other sites
On 10/3/2018 at 5:41 PM, Seamus said:

Kyle. 

Appreciate the reply and quick dive on your part into Genovation. I believe that yes, installs are complete. I understand the hotkey creation in DAS without any real issue, so I believe I’ve the handle on basic practice. I’m stuck on what I’d call mapping or quite possibly, I don’t fully understand the Genovation (external keypad) concept. 

A conventional “buy now at +.05” assigned to F1 makes sense. The Geno keypad doesn’t have an F1 and for the matter, it doesn’t appear any key is fixed to the system. I also cannot locate a cell or placement in the setup Geno software where I would establish say, the top left key is recognized by the system as F1 and thus, maps the command when said Geno button is pressed. I’m pretty certain I am making the situation quite complicated.

The trading theory currently studied is rather intuitive in my brain, programming...not so much. 

Thanks again man for the reply. 

Yeah, I'm not physically familiar with the device, from what I've read about it, it will flash a key-combination to the button (I believe each button can have an A and B mode). That is stored on the devices EEPROM (hardware memory) and then it sends that stored hot-key to the PC via the USB as that key. This way it can be used without driver software (moved to another PC). 

See the attached screenshot -- From the looks of it, you run the "Genovation MacroMasterCPxx (CP24)" software and then:
1) Select the key you want to program (#1 on the screen)
2) Select the level you want (since each key can have two operations stored), #2 in the image.
3) Select the key combination, in this example I selected SHIFT + CTRL + A (see #3 and #4)
4) Save the file. I'd imagine you have to flash this file some how, but I don't have the hardware.
5) The rest is done in DAS.

I wouldn't use the F13-F24 keys as DAS doesn't appear to support them. 

InkedGenovation_MacroMasterCPxx_(CP24)_MacroMasterCPxx_2018-10-10_18-14-59_LI.jpg

Share this post


Link to post
Share on other sites
On 10/6/2018 at 5:07 PM, jimguo22bbt said:

This is brilliant. I am going to define my hotkeys using your script template and try it in my simulator (this is my 2nd week in the simulator). 

I think there is one caveat of the script which I describe below. Please correct me if I am wrong.

When calculating the number of shares one could afford with current account buying power:(e.g. DefSahre = BP*0.98), your script would be using the "stop loss" price instead of actual bid/ask price. This difference would lead to not having enough buying power when going for a long position with current account buying power. I guess you must have realized that and hence set 98% of total buying power as default. I could not think of an easy way to deal with this issue as we do need the stop loss price in the calculation. But I think this could be listed as "know issues" of the script to warn potential users. 

(Additional note: DefSahre = BP*0.98: This was confusing to me at first: how could buying power ($) multiple 0.98 is equal to share number?. After I checked the Dastrader manual and realized that it was actually calculating BP*0.98/Price. This was really Dastrader's fault. I share this here in case other users had the same confusion.)

 

Yes, that's the reason for the 0.98%. I'm sure if you set a really large stop price, you could effectively run out of buying power. And yes, that DAS calculation confused me at first because I didn't realize the BP function was converting to shares.

 

On 10/7/2018 at 7:57 PM, Jason W said:

Thanks again for this amazing script.  

 

I download this sheet as .xlsx on my computer, it needs to ENABLE EDITING to change the value. But after I enable editing, the spreadsheet stop working.  

 

Is there anyway to fix this ? 

 

Thank you 

I haven't tested it in Excel. It's probably messing up on SHEETS Validation functions as they may not be compatible with that of Excel's. 

 

22 minutes ago, Jason W said:

Yo IB requires 25% for margin so it 4:1 on long, but 30% for margin on short, so that's 3.33333:1 on short ?

So if we gonna do a short script with 1% risk  , is this the correct script ?

DefShare=BP*0.98; Share=DefShare*0.333333333333333* Price * 0.01; Price = Price - Bid + 0.02;SShare = Share / Price; Share = DefShare - SShare; DefShare = DefShare + SShare; SShare = Share; SShare = DefShare - SShare; Share = 0.5 * SShare; TogSShare; ROUTE =LIMIT; Price = Bid - 0.05; TIF=DAY+; SELL=Send; DefShare = 500;

                                     

or is it Share=DefShare*0.3* Price * 0.01 ?

Thanks again man !!

Are these numbers set in DAS as well? With that in mind, if DAS does know the your buying power for long is different than short, then it should work. You can use either 0.33333333333 (<--- sheets defaults to 15 places) or 0.33 (33%) or 0.3 (30%). It won't make too big of a difference.

I haven't thought of having mixed values for long / short. What you could do is either test it in SIM or use one of the test stock symbols, I believe TEST is one of them (it's a dummy symbol for testing things). Let me know what you find out and if it calculates correctly. 

Share this post


Link to post
Share on other sites

I'm not even sure if DAS knows the difference. Because DAS does not separate long BP  and short BP 

If DAS does not know the difference, then the value should still be 0.25 right ?

If DAS knows the difference, then 0.3 is fine. 

There is no way to test this in the SIM, SIM has the same buying and shorting power I think. 

So I'm gonna have to take one for the team .....   

Thanks again Kyle. 

Share this post


Link to post
Share on other sites
13 hours ago, Jason W said:

I'm not even sure if DAS knows the difference. Because DAS does not separate long BP  and short BP 

If DAS does not know the difference, then the value should still be 0.25 right ?

If DAS knows the difference, then 0.3 is fine. 

There is no way to test this in the SIM, SIM has the same buying and shorting power I think. 

So I'm gonna have to take one for the team .....   

Thanks again Kyle. 

I wouldn't take one for the team  testing it, use a NASDAQ testing symbol. It sends the order in to the market, but they don't actually fulfill with anything (as it's not a real company). These: TEST TESTB TESTE TESTX ATEST

Additionally, a few different ways to test it to wait until the market closes and switch the "SELL=SEND;" to "SELL=LOAD;", click a price really close to the current. See what it puts in the share box, as that's likely to be the maximum-affordable calculation. That's how I tested a lot of it, with the market closed you don't have to worry about the price jumping around and can consistently click different stop distances (e.g. .10c back, .20c back) to see what it is calculating.

I assume that DAS is likely using the buying power for long for both calculations (since it doesn't know you're planning to go short when it loads the values), so you'd need to factor that into the hotkey, 0.33 should be the right number on the short side.

**EDIT**

I think I may have figured out how to go about this:

Example Numbers:
Equity: $25,000
Buying Power Long 4:1 - $100,000 : $25,000
Buying Power Short 3:1 - $75,000 : $25,000

Assuming $10 stock and that DAS is going to use the LONG number for both:
BP = 100,000 / $10 = 10,000 "Shares"
10,000 * 0.25 [equity] = 2,500 [at account equity]


BP * 0.75 = 75,000 / $10 = 7,500 "Shares"
7,500 Shares * 0.33 [equity] = 2,475

 

So try this:
 

DefShare=BP*0.73; Share=DefShare*0.333333333333333* Price * 0.01;

That opening DefShare=BP*0.73 is saying "Calculate using 73% of Buying Power [assuming it's using the LONG number]" (It's 75% minus 2% for a buffer for price fluctuations/spreads).
 

Please let me know if you test it and if it works or not. If it does, I'll add it to the configuration and instructions.

Edited by KyleK29
  • Like 1

Share this post


Link to post
Share on other sites
On 10/3/2018 at 5:41 PM, Seamus said:

Kyle. 

Appreciate the reply and quick dive on your part into Genovation. I believe that yes, installs are complete. I understand the hotkey creation in DAS without any real issue, so I believe I’ve the handle on basic practice. I’m stuck on what I’d call mapping or quite possibly, I don’t fully understand the Genovation (external keypad) concept. 

A conventional “buy now at +.05” assigned to F1 makes sense. The Geno keypad doesn’t have an F1 and for the matter, it doesn’t appear any key is fixed to the system. I also cannot locate a cell or placement in the setup Geno software where I would establish say, the top left key is recognized by the system as F1 and thus, maps the command when said Geno button is pressed. I’m pretty certain I am making the situation quite complicated.

The trading theory currently studied is rather intuitive in my brain, programming...not so much. 

Thanks again man for the reply. 

Also, take a look at this thread: 

Appears there might be an issue with the Windows 10 drivers, so you have to use Flash Drive mode for programming. They'll be able to help a tad more, as they have the device.

 

Edited by KyleK29

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site, you agree to our Terms of Use, Privacy Policy and use of We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..