Category Archives: ChatGPT

Writing

ChatGPT at it’s finest: writing short helpful code

ChatGPT at it’s finest: writing short helpful code without having to do fancy work.

The following is a dialog with ChatGPT. I had this script that I would normally have to hand edit all of the ticker  symbols by adding them to the end of the lines of code. I am sure there is some clever way using sed or awk but, I figured why not get ChatGPT to help.

ChatGPT then was also able to generate the Tags for this post,by feeding the post into a prompt and I used Stable Diffusion to generate the featured image using the blog title as the prompt. Sometimes it is good to use ChatGPT to proofread as well but, this post was short and simple enough not to do that.


User

I want to show you an output, in the left column are the ticker symbols for a number of cryptocurrencies, I want you to remember all of them as they will be used in the next question that I will pose…..

Currency  Price      Available  Hold      Avail in USD  Held in USD
AAVE 98.16          0.0 0.0              0.0
ACH 0.020353          0.0 0.0              0.0
ADA 0.3859          0.0 0.0              0.0
ALGO 0.1341          0.0 0.0              0.0
AMP 0.00248          0.0 0.0              0.0
ANKR 0.0244          0.0 0.0              0.0
ATOM 9.283          0.0 0.0              0.0
AVAX 20.66          0.0 0.0              0.0
AXS 6.8          0.0 0.0              0.0
BAL 3.68          0.0 0.0              0.0
BAND 1.417          0.0 0.0              0.0
BAT 0.21159          0.0 0.0              0.0
BCH 223.72          0.0 0.0              0.0
BNT 0.75          0.0 0.0              0.0
BOND 2.2          0.0 0.0              0.0
BTC 37964.39          0.0 0.0              0.0
CGLD 0.53          0.0 0.0              0.0
COMP 51.17          0.0 0.0              0.0
CRV 0.5658          0.0 0.0              0.0
CVC 0.1102          0.0 0.0              0.0
DAI 0.9999          0.0 0.0              0.0
DOGE 0.08033          0.0 0.0              0.0
DOT 5.263          0.0 0.0              0.0
ETC 18.86          0.0 0.0              0.0
ETH 2054.84          0.0 0.0              0.0
FARM 32.73          0.0 0.0              0.0
FET 0.5347          0.0 0.0              0.0
FIL 4.545          0.0 0.0              0.0
GLM 0.2418          0.0 0.0              0.0
GRT 0.1483          0.0 0.0              0.0
ICP 4.605          0.0 0.0              0.0
KNC 0.7065          0.0 0.0              0.0
LINK 14.588          0.0 0.0              0.0
LOOM 0.0673          0.0 0.0              0.0
LPT 6.33          0.0 0.0              0.0
LRC 0.216          0.0 0.0              0.0
LTC 69.78          0.0 0.0              0.0
MANA 0.4405          0.0 0.0              0.0
MATIC 0.7528          0.0 0.0              0.0
MIR 0.0941          0.0 0.0              0.0
MKR 1483.6          0.0 0.0              0.0
MLN 15.12          0.0 0.0              0.0
NKN 0.1064          0.0 0.0              0.0
NMR 15.68          0.0 0.0              0.0
OGN 0.12922          0.0 0.0              0.0
OMG 1.7217          0.0 0.0              0.0
OXT 0.0724          0.0 0.0              0.0
PLA 0.204          0.0 0.0              0.0
POLY 0.1963          0.0 0.0              0.0
QNT 99.56          0.0 0.0              0.0
REN 0.0823          0.0 0.0              0.0
REQ 0.083          0.0 0.0              0.0
RLC 1.4794          0.0 0.0              0.0
RLY 0.0126          0.0 0.0              0.0
SKL 0.0436          0.0 0.0              0.0
SNX 3.392          0.0 0.0              0.0
SOL 58.2          0.0 0.0              0.0
STORJ 0.7658          0.0 0.0              0.0
UMA 1.953          0.0 0.0              0.0
UNI 6.161          0.0 0.0              0.0
USD              0.01 0.0
USDC              0.0 0.0
XLM 0.118572          0.0 0.0              0.0
XTZ 0.817          0.0 0.0              0.0
YFI 8519.94          0.0 0.0              0.0
ZEC 29.03          0.0 0.0              0.0
ZRX 0.39338          0.0 0.0              0.0

I don’t have the ability to remember information from one interaction to the next, but I can certainly help you analyze or work with the data you’ve provided in this session. If you have a specific question or task related to this cryptocurrency data, feel free to let me know, and I’ll do my best to assist you!

User

Can you print out all of the symbols in the left column?

Certainly! Here are all the ticker symbols from the left column:

objectivec
AAVE, ACH, ADA, ALGO, AMP, ANKR, ATOM, AVAX, AXS, BAL, BAND, BAT, BCH, BNT, BOND, BTC, CGLD, COMP, CRV, CVC, DAI, DOGE, DOT, ETC, ETH, FARM, FET, FIL, GLM, GRT, ICP, KNC, LINK, LOOM, LPT, LRC, LTC, MANA, MATIC, MIR, MKR, MLN, NKN, NMR, OGN, OMG, OXT, PLA, POLY, QNT, REN, REQ, RLC, RLY, SKL, SNX, SOL, STORJ, UMA, UNI, USD, USDC, XLM, XTZ, YFI, ZEC, ZRX

If you have any specific tasks or questions related to these symbols, feel free to let me know!

User

OK, good, you remembered them. Now for the next step. I am going to show an example using btc and I would like you to create a listing with all of the ticker symbols from the left column. Example: $DIR/rsi-fractals-avgs-bbands-txt-summary.py btc

Sure, I understand. If you could provide an example of the desired output or clarify the specific format or information you’re looking for related to each ticker symbol (similar to the example you provided with btc), I’d be happy to assist you further.

User

I am looking for you to create code that has $DIR/rsi-fractals-avgs-bbands-txt-summary.py on every line but with the ticker symbols from the left column appear on that line right after it.

Certainly! It sounds like you want a list of commands where $DIR/rsi-fractals-avgs-bbands-txt-summary.py is followed by each ticker symbol. Here’s an example Python script that generates those commands:

