Scripting in Think Or Swim #ToS

Implementing EMA Clouds in ThinkScript

#Multiple EMA Cloud input ema1low = 5; input ema1high = 13; input ema2low = 34; input ema2high = 50; input ema3low = 72; input ema3high = 89; def ema5 = ExpAverage(close, ema1low); def ema13 = ExpAverage(close, ema1high); AddCloud(ema5, ema13, Color.DARK_GREEN, Color.RED); def ema34 = ExpAverage(close, ema2low); def ema50 = ExpAverage(close, ema2high); AddCloud(ema34, ema50, Color.green, Color.light_gray); def ema72 = ExpAverage(close, ema3low); def ema89 = ExpAverage(close, ema3high); AddCloud(ema72, ema89, Color.blue, Color.yellow); def buycross = (ema5 > ema13) and (ema34 crosses above ema50); def buycrossAdditional = (ema72 crosses above ema89); AddOrder(OrderType.BUY_TO_OPEN, buycross, tickColor = GetColor(1), arrowColor = GetColor(1), name = "Buy", tradeSize = floor(10000 / close)); def sellcross = ema5 crosses below ema13 and (ema34 < ema50); AddOrder(OrderType.SELL_TO_CLOSE, sellcross, tickColor = GetColor(0), arrowColor = GetColor(0), name = "Sell"); AddLabel(yes, "EMA5 & EMA13 = Dark Green & Red", Color.DARK_GREEN); AddLabel(yes, "EMA34 & EMA50 = Green & Light Grey", Color.GREEN); AddLabel(yes, "EMA72 & EMA89 = Blue & Yellow", Color.BLUE); read more

Enterprise Mobility @ SAP – Relay

This is another blog post of a series around the enterprise mobility IT team at SAP. We are an internal IT team focused on managing mobile devices, applications, and developing custom apps for SAP’s 100,000 employees. I have been a part of this team for the past six years and believe we have some unique stories, software, tools, and insights to help others in the community considering, or currently undertaking, some of the challenges which surround mobility and its adoption in the enterprise.

Introduction

As mentioned in previous posts, apps are an essential cornerstone of mobility @ SAP. Whether they are employee initiated or driven by innovation, we adopt the underlying processes and do our best to deliver solutions that increase our end users’ productivity. This post will take a deep dive into the ideation, architecture, design, and lifecycle of an internal app called Relay. A real-time chat application initially developed in 2012 using the Business Technology Platform (Previously known as the SAP Cloud Platform). A variation of the application might be familiar to some of you SAP community users, as Messages. We recently retired the application internally due to the increased adoption of MS Teams and Slack. However, I believe that some of the concepts and premise behind the application are still relevant to share. read more

Working with Bluetooth for iOS Applications

I recently purchased a Concept2 rower and started doing some indoor rowing to change up my workout routines. I was considering developing a live rowing platform to compete with friends and make the workouts more interactive. It turned out there were already a few options on the market, so I shelved the idea.

But, since the Concept2 allows 3rd party connectivity, I still was curious how integration, discovery, and notifications would work from an iOS device. I was able to find a nice SDK, but it was considerably outdated (5 years) so I decided to use that as a foundation and port the application to Swift 5 and get it working for anyone else interested in developing a rowing app for iOS. read more

Side Project: qubit²

Over the past couple of years I have had a keen interest in quantum computing and the optimism of its benefits over traditional computing methods. I have read countless papers, articles and spent a considerable amount of time deciding how I would explain it to a 5 year old.

ELI5: A normal computer is like a light switch is either on or off. A quantum computer is more like a dimmer switch, it can be partially on, or partially off.

It’s overly simplistic but gives a simple understanding of the potential states that the device can be in. I also wonder how I would explain QC to friends or technology friends. Trying to find the right words that quantify both its elementary simplicity and its quantitative complexity is difficult, especially when you yourself don’t fully grasp it. But like other technologies, the best way to learn is by doing … experimenting, researching and proofing. Leading to your own understanding and comprehension of existing anecdotes and theories or new ones. read more

Relicensing your open source projects from * to BSL (Business Source License)

As a creator and contributer to open source projects I am often torn as how to license my projects to encourage the greater community to contribute and have creative freedom with a project. However I would still try to ensure that I maintain control over as much of the intellectual property (IP) or business value as possible – especially if this value is what I have in place as a revenue generator and would enable me to continue development of the project.

