Skip to content

Instantly share code, notes, and snippets.

High-level design of a trading bot

Overview

flowchart LR;
    UI[UI Component - WPF/Web/etc] --> B;
    B([Trading Bot APIs]) -- list --> SR[[Strategy Registry]];
    SR --x SI[Strategy Implementations...];
public class Inventory {
public int getCapacity();
public int getAvailableStorageUnit();
public List<Long> getProductIdList();
public int getQuantity(long productId);
public boolean addToStock(long productId, int quantity);
public boolean removeFromStock(long productId, int quantity);
#num of philosopher
num_p = 5
# num of meal/philosopher
r =1000
Tanenbaum_forks =[Semaphore(0) for i in range(num_p)]
t_mutex =Semaphore(1)
state=['thinking']*num_p
@Override
protected String doInBackground(String... data) {
HttpURLConnection urlConnection = null;
try {
URL url = new URL("http://192.168.1.7:1337/api/doc");
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("POST");
urlConnection.setRequestProperty("Accept", "application/json");
urlConnection.setRequestProperty("Content-type", "application/json");
urlConnection.setRequestProperty("charset", "utf-8");
public class Solution {
public void solveSudoku(char[][] board) {
int rLength = board.length;
int cLength = board[0].length;
List<Character> candidate = new Arraylist<Character>();
for(int i =1; i < rLength+1, i++){
candidate.add((char)i);
}
for(int i = 0; i < rLength; i++){
for(int j = 0; j < cLength; j++ ){
package com.example.miaodonghan.hw3_listview;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.LabeledIntent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;