python
# List of ticker symbols ticker_symbols = [     "AAVE", "ACH", "ADA", "ALGO", "AMP", "ANKR", "ATOM", "AVAX", "AXS", "BAL",     "BAND", "BAT", "BCH", "BNT", "BOND", "BTC", "CGLD", "COMP", "CRV", "CVC",     "DAI", "DOGE", "DOT", "ETC", "ETH", "FARM", "FET", "FIL", "GLM", "GRT", "ICP",     "KNC", "LINK", "LOOM", "LPT", "LRC", "LTC", "MANA", "MATIC", "MIR", "MKR",     "MLN", "NKN", "NMR", "OGN", "OMG", "OXT", "PLA", "POLY", "QNT", "REN", "REQ",     "RLC", "RLY", "SKL", "SNX", "SOL", "STORJ", "UMA", "UNI", "USD", "USDC", "XLM",     "XTZ", "YFI", "ZEC", "ZRX" ] # Directory variable DIR = "$DIR" # Generate commands commands = [f"{DIR}/rsi-fractals-avgs-bbands-txt-summary.py {symbol}" for symbol in ticker_symbols] # Print commands for command in commands:     
       print(command)

Replace $DIR with the actual directory you want to use. This script will generate commands for each ticker symbol, following the format you provided. If you have any specific adjustments or requirements, feel free to let me know!


OK how did it turn out?

This is the output, just as I expected and was looking for. Saved me probably about 15 minutes of tedious hand editing…

$DIR/rsi-fractals-avgs-bbands-txt-summary.py AAVE
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ACH
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ADA
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ALGO
$DIR/rsi-fractals-avgs-bbands-txt-summary.py AMP
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ANKR
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ATOM
$DIR/rsi-fractals-avgs-bbands-txt-summary.py AVAX
$DIR/rsi-fractals-avgs-bbands-txt-summary.py AXS
$DIR/rsi-fractals-avgs-bbands-txt-summary.py BAL
$DIR/rsi-fractals-avgs-bbands-txt-summary.py BAND
$DIR/rsi-fractals-avgs-bbands-txt-summary.py BAT
$DIR/rsi-fractals-avgs-bbands-txt-summary.py BCH
$DIR/rsi-fractals-avgs-bbands-txt-summary.py BNT
$DIR/rsi-fractals-avgs-bbands-txt-summary.py BOND
$DIR/rsi-fractals-avgs-bbands-txt-summary.py BTC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py CGLD
$DIR/rsi-fractals-avgs-bbands-txt-summary.py COMP
$DIR/rsi-fractals-avgs-bbands-txt-summary.py CRV
$DIR/rsi-fractals-avgs-bbands-txt-summary.py CVC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py DAI
$DIR/rsi-fractals-avgs-bbands-txt-summary.py DOGE
$DIR/rsi-fractals-avgs-bbands-txt-summary.py DOT
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ETC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ETH
$DIR/rsi-fractals-avgs-bbands-txt-summary.py FARM
$DIR/rsi-fractals-avgs-bbands-txt-summary.py FET
$DIR/rsi-fractals-avgs-bbands-txt-summary.py FIL
$DIR/rsi-fractals-avgs-bbands-txt-summary.py GLM
$DIR/rsi-fractals-avgs-bbands-txt-summary.py GRT
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ICP
$DIR/rsi-fractals-avgs-bbands-txt-summary.py KNC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py LINK
$DIR/rsi-fractals-avgs-bbands-txt-summary.py LOOM
$DIR/rsi-fractals-avgs-bbands-txt-summary.py LPT
$DIR/rsi-fractals-avgs-bbands-txt-summary.py LRC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py LTC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py MANA
$DIR/rsi-fractals-avgs-bbands-txt-summary.py MATIC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py MIR
$DIR/rsi-fractals-avgs-bbands-txt-summary.py MKR
$DIR/rsi-fractals-avgs-bbands-txt-summary.py MLN
$DIR/rsi-fractals-avgs-bbands-txt-summary.py NKN
$DIR/rsi-fractals-avgs-bbands-txt-summary.py NMR
$DIR/rsi-fractals-avgs-bbands-txt-summary.py OGN
$DIR/rsi-fractals-avgs-bbands-txt-summary.py OMG
$DIR/rsi-fractals-avgs-bbands-txt-summary.py OXT
$DIR/rsi-fractals-avgs-bbands-txt-summary.py PLA
$DIR/rsi-fractals-avgs-bbands-txt-summary.py POLY
$DIR/rsi-fractals-avgs-bbands-txt-summary.py QNT
$DIR/rsi-fractals-avgs-bbands-txt-summary.py REN
$DIR/rsi-fractals-avgs-bbands-txt-summary.py REQ
$DIR/rsi-fractals-avgs-bbands-txt-summary.py RLC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py RLY
$DIR/rsi-fractals-avgs-bbands-txt-summary.py SKL
$DIR/rsi-fractals-avgs-bbands-txt-summary.py SNX
$DIR/rsi-fractals-avgs-bbands-txt-summary.py SOL
$DIR/rsi-fractals-avgs-bbands-txt-summary.py STORJ
$DIR/rsi-fractals-avgs-bbands-txt-summary.py UMA
$DIR/rsi-fractals-avgs-bbands-txt-summary.py UNI
$DIR/rsi-fractals-avgs-bbands-txt-summary.py USD
$DIR/rsi-fractals-avgs-bbands-txt-summary.py USDC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py XLM
$DIR/rsi-fractals-avgs-bbands-txt-summary.py XTZ
$DIR/rsi-fractals-avgs-bbands-txt-summary.py YFI
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ZEC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ZRX

What’s it for?

It is screener code that will go into a script that prints out all the cryptos in the list sorted by their position relative to their 20 day moving average. It uses the same logic as used for the Mayer Multiple, except it is on a 20 day MA basis.

X = Current Price / 20DMA

Code

#!/bin/bash 
DIR="/home/erick/python/ta"