Sentry – which is a great error logging/monitoring tool – recently evaluated their open source licensing and had some reasonable goals in mind:

  • Anyone should be able to run Sentry for themselves or their business
  • No difference between our cloud service and our open-source product (no open-core model)
  • Minimal limitations on usage of code; as free as possible
  • Protection from other companies selling our work

Due to the weight on the last point, Sentry decided to change their license from BSD-3/Apache-2.0 to BSL. read more

A simplistic Node.js implementation of RSA encryption/decryption

This is a basic and simplistic implementation of RSA in JS which used to understand the implementation/math required for encryption/decryption and opportunities for hacking RSA using Quantum Computing.

If you are looking for a nice article on RSA and a small practical example, this might be helpful https://simple.wikipedia.org/wiki/RSA_algorithm

Hacking RSA using Prime Number Factorization

Hacking RSA uses the numeric public exponent from the public key and tries to calculate its largest common multiple factors (p and q) – from those two numbers you can calculate the Private Key. Using traditional computing to hack “small” RSA public keys can be done with a few modern algorithms, including the currently fastest General Number Field Sieve.

A nice library for General Number Field Sieves is http://cado-nfs.gforge.inria.fr/

You can use this site to factor a prime without having to install anything https://asecuritysite.com/encryption/factors. Enter the Public Key which gets generated by the code (should be < 100 bits for the site to be able to factor)

Installation

npm install

Usage

Edit the index.js file if you would like to edit the size or message being encrypted:

// Message
const message = 'Hello';

// Generate RSA keys (bits), max is 232 digits (768 bits)
const keys = RSA.generate(80);

Run the code

npm run start

Example Output

Public Key Exponent (e):65537 Random Prime (p): 798000088811 Random Prime (q): 563631878177 Totient (lcm of (p-1)(q-1)): 224889144420297550405280 ------------------------------------------------- Keys Public Key (n = p * q): 449778288841956732777547 Public Key Length: 24 digits (79 bits) Private Key (d = e multiplicative inverse (totient)): 210473481577786144493313 Private Key Length: 24 digits (78 bits) ------------------------------------------------- Message: Hello Encoded: 72101108108111 Encrypted (c = encoded message (m) ^ e modulo n): 426078873740860671226694 Decrypted (m = encrypted message (c) ^ d modulo n): 72101108108111 Decoded: Hello Correct? true read more

Open Source Project & Paper: Blockchain proof of concept

Late last year I wrote a small paper (for my MBA program) and developed an accompanying proof of concept (Javascript/Node/P2P) on the implementation of blockchain in the retail or food distribution network around protecting goods from food fraud.

Source Code: https://github.com/paschmann/blockchain_origin

Abstract

Food fraud is a crime which has the potential to negatively affect the brand image, financial resources and impact multiple parties in the supply chain paradigm of food distribution. The ability to track and trace the origin and touch points of products throughout the network is imperative to limit the impact caused by a food fraud incident or a food safety issue. Blockchain has the potential to disrupt multiple industries by providing a shared and trusted ledger of transactions which no single company controls. One practical application of blockchain is utilizing the platform as a static register – a distributed database for storing reference data. In this paper I will describe a technical implementation of a blockchain in a practical scenario which shares the details and a proof of concept of a food origin scenario. The implementation will share a simplistic JavaScript application of a digital ledger based blockchain allowing manufacturers to register data on the food origin in the static registry and vested parties the ability to augment and view the data for the purpose of traceability and accuracy. read more

Open Source Project: Rasa UI

Rasa is an open source machine learning framework to automate text-and voice-based conversations.

Rasa UI is a web application built on top of, and for Rasa. Rasa UI provides a web application to quickly and easily be able to create and manage bots, NLU components (Regex, Examples, Entities, Intents, etc.) and Core components (Stories, Actions, Responses, etc.) through a web interface. It also provides some convenience features for Rasa, like training and loading your models, monitoring usage or viewing logs.

I developed Rasa UI to help me manage my bots as well as creating and managing the training data. The app is developed on NodeJS, and uses a simple SQLite DB for persistence (previously PostgresDB). read more