Some hedging examples
This commit is contained in:
parent
c7a8c724ee
commit
3a8bc6420f
@ -132,7 +132,9 @@ BUY 10 SHARES OF "QQQ_TOKEN"
|
||||
FROM "CryptoExchange"
|
||||
```
|
||||
|
||||
### BUY Trigger for above
|
||||
## Hedging
|
||||
|
||||
### BUY Trigger for the above examples
|
||||
```
|
||||
BUY 1 SHARES OF "QQQ"
|
||||
FOR CURRENT_PRICE( "StockExchange", "QQQ" )
|
||||
@ -140,53 +142,7 @@ BUY 1 SHARES OF "QQQ"
|
||||
FOR EVERY 1 SHARES OF "QQQ_TOKEN" SOLD FROM "CryptoExchange"
|
||||
```
|
||||
|
||||
|
||||
### SELL Trigger for the above examples
|
||||
```
|
||||
[In reply to Penguin]
|
||||
#Code example:
|
||||
"""
|
||||
set the maximum amount($USD) of QQQ tokens i can sell to traders as [my max position]
|
||||
"""
|
||||
set [my max position$]=[$1000]
|
||||
|
||||
"""set the amount($USD) of sold QQQ token as $0 becoz i havent sold any QQQ tokens before i start my bot
|
||||
"""
|
||||
set [total$].[sold QQQ token] =0
|
||||
|
||||
"""
|
||||
The quantity of the sell order quote i can send to the market is the remaining amount of [my max position], which is [max]-[total].[sold]
|
||||
initially,
|
||||
[my max position$]=$1000,
|
||||
[total$].[sold QQQ token]=0,
|
||||
remaining token=
|
||||
[my max position$] - [total$].[sold QQQ token]=$1000-0=$1000
|
||||
so,
|
||||
[remain$]
|
||||
=[my max position$] - [total$].[sold QQQ token]
|
||||
"""
|
||||
|
||||
#get price quote from the nasdaq
|
||||
[get][QQQ etf price$] from [ib]
|
||||
|
||||
while [total$].[sold QQQ token]
|
||||
<[my max position$]
|
||||
"""find my remaining amount($USD)
|
||||
of qqq tokens i can sell
|
||||
"""
|
||||
[remain$]=
|
||||
[my max position$] - [total$].[sold
|
||||
QQQ token]
|
||||
|
||||
"""convert the remaining
|
||||
amount($USD) to number of shares
|
||||
of qqq tokens i can sell
|
||||
"""
|
||||
[share].[remain$]=
|
||||
[remain$] / [QQQ etf $price]
|
||||
|
||||
#set my Bid Ask spread
|
||||
[price].[Bid]=
|
||||
[QQQ etf $price] - [spread]/2
|
||||
[price].[Ask]=
|
||||
[QQQ etf $price] + [spread]/2
|
||||
???
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user