rm $DIR/output-rsi-er-price-sma20-multiple.csv

$DIR/rsi-fractals-avgs-bbands-txt-summary.py AAVE
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ACH
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ADA
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ALGO
$DIR/rsi-fractals-avgs-bbands-txt-summary.py AMP
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ANKR
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ATOM
$DIR/rsi-fractals-avgs-bbands-txt-summary.py AVAX
$DIR/rsi-fractals-avgs-bbands-txt-summary.py AXS
$DIR/rsi-fractals-avgs-bbands-txt-summary.py BAL
$DIR/rsi-fractals-avgs-bbands-txt-summary.py BAND
$DIR/rsi-fractals-avgs-bbands-txt-summary.py BAT
$DIR/rsi-fractals-avgs-bbands-txt-summary.py BCH
$DIR/rsi-fractals-avgs-bbands-txt-summary.py BNT
$DIR/rsi-fractals-avgs-bbands-txt-summary.py BOND
$DIR/rsi-fractals-avgs-bbands-txt-summary.py BTC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py CGLD
$DIR/rsi-fractals-avgs-bbands-txt-summary.py COMP
$DIR/rsi-fractals-avgs-bbands-txt-summary.py CRV
$DIR/rsi-fractals-avgs-bbands-txt-summary.py CVC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py DAI
$DIR/rsi-fractals-avgs-bbands-txt-summary.py DOGE
$DIR/rsi-fractals-avgs-bbands-txt-summary.py DOT
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ETC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ETH
$DIR/rsi-fractals-avgs-bbands-txt-summary.py FARM
$DIR/rsi-fractals-avgs-bbands-txt-summary.py FET
$DIR/rsi-fractals-avgs-bbands-txt-summary.py FIL
$DIR/rsi-fractals-avgs-bbands-txt-summary.py GLM
$DIR/rsi-fractals-avgs-bbands-txt-summary.py GRT
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ICP
$DIR/rsi-fractals-avgs-bbands-txt-summary.py KNC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py LINK
$DIR/rsi-fractals-avgs-bbands-txt-summary.py LOOM
$DIR/rsi-fractals-avgs-bbands-txt-summary.py LPT
$DIR/rsi-fractals-avgs-bbands-txt-summary.py LRC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py LTC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py MANA
$DIR/rsi-fractals-avgs-bbands-txt-summary.py MATIC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py MIR
$DIR/rsi-fractals-avgs-bbands-txt-summary.py MKR
$DIR/rsi-fractals-avgs-bbands-txt-summary.py MLN
$DIR/rsi-fractals-avgs-bbands-txt-summary.py NKN
$DIR/rsi-fractals-avgs-bbands-txt-summary.py NMR
$DIR/rsi-fractals-avgs-bbands-txt-summary.py OGN
$DIR/rsi-fractals-avgs-bbands-txt-summary.py OMG
$DIR/rsi-fractals-avgs-bbands-txt-summary.py OXT
$DIR/rsi-fractals-avgs-bbands-txt-summary.py PLA
$DIR/rsi-fractals-avgs-bbands-txt-summary.py POLY
$DIR/rsi-fractals-avgs-bbands-txt-summary.py QNT
$DIR/rsi-fractals-avgs-bbands-txt-summary.py REN
$DIR/rsi-fractals-avgs-bbands-txt-summary.py REQ
$DIR/rsi-fractals-avgs-bbands-txt-summary.py RLC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py RLY
$DIR/rsi-fractals-avgs-bbands-txt-summary.py SKL
$DIR/rsi-fractals-avgs-bbands-txt-summary.py SNX
$DIR/rsi-fractals-avgs-bbands-txt-summary.py SOL
$DIR/rsi-fractals-avgs-bbands-txt-summary.py STORJ
$DIR/rsi-fractals-avgs-bbands-txt-summary.py UMA
$DIR/rsi-fractals-avgs-bbands-txt-summary.py UNI
$DIR/rsi-fractals-avgs-bbands-txt-summary.py USD
$DIR/rsi-fractals-avgs-bbands-txt-summary.py USDC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py XLM
$DIR/rsi-fractals-avgs-bbands-txt-summary.py XTZ
$DIR/rsi-fractals-avgs-bbands-txt-summary.py YFI
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ZEC
$DIR/rsi-fractals-avgs-bbands-txt-summary.py ZRX


echo "Cur  ,Und,Targt,RSI, ER,20Ml,Mayer Mult."


# Sort by desending price/sma20 multiples
sort -nk6 -t, -r $DIR/output-rsi-er-price-sma20-multiple.csv

the script runs the rsi-fractals-avg-bbands-txt-summary code on all the tickers listed and saves output to…

output-rsi-er-price-sma20-multiple.csv

then sorts the output by the 20sma multiple column

 

Results

Best relative performers on top, worst on bottom. This idea comes from the book Fortune’s Formula and appears as a technique used by Princeton-Newport. Basically sell the top and buy the bottom ( deep value…maybe), or alternativly short the top and long the bottom. Or in the case of crypto the bottom ones might be just be duds that are always behind the pack, maybe don’t even bother with them.

Cur  ,Und,Targt,RSI, ER,20Ml,Mayer Mult.
UNI  ,USD,False,73,0.06,1.18,1.31
SKL  ,USD,False,63,0.07,1.1 ,1.59
FET  ,USD,False,67,0.14,1.09,1.97
SNX  ,USD,False,63,0.09,1.07,1.43
GRT  ,USD,False,60,0.05,1.07,1.37
AXS  ,USD,False,56,0.0 ,1.07,1.2
AMP  ,USD,False,63,0.05,1.06,1.17
MKR  ,USD,False,60,0.13,1.05,1.34
AVAX ,USD,False,61,0.07,1.05,1.61
RLC  ,USD,False,61,0.01,1.04,1.19
OGN  ,USD,False,56,0.05,1.03,1.33
UMA  ,USD,False,52,0.07,1.01,1.13
NMR  ,USD,False,55,0.02,1.01,1.14
MANA ,USD,False,48,0.01,1.01,1.18
DOGE ,USD,False,55,0.02,1.01,1.15
BTC  ,USD,False,54,0.14,1.01,1.27
REQ  ,USD,False,52,0.02,1.0 ,1.1
NKN  ,USD,False,59,0.02,1.0 ,1.1
ICP  ,USD,False,51,0.04,1.0 ,1.14
FARM ,USD,False,53,0.04,1.0 ,1.31
ETH  ,USD,False,47,0.04,1.0 ,1.13
DAI  ,USD,False,44,0.01,1.0 ,1.0
ATOM ,USD,False,49,0.05,1.0 ,1.09
ADA  ,USD,False,57,0.01,1.0 ,1.25
AAVE ,USD,False,52,0.08,1.0 ,1.38
STORJ,USD,False,46,0.13,0.99,2.0
SOL  ,USD,False,51,0.19,0.98,2.12
ALGO ,USD,False,47,0.06,0.98,1.13
ACH  ,USD,False,51,0.02,0.98,1.07
ZEC  ,USD,False,43,0.04,0.97,1.0
XLM  ,USD,False,43,0.05,0.97,1.03
LTC  ,USD,False,42,0.03,0.97,0.89
LINK ,USD,False,46,0.17,0.97,1.8
DOT  ,USD,False,45,0.01,0.97,1.08
COMP ,USD,False,49,0.05,0.97,1.11
QNT  ,USD,False,43,0.02,0.96,0.98
PLA  ,USD,False,45,0.02,0.96,1.19
OXT  ,USD,False,47,0.01,0.96,1.13
ETC  ,USD,False,39,0.0 ,0.96,1.07
CRV  ,USD,False,47,0.08,0.96,0.92
BCH  ,USD,False,36,0.1 ,0.96,1.08
LRC  ,USD,False,42,0.08,0.95,0.99
FIL  ,USD,False,41,0.0 ,0.95,1.14
CGLD ,USD,False,44,0.0 ,0.95,1.07
BAL  ,USD,False,38,0.12,0.95,0.88
XTZ  ,USD,False,38,0.03,0.94,1.03
MLN  ,USD,False,36,0.05,0.94,0.9
BAT  ,USD,False,38,0.01,0.94,1.07
BAND ,USD,False,44,0.01,0.94,1.12
ANKR ,USD,False,43,0.01,0.94,1.06
LPT  ,USD,False,41,0.04,0.92,1.13
GLM  ,USD,False,41,0.02,0.92,1.18
CVC  ,USD,False,48,0.05,0.91,1.27
ZRX  ,USD,False,36,0.09,0.9 ,1.68
YFI  ,USD,False,42,0.04,0.9 ,1.32
MATIC,USD,False,28,0.03,0.9 ,1.1
KNC  ,USD,False,27,0.03,0.9 ,1.11
BNT  ,USD,False,32,0.08,0.9 ,1.56
POLY ,USD,False,30,0.01,0.81,1.2

 

 

ChatGPT will create Tags

Finally by posting this post into a prompt you can ask ChatGPT to generate Tags for the post. I used most of them but trimmed a few that were redundant.

Stacks of Coin

Bitcoin’s Soft Underbelly

The best way to make money is to go out and do it yourself.

Hey ChatGPT, Do you what Bitcoin is?

Yes, I am familiar with Bitcoin. Bitcoin is a decentralized digital currency that uses cryptography for security and is supported by a peer-to-peer network. It was created in 2009 by an unknown individual or group of individuals using the pseudonym Satoshi Nakamoto.

Bitcoin is based on a distributed ledger technology called the blockchain, which allows it to operate without the need for a central authority. Transactions are recorded in blocks, which are linked together in a chain. This chain of blocks is secured using complex mathematical algorithms, which makes it extremely difficult to alter the record of transactions.

Bitcoin can be used to send and receive payments over the internet, and it has attracted a lot of attention due to its potential to disrupt traditional financial systems. However, it has also been associated with criminal activities, and its value can be volatile.

Hidden Risks

Just to linger on the topic for a moment, Bitcoin, has another risk that does not get enough mention. Cryptography has a shelf life and eventually breaks, either via some discovery of a short path to crack a private key given a public key or collisions. Bitcoin uses SHA256 encryption which seems safe for now but, as with all hash algorithms, there is no closed form solution that shows it is watertight. It’s more along the lines of, well the last cryptographic code broke because of X,Y or Z, so lets beef the new one up to be stronger in those areas. But, someone might find a crack in SHA256 tomorrow, just like what happened for SHA-1 not too long ago From what I recall it was a university research project that broke it. Or looking at the second failure mode, when will brute force collision with a large number of private keys become possible and profitable, It’s only a matter of time. 256 bits is a lot a space to brute force through. But, computing power (Now multi threaded quantum computing too ) grows over time and large entities such as nation states with deep pockets could do something like this at some point in the not so distant future. Is this possible, who knows now, but someday it might.

There are known knowns, known unknowns and then the ones that get you when you least expect it, unknown unknowns and this risk clearly falls in that category.

Interesting to Skim

https://www.whitehouse.gov/wp-content/uploads/2022/11/M-23-02-M-Memo-on-Migrating-to-Post-Quantum-Cryptography.pdf

Lightbeam Cat

Luna Rides Light Beam

Can you write a story about a cat riding a beam of light. Use a writing style that is characterized by a narrative storytelling approach, use anecdotes and examples to illustrate the main points and also ask pretend questions about your own beliefs and assumptions, use a conversational tone and make it easy to follow your reasoning. Also use metaphors and comparisons.

Once upon a time, there was a cat named Luna who lived in a small village at the foot of a mountain. Luna was a curious and adventurous cat, always looking for new and exciting experiences.

One day, while exploring the mountain, Luna stumbled upon a strange, glowing beam of light. Without hesitation, she leapt onto the beam and began to ride it. The beam was like a magic carpet, lifting Luna higher and higher into the sky.

As Luna rode the beam, she saw things she had never seen before. The world below her became smaller and smaller, and she could see for miles and miles. She felt like she was flying, free as a bird. Luna felt a sense of wonder and amazement as she soared through the air.

As Luna rode the beam, she couldn’t help but think about the nature of light. She remembered her physics lessons and wondered if light was a particle or a wave. She wondered if the beam she was riding on was made up of photons, the fundamental particles of light. Luna also wondered if the beam she was riding on was infinite, and if there were other cats riding on beams of light somewhere in the universe.

But Luna quickly realized that these were just idle musings and that she should just enjoy the ride. The beam was like a river of light, and Luna was its fearless navigator. She rode the beam, feeling the wind in her fur, and the sun on her face.

Just as Luna was starting to feel like the beam would take her to the ends of the earth, it suddenly disappeared. Luna found herself back on the mountain, with the village below her. She realized that her adventure had come to an end, but the memories of it would stay with her forever.

From that day on, Luna had a new appreciation for the beauty and mystery of light. She would often return to the mountain and gaze up at the sky, searching for that magical beam of light once again.

And who knows? Maybe, just maybe, she would find it and ride it again, forever exploring the unknown and experiencing the wonder of the universe.

Kelly Criterion Paper

ChatGPT tackles dense research papers

Never underestimate life’s beauty.

ChatGPT can help to understand parts of a research paper that require clarification.

In this case the paper happens to be on applying the Kelly criterion to a portfolio of multiple assets.   I was interested in the paper and read through it a few times and understand it pretty well as I have been studying this area recently, including reading Fortune’s Formula by William Poundstone which deals with the Kelly criterion. But, I wanted to make sure my understanding was concrete.  I want to understand it in a way that I can compare what I personally have done in the way of setting up a portfolio. Specifically code that manages an index fund with risk management applied that operates similar the way the Kelly criterion works.

Electronic copy available at: http://ssrn.com/abstract=2259133Kelly criterion for multivariate portfolios: a model-free approach

The process involved to simplify text

By pasting in a section of the paper and asking it to dumb it down a bit and then interacting with it using some followup questions it can help clarify it. ChatGPT can be asked to bring it down to a high school level or alternatively you can tell it an age that you want the understanding to be brought down to.

In this case I also asked it to produce and example using Python code. The code is functional, however there is a few unused variables in it.


Transcript of the ‘conversation’ with ChatGPT

Explain the following in simpler terms, like high school level… Algorithm for the fractional Kelly strategies The strategies that bet less than the Kelly fraction are called fractional Kelly strategies. As we just pointed out, they are less profitable but also less risky. In the case of a univariate portfolio we just decrease the capital fraction invested in the risky asset and shift the released capital to the riskless bond. But for a multivariate portfolio such an approach is ambiguous. Indeed, an investor usually cares about the total fraction of risky assets in his/her portfolio. And s/he can at first proportionally descrease the fractions of all risky assets in u? but then additionally redistribute the capital among the risky assets. If the returns are jointly Gaussian then we shall just proportionally reduce the fractions of the risky assets. Moreover, in this case the strategy with Kelly fraction x := 1/(1 − α) is equivalent to the maximization of the (negative) power utility xα/α, α < 0. But in general this nice property does not hold true (see MacLean et al. [2010] and Davis and Lleo [2012]). For instance7, even if the marginal returns are Gaussian but the marginals are paired by Clayton copula, then the proportional fraction reduction is suboptimal. Imposing additional constraints 0 ≤ ui ≤ x ∀i and ∑n i=1 ui ≤ x we can still use (3) to find the optimal portfolio for a given x. However, (3) may be a bad approximation for the leveraged portfolios or the portfolios that contain assets with possibly very high returns8 (see Appendix 1). Additionally, practitioners usually like having two independent optimization methods: if both of them get similar results then they are plausible. We consider the portfolio optimization under the no leverage and no short selling constraints. A Monte Carlo grope algorithm we employ is as follows: 1. Assume we want to invest x of our capital in risky assets9, x ∈ [0%, 100%]. Choose an initial portfolio so that all fractions of the risky assets are between 0.0 and x and their sum is equal to x. Distributing the capital over all assets equally may be a good start. 2. (Groping step): modify the fractions at random so that the no short selling and no leverage conditions still hold. If the new portfolio yields higher expected growth rate, set it as initial portfolio, otherwise leave initial portfolio unchanged. 3. Repeat Step 2 until portfolio performance stops increasing.

The Kelly strategy is a way to invest money in different assets (like stocks or bonds) in order to make the most profit. The Kelly strategy says that you should invest a certain percentage of your money into each asset, based on how likely that asset is to make a profit. However, this strategy can be risky because if one of your assets doesn’t make as much money as you expected, you can lose a lot of your overall investment.

A fractional Kelly strategy is a way to make the Kelly strategy less risky by investing less money into each asset. For example, instead of following the Kelly strategy exactly, you might only invest 80% of the money that the Kelly strategy suggests. This means you’ll make less profit, but you’ll also be less likely to lose a lot of money.

When you’re using a fractional Kelly strategy for a portfolio (a collection of assets) that has multiple types of assets, it can be tricky to figure out how much to invest in each one. If all of the assets are likely to make similar profits, you can just decrease the percentage you’re investing in each one by the same amount. But if the assets have different levels of risk, you’ll need to adjust the percentages differently.

One way to do this is by using a computer program that simulates how different portfolios would perform. The program starts with a random portfolio and then makes small changes to it, to see if it will make more profit. If the new portfolio is better, the program switches to it and continues making changes. If the portfolio stops improving, the program stops.

This process is called a “Monte Carlo simulation” because it uses random numbers and works like a game of chance. By doing this simulation many times, it will get a portfolio that has a better chance to make a better return. The optimization process will be constraint by no leverage and no short selling, and the final result will be the optimal portfolio.

Would it be possible to use historic data or some kind of model data?

Yes, it is possible to use historic data or model data when using a fractional Kelly strategy. In fact, using historical data is often necessary in order to estimate the expected returns and risks of different assets.

One way to use historic data is by looking at the past performance of the assets. By analyzing the returns of an asset over a certain period of time, you can estimate the expected return and risk of investing in that asset. This information can then be used as input for the simulation algorithm.

Another way is to use financial models to estimate the expected returns and risks of different assets. These models use mathematical equations to describe how the assets should behave based on certain factors, such as economic conditions, market trends, and other variables. By plugging in the relevant information into the model, you can get estimates of the expected returns and risks of investing in different assets. This information can also be used as an input for the simulation algorithm

It’s important to note that, regardless of the input, the simulation and optimization algorithm will still work by exploring different portfolio scenarios under the constraints and looking for the one that will generate a higher expected return.

 

When working with historical data I assume it is going to be simulating trades.

Yes, when working with historical data, it is common to use it to simulate trades and backtest the strategy.

Backtesting is the process of applying a trading strategy to historical data to see how it would have performed in the past. By simulating trades on historical data, you can get an idea of how the strategy would have performed in the past and evaluate the strategy’s performance.

When you’re backtesting a fractional Kelly strategy, you would use historical data on the returns and risks of the assets in your portfolio to estimate the expected returns and risks. You would then use the simulation algorithm to generate different portfolios and apply the fractional Kelly strategy to them. The simulated trades will be compared to actual historical returns and the strategy performance will be evaluated.

It’s important to remember that past performance does not guarantee future results and that backtesting does not take into account all the risks of real-world trading. However, backtesting allows you to check how the strategy behaves over the course of history and how it could have performed if it would have been used in the past. This can give you an idea of how the strategy might perform in the future, and whether it’s worth implementing in a live trading scenario.


So, in essence it is using backtesting on set of assets and adjusting the fraction of each of them up and down randomly to find the best overall gains of the entire portfolio.

Yes, that’s correct! Essentially, backtesting a fractional Kelly strategy involves using historical data on the returns and risks of the assets in your portfolio, and then using a simulation algorithm to generate different portfolios. The algorithm will make random adjustments to the fraction of capital invested in each asset and will evaluate the expected return of each portfolio generated. The goal of this process is to find the portfolio that will generate the best overall gains by adjusting the fraction of capital invested in each assets, that is the one that will have the highest expected return.

In practice, the algorithm will explore the portfolio space by making random changes to the portfolio, according to the constraints and the Kelly strategy, and it will keep track of the best portfolio so far. The algorithm will repeat this process multiple times until it reaches a predefined criteria to stop, such as reaching a certain number of iterations or reaching a level of portfolio performance.

It’s worth noting that the algorithm can explore a large number of different portfolio combinations and therefore it can be a computationally expensive process. But, it allows to find the optimal portfolio given the conditions of the assets, constraints, and the Kelly strategy, and it can also provides insights on how the assets are behaving together.


If the algorithm finds the best returns isn’t this equivalent to the Kelly strategy.

Not exactly, while the fractional Kelly strategy and the algorithm I’ve described are related, they are not the same thing.

The Kelly strategy is a mathematical formula that tells you the optimal percentage of your capital to invest in each asset, given the expected returns and risks of the assets. The formula is based on the idea that you want to maximize your long-term growth rate, and it assumes that you have a perfect estimate of the expected returns and risks of each asset.

The algorithm I described, on the other hand, is a process for finding a good portfolio using the constraints and the Kelly strategy, but it doesn’t follow the formula exactly. Instead, it uses historical data and simulations to estimate the expected returns and risks of the assets, and it explores different portfolio combinations to find the one that generates the highest return. It may find a portfolio that is similar or equivalent to what the Kelly formula would suggest, but it is not guaranteed to do so.

It’s worth noting that the Kelly strategy can be challenging to implement in practice because of the difficulty to estimate the expected return and risk for each asset and because of the Kelly assumption that an individual can reinvest the profits and have no constraints on the bet size. On the other hand, the fractional Kelly algorithm is a more practical approach that can handle different constraints and real-world scenarios, such as leverage and short selling constraints.


Is there a simple example that can be shown with Python code?

Here is a simple example of how you might use Python code to backtest a fractional Kelly strategy:

import numpy as np

# Example data: historical returns and volatilities of three assets
returns = np.array([[0.02, 0.03, 0.01], [0.05, 0.02, 0.04], [0.04, 0.06, 0.03]])
volatilities = np.array([[0.01, 0.02, 0.005], [0.02, 0.01, 0.03], [0.01, 0.03, 0.02]])

# Initialize portfolio with equal fractions of capital invested in each asset
portfolio = np.array([1/3, 1/3, 1/3])

# Set the Kelly fraction (fraction of capital to invest in risky assets)
kelly_fraction = 0.8

# Set the number of simulations to run
num_simulations = 1000

# Set the fractional Kelly fraction
frac_kelly = 0.6

# Initialize a variable to keep track of the maximum portfolio return
best_return = -np.inf

# Run the simulations
for i in range(num_simulations):
    # Randomly adjust the portfolio fractions
    new_portfolio = portfolio + np.random.normal(size=3) * 0.01
    # Make sure the fractions are between 0 and the Kelly fraction
    new_portfolio = np.maximum(new_portfolio, 0)
    new_portfolio = np.minimum(new_portfolio, frac_kelly)
    # Make sure the fractions sum to 1
    new_portfolio = new_portfolio / new_portfolio.sum()
    # Calculate the expected return and volatility of the new portfolio
    expected_return = (new_portfolio * returns).sum()
    expected_volatility = (new_portfolio * volatilities).sum()
    # Update the best portfolio if the new one has a higher return
    if expected_return > best_return:
        portfolio = new_portfolio
        best_return = expected_return

# Print the optimal portfolio fractions
print("Optimal portfolio fractions:", portfolio)

This code is a simple example that shows how you can use Python to backtest a fractional Kelly strategy. The example uses historical returns and volatilities of three assets. The code set the Kelly fraction to 0.8 and the fractional Kelly fraction to 0.6 and runs the simulation 1000 times.

It starts with an initial portfolio that has equal fractions of capital invested in each asset, and then makes small random changes to the portfolio in each simulation. It then checks whether the new portfolio has a higher expected return and if so, it keeps the new portfolio and continue the process. After all the simulations are done, the optimal portfolio fractions are printed.

Keep in mind that this is a very simple example, and in practice, you would need to use more sophisticated methods to estimate the expected returns and risks of the assets, and you would need to use more realistic constraints. Additionally, you would want to test the performance of the algorithm with a variety of scenarios and parameters to validate the strategy.


Is it possible to use a genetic algorithm for this instead of Monte Carlo simulation?

Yes, it is possible to use a genetic algorithm for backtesting a fractional Kelly strategy instead of a Monte Carlo simulation. A genetic algorithm is a type of optimization algorithm that is inspired by the process of natural selection.

Just like the Monte Carlo simulation algorithm that I described earlier, a genetic algorithm would be used to explore the portfolio space and find the portfolio that generates the highest expected return. However, instead of making random changes to the portfolio, a genetic algorithm uses the principles of natural selection to evolve a population of portfolios over time.

Here’s a general overview of how a genetic algorithm for backtesting a fractional Kelly strategy might work:

  1. Start with an initial population of portfolios that are randomly generated and satisfy the constraints of the problem.
  2. Evaluate the fitness of each portfolio in the population. This is usually done by calculating the expected return of each portfolio and use it as the fitness value
  3. Select the best portfolios from the population to “breed” new portfolios. The selection process is usually based on the fitness value of each portfolio.
  4. “Breed” new portfolios by combining the characteristics of the selected portfolios through crossover and mutation operators.
  5. Repeat the process of selection, breeding, and mutation until the performance of the population reaches a predefined stopping criteria.
  6. Return the best portfolio of the final population.

A genetic algorithm can be a powerful optimization technique, and it has the ability to find globally optimal solutions to problems that are difficult to solve using other methods. However, it also has its limitations, such as the difficulty of determining the optimal configuration of parameters and the risk of getting stuck in local optima.

It is also worth noting that, similar to the Monte Carlo simulation, a genetic algorithm would still need to estimate the expected return and risk of each assets, and it would also need to be validated and tested thoroughly with a variety of scenarios and parameters before it is used in a live trading scenario.

sqrt(2) AI

Generating Code With ChatGPT

ChatGPT can generate code by asking for it using plain English. Here are a few examples easy and some harder where it generates code to get the square root of two. It fails to do it via a genetic algorithm although the form of the code is not too bad and looks like it could be debugged and modified to work. For a different spin I asked it to do it using BASH script as well. ChatGPT has some ways to go but it is a world ahead of GPT3.0,2.0 and other generative text models I have used over the last 5 years.
Can you write Python code to get the square root of two?

Certainly! Here is some Python code that you can use to calculate the square root of two:

 import math

# Calculate the square root of two
square_root_of_two = math.sqrt(2)

# Print the result
print(square_root_of_two)

This code uses the sqrt() function from the math module to calculate the square root of a number. In this case, the number is 2, so the code will calculate the square root of two.

The sqrt() function returns the result as a floating point number, which is a type of data that can represent decimal values. The code then prints the result using the print() function, which will output the square root of two to the console.

I hope this helps! Let me know if you have any questions or if you need further assistance.


Can you redo the code using Newton’s method?

Certainly! Here is some Python code that uses Newton’s method to calculate the square root of two:

 # Function to calculate the square root using Newton's method
def square_root(x, guess=1.0):
    # Calculate the next guess using Newton's method
    next_guess = (guess + x / guess) / 2
    
    # Check if the guess is close enough to the actual value
    if abs(next_guess - guess) < 0.00001:
        # If it is, return the result
        return next_guess
    else:
        # If it's not, use the next guess as the new starting point and call the function again
        return square_root(x, next_guess)

# Calculate the square root of two
square_root_of_two = square_root(2)

# Print the result
print(square_root_of_two)

This code defines a function called square_root() that takes two arguments: the number for which you want to calculate the square root (x), and an initial guess for the square root (guess). The function uses Newton’s method to iteratively improve the guess until it is close enough to the actual value, at which point it returns the result.

To calculate the square root of two, you can call the square_root() function with the number 2 as the first argument. The function will then return the square root of two as a floating point number, which you can then print to the console using the print() function.

I hope this helps! Let me know if you have any questions or if you need further assistance.


Can you make Python code using recursion to calculate the square root of two?

Certainly! Here is a Python function that uses recursion to calculate the square root of two:

 def sqrt(x, guess=1.0):
    if abs(guess**2 - x) < 0.00001:
        return guess
    else:
        return sqrt(x, (guess + x/guess)/2)

result = sqrt(2)
print(result)

This function uses the Newton-Raphson method to calculate the square root of a given number x. The function takes an optional initial guess for the square root, which is used as the starting point for the iterative process. The function then calculates a new guess using the formula (guess + x/guess)/2, which is derived from the equation f(guess) = guess^2 - x = 0. The function then checks whether the difference between the new guess and the true value of the square root is small enough, and if it is, it returns the guess. Otherwise, it calls itself with the new guess and continues the iterative process.

This function will continue to iterate until it finds a guess that is close enough to the true value of the square root, at which point it will return the final guess. The function will terminate when the difference between the guess and the true value is small enough, as determined by the abs(guess**2 - x) < 0.00001 condition.

You can try calling the sqrt function with different values of x to see how it works. For example, to calculate the square root of two, you can call sqrt(2).


Can you make Python code to calculate the square root of two using machine learning?

Certainly! Here is a Python function that uses a machine learning model to calculate the square root of two:

 import numpy as np
from sklearn.linear_model import LinearRegression

def sqrt(x):
    # Create training data
    X = np.array([1, 2, 3, 4, 5]).reshape(-1, 1)
    y = np.array([1, 1.41421356, 1.73205081, 2, 2.23606798])
    
    # Create and fit the model
    model = LinearRegression()
    model.fit(X, y)
    
    # Use the model to predict the square root of x
    return model.predict([[x]])[0]

result = sqrt(2)
print(result)
 

This function uses a linear regression model from the sklearn library to predict the square root of a given number x. The model is trained on a dataset of input-output pairs, where the input is a number and the output is its square root. The model is then used to predict the square root of x by calling the predict method and passing it the value of x as an input.

To use this function, you will need to install the numpy and sklearn libraries


Can you calculate the square root of two using a bash script?

Certainly! Here is a bash script that calculates the square root of two using the bc command-line calculator:

 #!/bin/bash

# Calculate the square root of 2 using the bc calculator
sqrt=$(echo "sqrt(2)" | bc -l)

# Print the result
echo "The square root of 2 is: $sqrt"


To run this script, save it to a file and make it executable using the chmod command:

 chmod +x sqrt.sh

Then you can run the script by calling it:

 ./sqrt.sh

This script uses the bc command-line calculator to calculate the square root of two by passing the expression sqrt(2) to the bc command and using the -l flag to specify that it should use the built-in math library. The result is stored in the sqrt variable and is then printed to the console.

The bc command is a powerful calculator that can perform a wide range of mathematical operations, including arithmetic, algebra, trigonometry, and more. It is often used in bash scripts to perform calculations and manipulate numerical data.


Non Functional code was produced when it was asked to generate the code to do sqrt of 2 using a genetic algorithm. I had asked it to refine code that it generated that ‘ran off the page’ to shorten it. It removed some comments and streamlined the code as well.

Certainly! Here is a shorter version of the Python code that uses a genetic algorithm to find the square root of two:

 import random

def fitness(individual):
    return 1/abs(individual - 2**0.5)

def create_population(size):
    return [random.random() for _ in range(size)]

def select_parent(population, tournament_size):
    random.shuffle(population)
    return max(population[:tournament_size], key=fitness)

def reproduce(parent1, parent2):
    split_point = random.randint(1, len(parent1)-1)
    return parent1[:split_point] + parent2[split_point:]

def mutate(individual):
    mutate_index = random.randint(0, len(individual)-1)
    mutate_value = random.random()
    return individual[:mutate_index] + [mutate_value] + individual[mutate_index+1:]

def evolve(population, retain_percentage, random_select_percentage, mutation_rate):
    retain_length = int(len(population) * retain_percentage)
    random_length = int(len(population) * random_select_percentage)
    sorted_population = sorted(population, key=fitness, reverse=True)
    parents = sorted_population[:retain_length]
    for individual in sorted_population[retain_length:retain_length+random_length]:
        if random.random() < mutation_rate:
            parents.append(individual)
    parents_length = len(parents)
    desired_length = len(population) - parents_length
    children = []
    while len(children) < desired_length:
        parent1 = select_parent(population, tournament_size=5)
        parent2 = select_parent(population, tournament_size=5)
        child = reproduce(parent1, parent2)
        if random.random() < mutation_rate:
            child = mutate(child)
        children.append(child)
    parents.extend(children)
    return parents

def run_genetic_algorithm(population_size=100, generations=100, retain_percentage=0.2, random_select_percentage=0.05, mutation_rate=0.01):
    population = create_population(population_size)
    for _ in range(generations):
        population = evolve(population, retain_percentage, random_select_percentage, mutation_rate)
    return max(population, key=fitness)

result = run_genetic_algorithm()
print(result)
 

This code uses a genetic algorithm to search for the square root of two by generating a population of possible values and iteratively improving them through reproduction, mutation, and selection. The fitness function is used to evaluate the quality of each individual, and the genetic algorithm uses this function to guide the search towards better solutions.

 

Chicken Tenders

Chicken Tenders Monetary Standard

Really? Not sure on this idea, so let’s ask ChatGPT

Could chicken tenders be used as a standard?

Chicken tenders, or strips of chicken breast that are breaded and fried, could not be used as a standard for currency or any other type of financial system.

There are several reasons why chicken tenders (or any other type of food) could not be used as a standard. One reason is that they do not have a stable value. The value of chicken tenders (or any other type of food) can fluctuate based on a variety of factors, including supply and demand, production costs, and market conditions. This makes them an unreliable store of value and an unreliable medium of exchange.

Another reason is that chicken tenders (or any other type of food) do not have a widely recognized value or a widely accepted means of exchange. Unlike fiat currencies, which are issued by governments and accepted as a means of payment in most countries, chicken tenders (or any other type of food) are not recognized as a legitimate form of payment and are not widely accepted as a medium of exchange.

Finally, chicken tenders (or any other type of food) are subject to spoilage and deterioration, which makes them a poor choice as a standard for currency or any other type of financial system.

Overall, it is not practical or feasible to use chicken tenders (or any other type of food) as a standard for currency or any other type of financial system.

Create a stable coin based on chicken tenders.

It would not be practical or feasible to create a stablecoin based on chicken tenders. While it is theoretically possible to create a stablecoin based on any type of asset, including chicken tenders, there are several reasons why it would not be practical or feasible in this case.

One reason is that chicken tenders (or any other type of food) do not have a stable value. The value of chicken tenders (or any other type of food) can fluctuate based on a variety of factors, including supply and demand, production costs, and market conditions. This makes them an unreliable store of value and an unreliable medium of exchange, which would make it difficult to maintain the stability of a stablecoin based on chicken tenders.

Another reason is that chicken tenders (or any other type of food) do not have a widely recognized value or a widely accepted means of exchange. Unlike fiat currencies, which are issued by governments and accepted as a means of payment in most countries, chicken tenders (or any other type of food) are not recognized as a legitimate form of payment and are not widely accepted as a medium of exchange. This would make it difficult for people to use a stablecoin based on chicken tenders in everyday transactions.

Finally, chicken tenders (or any other type of food) are subject to spoilage and deterioration, which would make it difficult to maintain a stablecoin based on chicken tenders over the long term.

Overall, it is not practical or feasible to create a stablecoin based on chicken tenders or any other type of food.


On a more serious note check out The Bitcoin Standard, which might actually work.

Also there are interviews ( by Jordan Peterson and Lex Fridman ) with Saifedean Ammous an Austrian economist who wrote, The Bitcoin Standard: The Decentralized Alternative to Central Banking, see this post … http://erick.heart-centered-living.org/info-links/jordan-peterson-bitcoin-interview/